All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 00/62] Add ACPI support for arm64 on Xen
@ 2015-11-17  9:39 shannon.zhao at linaro.org
  2015-11-17  9:40 ` [PATCH v3 01/62] Revert "xen/arm: vgic-v2: Drop cbase from arch_domain" shannon.zhao
                   ` (67 more replies)
  0 siblings, 68 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:39 UTC (permalink / raw)
  To: linux-arm-kernel

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

This patch set adds ACPI support for arm64 on Xen. The design document
could be found from [1].

Xen reads static tables described by ACPI standard (6.0) from uefi and
configures timer, GIC and UART. ACPI tables are modified to enable PSCI,
HVC and Xen specific information and mapped into Dom0 address space.
A minimal device tree is created to pass EFI table which contains memory
layout (which cannot be passed using ACPI) and RSDP pointer to Dom0
through the node "uefi" under /hypervisor node. Dom0 parses dynamic ACPI
tables and configure other peripherals.

Patch 1 reverts "xen/arm: vgic-v2: Drop cbase from arch_domain" because
d->arch.vgic.cbase will be used by creating Dom0 MADT table later.
Patches 2-36 add ACPI support for Xen/uefi interface.
Patches 37-62 add ACPI support for Xen/Dom0 interface.
Last patch "xen: arm64: Add ACPI support" enables the support for ACPI
so that individual patches do not affect working xen code base.

ACPI is now configurable via command line option "acpi=". To boot from
ACPI this parameter should be set to "force".

Patches are tested on FVP base model. Instructions for reproducing the
setup and working code base can be found from the following repositories
wiki[2], Xen[3], Linux[4], UEFI[5]. Also you can get the test scripts
and firmware binaries from[6].

Note currently the EFI runtime service is not added in this patch set
since I didn't figure out a good way to support that. Dom0 will check if
Xen supports runtime service. If not, Dom0 will not initialize runtime
services. It's a long time since previous patch set and most work has
been done. So I send this patch set out without runtime service support
and later I could continue working on adding runtime service support or
maybe other people who know this better could help work on that based on
this patch set.

Thanks,
Shannon

[1] http://lists.xen.org/archives/html/xen-devel/2015-11/msg00488.html
[2] https://wiki.linaro.org/LEG/Engineering/Xen_boot_on_FVP_ACPI_UEFI
[3] http://git.linaro.org/people/shannon.zhao/linux-mainline.git  ACPI_XEN_ARM_Linux_V1
[4] http://git.linaro.org/people/shannon.zhao/xen.git  ACPI_XEN_ARM_V3
[5] http://git.linaro.org/people/shannon.zhao/linaro-edk2.git  acpi-xen-uefi-v3
[6] http://people.linaro.org/~shannon.zhao/ACPI_XEN/

Most changes since v2:
* Create Dom0 ACPI tables based on new design
* Pass UEFI information to Dom0 through "uefi" node under /hypervisor
  node within FDT
* Define HAVE_NUMA option for NUMA
* Make pmstat dependent on HAS_CPUFREQ
* Refactor some ACPI codes to be aligned wit Linux
* Add GICv3 ACPI support
* Add a hypercall for device MMIO mapping
* Add a hypercall for event-channel interrupt
* Map newly created EFI and ACPI tables to the Xen and Dom0 unused place

Bob Moore (3):
  ACPICA: ACPI 6.0: Add changes for FADT table
  ACPICA: ACPI 6.0: Add changes for MADT table.
  ACPICA: ACPI 6.0: Add support for STAO table

Hanjun Guo (1):
  ACPICA: ACPI 6.0: Add values for MADT GIC version field

Naresh Bhat (3):
  acpi/NUMA: Build NUMA for x86 only
  arm/acpi: Print GIC information when MADT is parsed
  xen/arm64: Add ACPI support

Parth Dixit (17):
  acpi/pmstat: Build pmstat for x86 only
  arm/acpi: Emulate io ports for arm
  arm/acpi: Add basic ACPI initialization
  arm/acpi: Parse MADT to map logical cpu to MPIDR and get
    cpu_possible_map
  arm/smpboot: Move dt specific code in smp to seperate functions
  acpi/table: Introduce acpi_parse_entries
  arm: Introduce a generic way to use a device from acpi
  arm/gic-v2: Add ACPI boot support for GICv2
  arm/acpi: Add GTDT support updated by ACPI 5.1
  arm/irq: Add helper function for setting interrupt type
  arm/acpi: Parse GTDT to initialize timer
  arm/uart: Create generic uart initialization function
  arm/acpi: Initialize serial port from ACPI SPCR table
  arm/acpi: Read acpi memory info from uefi
  arm/p2m: Add helper functions to map memory regions
  arm/acpi: Configure interrupts dynamically
  arm/acpi: Add acpi parameter to enable/disable acpi

Shannon Zhao (38):
  Revert "xen/arm: vgic-v2: Drop cbase from arch_domain"
  acpi: Don't do traditional BIOS table scan for ARM64
  acpi: Refactor acpi_os_map_memory to be architecturally independent
  arm/acpi: Add arch_acpi_os_map_memory helper function for ARM
  arm/acpi: Add arm specific acpi header file
  arm/acpi: Move end_boot_allocator after acpi_boot_table_init
  arm/acpi: Introduce ARM Boot Architecture Flags in FADT
  arm/acpi: Parse FADT table and get PSCI flags
  arm/acpi: Add Generic Interrupt and Distributor struct
  arm/acpi: Add ACPI support for SMP initialization
  arm/gic-v2: Refactor gicv2_init into generic and dt specific parts
  arm/gic-v3: Refactor gicv3_init into generic and dt specific parts
  acpi/table: Introduce acpi_get_entry to get specified entry
  arm/gic-v3: Add ACPI boot support for GICv3
  arm/gic: Add ACPI support for GIC preinit
  arm/acpi: Add a helper function to get interrupt type
  pl011: Refactor pl011 driver to dt and common initialization parts
  serial: Rename SERHND_DTUART to SERHND_UART
  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/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 rest tables for Dom0
  xen/efi: store EFI system table in efi structure
  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: Route all Xen unused SPIs to Dom0
  arm/acpi: Deny MMIO access of UART
  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

 config/arm64.mk                    |   1 +
 xen/arch/arm/Makefile              |   1 +
 xen/arch/arm/acpi/Makefile         |   2 +
 xen/arch/arm/acpi/boot.c           | 214 ++++++++++++
 xen/arch/arm/acpi/lib.c            |  85 +++++
 xen/arch/arm/arm64/smpboot.c       |  12 +-
 xen/arch/arm/device.c              |  19 ++
 xen/arch/arm/domain.c              |   4 +
 xen/arch/arm/domain_build.c        | 667 ++++++++++++++++++++++++++++++++++++-
 xen/arch/arm/efi/efi-boot.h        |  23 ++
 xen/arch/arm/gic-v2.c              | 141 +++++++-
 xen/arch/arm/gic-v3.c              | 271 ++++++++++++---
 xen/arch/arm/gic.c                 |  55 ++-
 xen/arch/arm/irq.c                 |  22 +-
 xen/arch/arm/mm.c                  |   4 +
 xen/arch/arm/p2m.c                 |  60 ++++
 xen/arch/arm/psci.c                |  30 +-
 xen/arch/arm/setup.c               |  37 +-
 xen/arch/arm/smpboot.c             |  34 +-
 xen/arch/arm/time.c                |  73 +++-
 xen/arch/arm/vgic-v2.c             |  10 +-
 xen/arch/arm/vgic.c                |  19 ++
 xen/arch/arm/vuart.c               |   2 +-
 xen/arch/arm/xen.lds.S             |   7 +
 xen/arch/x86/Rules.mk              |   1 +
 xen/arch/x86/acpi/lib.c            |  16 +
 xen/common/efi/boot.c              | 182 ++++++++++
 xen/common/efi/runtime.c           |   2 +-
 xen/common/sysctl.c                |   2 +-
 xen/drivers/acpi/Makefile          |   4 +-
 xen/drivers/acpi/osl.c             |  14 +-
 xen/drivers/acpi/tables.c          | 120 ++++++-
 xen/drivers/char/Makefile          |   2 +-
 xen/drivers/char/arm-uart.c        | 136 ++++++++
 xen/drivers/char/cadence-uart.c    |   2 +-
 xen/drivers/char/dt-uart.c         | 107 ------
 xen/drivers/char/exynos4210-uart.c |   2 +-
 xen/drivers/char/omap-uart.c       |   2 +-
 xen/drivers/char/pl011.c           | 101 ++++--
 xen/drivers/char/scif-uart.c       |   2 +-
 xen/drivers/char/serial.c          |   2 +-
 xen/include/acpi/actbl.h           |  29 +-
 xen/include/acpi/actbl1.h          |  94 +++++-
 xen/include/acpi/actbl2.h          |   5 +
 xen/include/acpi/actbl3.h          | 114 ++++++-
 xen/include/asm-arm/acpi.h         | 108 ++++++
 xen/include/asm-arm/arm64/io.h     |  14 +
 xen/include/asm-arm/config.h       |   5 +
 xen/include/asm-arm/device.h       |  30 ++
 xen/include/asm-arm/domain.h       |   6 +
 xen/include/asm-arm/irq.h          |   2 +
 xen/include/asm-arm/p2m.h          |  15 +
 xen/include/asm-arm/setup.h        |  11 +
 xen/include/public/hvm/params.h    |   5 +
 xen/include/public/memory.h        |   1 +
 xen/include/xen/acpi.h             |  13 +
 xen/include/xen/efi.h              |   1 +
 xen/include/xen/serial.h           |   4 +-
 58 files changed, 2632 insertions(+), 315 deletions(-)
 create mode 100644 xen/arch/arm/acpi/Makefile
 create mode 100644 xen/arch/arm/acpi/boot.c
 create mode 100644 xen/arch/arm/acpi/lib.c
 create mode 100644 xen/drivers/char/arm-uart.c
 delete mode 100644 xen/drivers/char/dt-uart.c
 create mode 100644 xen/include/asm-arm/acpi.h

-- 
2.1.0

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

* [PATCH v3 01/62] Revert "xen/arm: vgic-v2: Drop cbase from arch_domain"
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
  2015-11-17  9:40 ` [PATCH v3 01/62] Revert "xen/arm: vgic-v2: Drop cbase from arch_domain" shannon.zhao
@ 2015-11-17  9:40 ` shannon.zhao at linaro.org
  2015-11-17 11:27     ` Julien Grall
  2015-11-17  9:40 ` [PATCH v3 02/62] acpi/NUMA: Build NUMA for x86 only shannon.zhao at linaro.org
                   ` (65 subsequent siblings)
  67 siblings, 1 reply; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

This reverts commit 810a50db69703f715d199d6b3a5f08193155d48b.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

Conflicts:
	xen/arch/arm/vgic-v2.c
---
 xen/arch/arm/vgic-v2.c       | 10 +++++-----
 xen/include/asm-arm/domain.h |  1 +
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/xen/arch/arm/vgic-v2.c b/xen/arch/arm/vgic-v2.c
index f7d784b..ba7ddac 100644
--- a/xen/arch/arm/vgic-v2.c
+++ b/xen/arch/arm/vgic-v2.c
@@ -531,7 +531,7 @@ static int vgic_v2_vcpu_init(struct vcpu *v)
 static int vgic_v2_domain_init(struct domain *d)
 {
     int i, ret;
-    paddr_t cbase, csize;
+    paddr_t csize;
     paddr_t vbase;
 
     /*
@@ -541,6 +541,7 @@ static int vgic_v2_domain_init(struct domain *d)
     if ( is_hardware_domain(d) )
     {
         d->arch.vgic.dbase = vgic_v2_hw.dbase;
+        d->arch.vgic.cbase = vgic_v2_hw.cbase;
         /*
          * For the hardware domain, we always map the whole HW CPU
          * interface region in order to match the device tree (the "reg"
@@ -548,13 +549,13 @@ static int vgic_v2_domain_init(struct domain *d)
          * Note that we assume the size of the CPU interface is always
          * aligned to PAGE_SIZE.
          */
-        cbase = vgic_v2_hw.cbase;
         csize = vgic_v2_hw.csize;
         vbase = vgic_v2_hw.vbase;
     }
     else
     {
         d->arch.vgic.dbase = GUEST_GICD_BASE;
+        d->arch.vgic.cbase = GUEST_GICC_BASE;
         /*
          * The CPU interface exposed to the guest is always 8kB. We may
          * need to add an offset to the virtual CPU interface base
@@ -562,7 +563,6 @@ static int vgic_v2_domain_init(struct domain *d)
          * region.
          */
         BUILD_BUG_ON(GUEST_GICC_SIZE != SZ_8K);
-        cbase = GUEST_GICC_BASE;
         csize = GUEST_GICC_SIZE;
         vbase = vgic_v2_hw.vbase + vgic_v2_hw.aliased_offset;
     }
@@ -571,8 +571,8 @@ static int vgic_v2_domain_init(struct domain *d)
      * Map the gic virtual cpu interface in the gic cpu interface
      * region of the guest.
      */
-    ret = map_mmio_regions(d, paddr_to_pfn(cbase), csize / PAGE_SIZE,
-                           paddr_to_pfn(vbase));
+    ret = map_mmio_regions(d, paddr_to_pfn(d->arch.vgic.cbase),
+                           csize / PAGE_SIZE, paddr_to_pfn(vbase));
     if ( ret )
         return ret;
 
diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h
index e7e40da..1e61f30 100644
--- a/xen/include/asm-arm/domain.h
+++ b/xen/include/asm-arm/domain.h
@@ -102,6 +102,7 @@ struct arch_domain
         struct pending_irq *pending_irqs;
         /* Base address for guest GIC */
         paddr_t dbase; /* Distributor base address */
+        paddr_t cbase; /* CPU base address */
 #ifdef HAS_GICV3
         /* GIC V3 addressing */
         /* List of contiguous occupied by the redistributors */
-- 
2.1.0

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

* [PATCH v3 01/62] Revert "xen/arm: vgic-v2: Drop cbase from arch_domain"
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40 ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                   ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

This reverts commit 810a50db69703f715d199d6b3a5f08193155d48b.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

Conflicts:
	xen/arch/arm/vgic-v2.c
---
 xen/arch/arm/vgic-v2.c       | 10 +++++-----
 xen/include/asm-arm/domain.h |  1 +
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/xen/arch/arm/vgic-v2.c b/xen/arch/arm/vgic-v2.c
index f7d784b..ba7ddac 100644
--- a/xen/arch/arm/vgic-v2.c
+++ b/xen/arch/arm/vgic-v2.c
@@ -531,7 +531,7 @@ static int vgic_v2_vcpu_init(struct vcpu *v)
 static int vgic_v2_domain_init(struct domain *d)
 {
     int i, ret;
-    paddr_t cbase, csize;
+    paddr_t csize;
     paddr_t vbase;
 
     /*
@@ -541,6 +541,7 @@ static int vgic_v2_domain_init(struct domain *d)
     if ( is_hardware_domain(d) )
     {
         d->arch.vgic.dbase = vgic_v2_hw.dbase;
+        d->arch.vgic.cbase = vgic_v2_hw.cbase;
         /*
          * For the hardware domain, we always map the whole HW CPU
          * interface region in order to match the device tree (the "reg"
@@ -548,13 +549,13 @@ static int vgic_v2_domain_init(struct domain *d)
          * Note that we assume the size of the CPU interface is always
          * aligned to PAGE_SIZE.
          */
-        cbase = vgic_v2_hw.cbase;
         csize = vgic_v2_hw.csize;
         vbase = vgic_v2_hw.vbase;
     }
     else
     {
         d->arch.vgic.dbase = GUEST_GICD_BASE;
+        d->arch.vgic.cbase = GUEST_GICC_BASE;
         /*
          * The CPU interface exposed to the guest is always 8kB. We may
          * need to add an offset to the virtual CPU interface base
@@ -562,7 +563,6 @@ static int vgic_v2_domain_init(struct domain *d)
          * region.
          */
         BUILD_BUG_ON(GUEST_GICC_SIZE != SZ_8K);
-        cbase = GUEST_GICC_BASE;
         csize = GUEST_GICC_SIZE;
         vbase = vgic_v2_hw.vbase + vgic_v2_hw.aliased_offset;
     }
@@ -571,8 +571,8 @@ static int vgic_v2_domain_init(struct domain *d)
      * Map the gic virtual cpu interface in the gic cpu interface
      * region of the guest.
      */
-    ret = map_mmio_regions(d, paddr_to_pfn(cbase), csize / PAGE_SIZE,
-                           paddr_to_pfn(vbase));
+    ret = map_mmio_regions(d, paddr_to_pfn(d->arch.vgic.cbase),
+                           csize / PAGE_SIZE, paddr_to_pfn(vbase));
     if ( ret )
         return ret;
 
diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h
index e7e40da..1e61f30 100644
--- a/xen/include/asm-arm/domain.h
+++ b/xen/include/asm-arm/domain.h
@@ -102,6 +102,7 @@ struct arch_domain
         struct pending_irq *pending_irqs;
         /* Base address for guest GIC */
         paddr_t dbase; /* Distributor base address */
+        paddr_t cbase; /* CPU base address */
 #ifdef HAS_GICV3
         /* GIC V3 addressing */
         /* List of contiguous occupied by the redistributors */
-- 
2.1.0

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

* [PATCH v3 02/62] acpi/NUMA: Build NUMA for x86 only
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
  2015-11-17  9:40 ` [PATCH v3 01/62] Revert "xen/arm: vgic-v2: Drop cbase from arch_domain" shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
@ 2015-11-17  9:40 ` shannon.zhao at linaro.org
  2015-11-17  9:40 ` shannon.zhao
                   ` (64 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

NUMA is currently not supported for ARM in Xen. Add a new compilation
option HAS_NUMA for NUMA. Configure and build NUMA only for x86
architecture now.

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>
---
 xen/arch/x86/Rules.mk     | 1 +
 xen/drivers/acpi/Makefile | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/Rules.mk b/xen/arch/x86/Rules.mk
index 42de328..5b8eaed 100644
--- a/xen/arch/x86/Rules.mk
+++ b/xen/arch/x86/Rules.mk
@@ -3,6 +3,7 @@
 
 HAS_IOPORTS := y
 HAS_ACPI := y
+HAS_NUMA := y
 HAS_VGA  := y
 HAS_VIDEO  := y
 HAS_CPUFREQ := y
diff --git a/xen/drivers/acpi/Makefile b/xen/drivers/acpi/Makefile
index bbb06a7..3bb626e 100644
--- a/xen/drivers/acpi/Makefile
+++ b/xen/drivers/acpi/Makefile
@@ -3,7 +3,7 @@ subdir-y += utilities
 subdir-$(x86) += apei
 
 obj-bin-y += tables.init.o
-obj-y += numa.o
+obj-$(HAS_NUMA) += numa.o
 obj-y += osl.o
 obj-y += pmstat.o
 
-- 
2.1.0

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

* [PATCH v3 02/62] acpi/NUMA: Build NUMA for x86 only
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
                   ` (2 preceding siblings ...)
  2015-11-17  9:40 ` [PATCH v3 02/62] acpi/NUMA: Build NUMA for x86 only shannon.zhao at linaro.org
@ 2015-11-17  9:40 ` shannon.zhao
  2015-11-17  9:40 ` [PATCH v3 03/62] acpi/pmstat: Build pmstat " shannon.zhao
                   ` (63 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

NUMA is currently not supported for ARM in Xen. Add a new compilation
option HAS_NUMA for NUMA. Configure and build NUMA only for x86
architecture now.

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>
---
 xen/arch/x86/Rules.mk     | 1 +
 xen/drivers/acpi/Makefile | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/Rules.mk b/xen/arch/x86/Rules.mk
index 42de328..5b8eaed 100644
--- a/xen/arch/x86/Rules.mk
+++ b/xen/arch/x86/Rules.mk
@@ -3,6 +3,7 @@
 
 HAS_IOPORTS := y
 HAS_ACPI := y
+HAS_NUMA := y
 HAS_VGA  := y
 HAS_VIDEO  := y
 HAS_CPUFREQ := y
diff --git a/xen/drivers/acpi/Makefile b/xen/drivers/acpi/Makefile
index bbb06a7..3bb626e 100644
--- a/xen/drivers/acpi/Makefile
+++ b/xen/drivers/acpi/Makefile
@@ -3,7 +3,7 @@ subdir-y += utilities
 subdir-$(x86) += apei
 
 obj-bin-y += tables.init.o
-obj-y += numa.o
+obj-$(HAS_NUMA) += numa.o
 obj-y += osl.o
 obj-y += pmstat.o
 
-- 
2.1.0

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

* [PATCH v3 03/62] acpi/pmstat: Build pmstat for x86 only
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
                   ` (4 preceding siblings ...)
  2015-11-17  9:40 ` [PATCH v3 03/62] acpi/pmstat: Build pmstat " shannon.zhao
@ 2015-11-17  9:40 ` shannon.zhao at linaro.org
  2015-11-23 15:46   ` Jan Beulich
  2015-11-23 15:46   ` Jan Beulich
  2015-11-17  9:40   ` shannon.zhao
                   ` (61 subsequent siblings)
  67 siblings, 2 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

Pmstat is currently not supported for ARM in Xen. Configure and build
pmstat for x86 architecture only.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/common/sysctl.c       | 2 +-
 xen/drivers/acpi/Makefile | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c
index 85e853f..8273ad4 100644
--- a/xen/common/sysctl.c
+++ b/xen/common/sysctl.c
@@ -171,7 +171,7 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl)
         op->u.availheap.avail_bytes <<= PAGE_SHIFT;
         break;
 
-#ifdef HAS_ACPI
+#ifdef HAS_CPUFREQ
     case XEN_SYSCTL_get_pmstat:
         ret = do_get_pm_info(&op->u.get_pmstat);
         break;
diff --git a/xen/drivers/acpi/Makefile b/xen/drivers/acpi/Makefile
index 3bb626e..c7d006a 100644
--- a/xen/drivers/acpi/Makefile
+++ b/xen/drivers/acpi/Makefile
@@ -5,7 +5,7 @@ subdir-$(x86) += apei
 obj-bin-y += tables.init.o
 obj-$(HAS_NUMA) += numa.o
 obj-y += osl.o
-obj-y += pmstat.o
+obj-$(HAS_CPUFREQ) += pmstat.o
 
 obj-$(x86) += hwregs.o
 obj-$(x86) += reboot.o
-- 
2.1.0

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

* [PATCH v3 03/62] acpi/pmstat: Build pmstat for x86 only
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
                   ` (3 preceding siblings ...)
  2015-11-17  9:40 ` shannon.zhao
@ 2015-11-17  9:40 ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                   ` (62 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

Pmstat is currently not supported for ARM in Xen. Configure and build
pmstat for x86 architecture only.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/common/sysctl.c       | 2 +-
 xen/drivers/acpi/Makefile | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c
index 85e853f..8273ad4 100644
--- a/xen/common/sysctl.c
+++ b/xen/common/sysctl.c
@@ -171,7 +171,7 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl)
         op->u.availheap.avail_bytes <<= PAGE_SHIFT;
         break;
 
-#ifdef HAS_ACPI
+#ifdef HAS_CPUFREQ
     case XEN_SYSCTL_get_pmstat:
         ret = do_get_pm_info(&op->u.get_pmstat);
         break;
diff --git a/xen/drivers/acpi/Makefile b/xen/drivers/acpi/Makefile
index 3bb626e..c7d006a 100644
--- a/xen/drivers/acpi/Makefile
+++ b/xen/drivers/acpi/Makefile
@@ -5,7 +5,7 @@ subdir-$(x86) += apei
 obj-bin-y += tables.init.o
 obj-$(HAS_NUMA) += numa.o
 obj-y += osl.o
-obj-y += pmstat.o
+obj-$(HAS_CPUFREQ) += pmstat.o
 
 obj-$(x86) += hwregs.o
 obj-$(x86) += reboot.o
-- 
2.1.0

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

* [PATCH v3 04/62] arm/acpi: Emulate io ports for arm
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

Add macros to emulate x86 style ports for arm. This avoids modification in
common code for acpi.

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

diff --git a/xen/include/asm-arm/arm64/io.h b/xen/include/asm-arm/arm64/io.h
index 37abc47..7ad9b65 100644
--- a/xen/include/asm-arm/arm64/io.h
+++ b/xen/include/asm-arm/arm64/io.h
@@ -20,6 +20,7 @@
 #ifndef _ARM_ARM64_IO_H
 #define _ARM_ARM64_IO_H
 
+#include <asm/system.h>
 #include <asm/byteorder.h>
 
 /*
@@ -109,4 +110,17 @@ static inline u64 __raw_readq(const volatile void __iomem *addr)
 #define writel(v,c)             ({ __iowmb(); writel_relaxed((v),(c)); })
 #define writeq(v,c)             ({ __iowmb(); writeq_relaxed((v),(c)); })
 
+/*
+ * Emulate x86 io ports for arm.
+ */
+#define __armio(addr) ( (void __iomem *)addr )
+
+#define inb(c) ( readb( __armio(c) ) )
+#define inw(c) ( readw( __armio(c) ) )
+#define inl(c) ( readl( __armio(c) ) )
+
+#define outb(v, c) ( writeb(v, __armio(c) ) )
+#define outw(v, c) ( writew(v, __armio(c) ) )
+#define outl(v, c) ( writel(v, __armio(c) ) )
+
 #endif /* _ARM_ARM64_IO_H */
-- 
2.1.0

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

* [PATCH v3 04/62] arm/acpi: Emulate io ports for arm
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

Add macros to emulate x86 style ports for arm. This avoids modification in
common code for acpi.

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

diff --git a/xen/include/asm-arm/arm64/io.h b/xen/include/asm-arm/arm64/io.h
index 37abc47..7ad9b65 100644
--- a/xen/include/asm-arm/arm64/io.h
+++ b/xen/include/asm-arm/arm64/io.h
@@ -20,6 +20,7 @@
 #ifndef _ARM_ARM64_IO_H
 #define _ARM_ARM64_IO_H
 
+#include <asm/system.h>
 #include <asm/byteorder.h>
 
 /*
@@ -109,4 +110,17 @@ static inline u64 __raw_readq(const volatile void __iomem *addr)
 #define writel(v,c)             ({ __iowmb(); writel_relaxed((v),(c)); })
 #define writeq(v,c)             ({ __iowmb(); writeq_relaxed((v),(c)); })
 
+/*
+ * Emulate x86 io ports for arm.
+ */
+#define __armio(addr) ( (void __iomem *)addr )
+
+#define inb(c) ( readb( __armio(c) ) )
+#define inw(c) ( readw( __armio(c) ) )
+#define inl(c) ( readl( __armio(c) ) )
+
+#define outb(v, c) ( writeb(v, __armio(c) ) )
+#define outw(v, c) ( writew(v, __armio(c) ) )
+#define outl(v, c) ( writel(v, __armio(c) ) )
+
 #endif /* _ARM_ARM64_IO_H */
-- 
2.1.0

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

* [PATCH v3 05/62] acpi: Don't do traditional BIOS table scan for ARM64
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

With the addition of ARM64 that does not have a traditional BIOS to
scan, add a #ifdef option for x86 to do the traditional BIOS scanning
for tables.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/drivers/acpi/osl.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/xen/drivers/acpi/osl.c b/xen/drivers/acpi/osl.c
index ce15470..db74a90 100644
--- a/xen/drivers/acpi/osl.c
+++ b/xen/drivers/acpi/osl.c
@@ -78,7 +78,9 @@ acpi_physical_address __init acpi_os_get_root_pointer(void)
 	} else {
 		acpi_physical_address pa = 0;
 
+		#ifdef CONFIG_X86
 		acpi_find_root_pointer(&pa);
+		#endif
 		return pa;
 	}
 }
-- 
2.1.0

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

* [PATCH v3 05/62] acpi: Don't do traditional BIOS table scan for ARM64
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

With the addition of ARM64 that does not have a traditional BIOS to
scan, add a #ifdef option for x86 to do the traditional BIOS scanning
for tables.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/drivers/acpi/osl.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/xen/drivers/acpi/osl.c b/xen/drivers/acpi/osl.c
index ce15470..db74a90 100644
--- a/xen/drivers/acpi/osl.c
+++ b/xen/drivers/acpi/osl.c
@@ -78,7 +78,9 @@ acpi_physical_address __init acpi_os_get_root_pointer(void)
 	} else {
 		acpi_physical_address pa = 0;
 
+		#ifdef CONFIG_X86
 		acpi_find_root_pointer(&pa);
+		#endif
 		return pa;
 	}
 }
-- 
2.1.0

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

* [PATCH v3 06/62] acpi: Refactor acpi_os_map_memory to be architecturally independent
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

Current acpi_os_map_memory is specific to x86. Refactor it to be
architecturally independent.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/x86/acpi/lib.c | 16 ++++++++++++++++
 xen/drivers/acpi/osl.c  | 12 +-----------
 xen/include/xen/acpi.h  |  2 ++
 3 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/xen/arch/x86/acpi/lib.c b/xen/arch/x86/acpi/lib.c
index cc15ea3..1e2e124 100644
--- a/xen/arch/x86/acpi/lib.c
+++ b/xen/arch/x86/acpi/lib.c
@@ -33,6 +33,22 @@ u8 __read_mostly acpi_disable_value;
 u32 __read_mostly x86_acpiid_to_apicid[MAX_MADT_ENTRIES] =
     {[0 ... MAX_MADT_ENTRIES - 1] = BAD_APICID };
 
+void __iomem *
+arch_acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
+{
+	if (system_state >= SYS_STATE_active) {
+		mfn_t mfn = _mfn(PFN_DOWN(phys));
+		unsigned int offs = phys & (PAGE_SIZE - 1);
+
+		/* The low first Mb is always mapped. */
+		if ( !((phys + size - 1) >> 20) )
+			return __va(phys);
+		return __vmap(&mfn, PFN_UP(offs + size), 1, 1,
+			      PAGE_HYPERVISOR_NOCACHE) + offs;
+	}
+	return __acpi_map_table(phys, size);
+}
+
 /*
  * Important Safety Note:  The fixed ACPI page numbers are *subtracted*
  * from the fixed base.  That's why we start at FIX_ACPI_END and
diff --git a/xen/drivers/acpi/osl.c b/xen/drivers/acpi/osl.c
index db74a90..54fb0f0 100644
--- a/xen/drivers/acpi/osl.c
+++ b/xen/drivers/acpi/osl.c
@@ -88,17 +88,7 @@ acpi_physical_address __init acpi_os_get_root_pointer(void)
 void __iomem *
 acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
 {
-	if (system_state >= SYS_STATE_active) {
-		mfn_t mfn = _mfn(PFN_DOWN(phys));
-		unsigned int offs = phys & (PAGE_SIZE - 1);
-
-		/* The low first Mb is always mapped. */
-		if ( !((phys + size - 1) >> 20) )
-			return __va(phys);
-		return __vmap(&mfn, PFN_UP(offs + size), 1, 1,
-			      PAGE_HYPERVISOR_NOCACHE) + offs;
-	}
-	return __acpi_map_table(phys, size);
+	return arch_acpi_os_map_memory(phys, size);
 }
 
 void acpi_os_unmap_memory(void __iomem * virt, acpi_size size)
diff --git a/xen/include/xen/acpi.h b/xen/include/xen/acpi.h
index 0f1077d..48d7810 100644
--- a/xen/include/xen/acpi.h
+++ b/xen/include/xen/acpi.h
@@ -54,6 +54,8 @@ typedef int (*acpi_table_handler) (struct acpi_table_header *table);
 
 typedef int (*acpi_table_entry_handler) (struct acpi_subtable_header *header, const unsigned long end);
 
+void __iomem *
+arch_acpi_os_map_memory(acpi_physical_address phys, acpi_size size);
 unsigned int acpi_get_processor_id (unsigned int cpu);
 char * __acpi_map_table (paddr_t phys_addr, unsigned long size);
 int acpi_boot_init (void);
-- 
2.1.0

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

* [PATCH v3 06/62] acpi: Refactor acpi_os_map_memory to be architecturally independent
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

Current acpi_os_map_memory is specific to x86. Refactor it to be
architecturally independent.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/x86/acpi/lib.c | 16 ++++++++++++++++
 xen/drivers/acpi/osl.c  | 12 +-----------
 xen/include/xen/acpi.h  |  2 ++
 3 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/xen/arch/x86/acpi/lib.c b/xen/arch/x86/acpi/lib.c
index cc15ea3..1e2e124 100644
--- a/xen/arch/x86/acpi/lib.c
+++ b/xen/arch/x86/acpi/lib.c
@@ -33,6 +33,22 @@ u8 __read_mostly acpi_disable_value;
 u32 __read_mostly x86_acpiid_to_apicid[MAX_MADT_ENTRIES] =
     {[0 ... MAX_MADT_ENTRIES - 1] = BAD_APICID };
 
+void __iomem *
+arch_acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
+{
+	if (system_state >= SYS_STATE_active) {
+		mfn_t mfn = _mfn(PFN_DOWN(phys));
+		unsigned int offs = phys & (PAGE_SIZE - 1);
+
+		/* The low first Mb is always mapped. */
+		if ( !((phys + size - 1) >> 20) )
+			return __va(phys);
+		return __vmap(&mfn, PFN_UP(offs + size), 1, 1,
+			      PAGE_HYPERVISOR_NOCACHE) + offs;
+	}
+	return __acpi_map_table(phys, size);
+}
+
 /*
  * Important Safety Note:  The fixed ACPI page numbers are *subtracted*
  * from the fixed base.  That's why we start at FIX_ACPI_END and
diff --git a/xen/drivers/acpi/osl.c b/xen/drivers/acpi/osl.c
index db74a90..54fb0f0 100644
--- a/xen/drivers/acpi/osl.c
+++ b/xen/drivers/acpi/osl.c
@@ -88,17 +88,7 @@ acpi_physical_address __init acpi_os_get_root_pointer(void)
 void __iomem *
 acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
 {
-	if (system_state >= SYS_STATE_active) {
-		mfn_t mfn = _mfn(PFN_DOWN(phys));
-		unsigned int offs = phys & (PAGE_SIZE - 1);
-
-		/* The low first Mb is always mapped. */
-		if ( !((phys + size - 1) >> 20) )
-			return __va(phys);
-		return __vmap(&mfn, PFN_UP(offs + size), 1, 1,
-			      PAGE_HYPERVISOR_NOCACHE) + offs;
-	}
-	return __acpi_map_table(phys, size);
+	return arch_acpi_os_map_memory(phys, size);
 }
 
 void acpi_os_unmap_memory(void __iomem * virt, acpi_size size)
diff --git a/xen/include/xen/acpi.h b/xen/include/xen/acpi.h
index 0f1077d..48d7810 100644
--- a/xen/include/xen/acpi.h
+++ b/xen/include/xen/acpi.h
@@ -54,6 +54,8 @@ typedef int (*acpi_table_handler) (struct acpi_table_header *table);
 
 typedef int (*acpi_table_entry_handler) (struct acpi_subtable_header *header, const unsigned long end);
 
+void __iomem *
+arch_acpi_os_map_memory(acpi_physical_address phys, acpi_size size);
 unsigned int acpi_get_processor_id (unsigned int cpu);
 char * __acpi_map_table (paddr_t phys_addr, unsigned long size);
 int acpi_boot_init (void);
-- 
2.1.0

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

* [PATCH v3 07/62] arm/acpi: Add arch_acpi_os_map_memory helper function for ARM
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/Makefile      |  1 +
 xen/arch/arm/acpi/Makefile |  1 +
 xen/arch/arm/acpi/lib.c    | 33 +++++++++++++++++++++++++++++++++
 3 files changed, 35 insertions(+)
 create mode 100644 xen/arch/arm/acpi/Makefile
 create mode 100644 xen/arch/arm/acpi/lib.c

diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile
index 1ef39f7..1851ae8 100644
--- a/xen/arch/arm/Makefile
+++ b/xen/arch/arm/Makefile
@@ -2,6 +2,7 @@ subdir-$(arm32) += arm32
 subdir-$(arm64) += arm64
 subdir-y += platforms
 subdir-$(arm64) += efi
+subdir-$(HAS_ACPI) += acpi
 
 obj-$(EARLY_PRINTK) += early_printk.o
 obj-y += cpu.o
diff --git a/xen/arch/arm/acpi/Makefile b/xen/arch/arm/acpi/Makefile
new file mode 100644
index 0000000..b5be22d
--- /dev/null
+++ b/xen/arch/arm/acpi/Makefile
@@ -0,0 +1 @@
+obj-y += lib.o
diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c
new file mode 100644
index 0000000..b68623b
--- /dev/null
+++ b/xen/arch/arm/acpi/lib.c
@@ -0,0 +1,33 @@
+/*
+ *  lib.c - Architecture-Specific Low-Level ACPI Support
+ *
+ *  Copyright (C) 2015, Shannon Zhao <shannon.zhao@linaro.org>
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#include <xen/acpi.h>
+#include <xen/mm.h>
+#include <asm/mm.h>
+
+void __iomem *
+arch_acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
+{
+    return __va(phys);
+}
-- 
2.1.0

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

* [PATCH v3 07/62] arm/acpi: Add arch_acpi_os_map_memory helper function for ARM
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/Makefile      |  1 +
 xen/arch/arm/acpi/Makefile |  1 +
 xen/arch/arm/acpi/lib.c    | 33 +++++++++++++++++++++++++++++++++
 3 files changed, 35 insertions(+)
 create mode 100644 xen/arch/arm/acpi/Makefile
 create mode 100644 xen/arch/arm/acpi/lib.c

diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile
index 1ef39f7..1851ae8 100644
--- a/xen/arch/arm/Makefile
+++ b/xen/arch/arm/Makefile
@@ -2,6 +2,7 @@ subdir-$(arm32) += arm32
 subdir-$(arm64) += arm64
 subdir-y += platforms
 subdir-$(arm64) += efi
+subdir-$(HAS_ACPI) += acpi
 
 obj-$(EARLY_PRINTK) += early_printk.o
 obj-y += cpu.o
diff --git a/xen/arch/arm/acpi/Makefile b/xen/arch/arm/acpi/Makefile
new file mode 100644
index 0000000..b5be22d
--- /dev/null
+++ b/xen/arch/arm/acpi/Makefile
@@ -0,0 +1 @@
+obj-y += lib.o
diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c
new file mode 100644
index 0000000..b68623b
--- /dev/null
+++ b/xen/arch/arm/acpi/lib.c
@@ -0,0 +1,33 @@
+/*
+ *  lib.c - Architecture-Specific Low-Level ACPI Support
+ *
+ *  Copyright (C) 2015, Shannon Zhao <shannon.zhao@linaro.org>
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#include <xen/acpi.h>
+#include <xen/mm.h>
+#include <asm/mm.h>
+
+void __iomem *
+arch_acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
+{
+    return __va(phys);
+}
-- 
2.1.0

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

* [PATCH v3 08/62] arm/acpi: Add arm specific acpi header file
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

Add architecture specific definitions and calls required for acpi in new
header file.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/setup.c       |  3 +++
 xen/include/asm-arm/acpi.h | 38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+)
 create mode 100644 xen/include/asm-arm/acpi.h

diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index e95759d..3b29904 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -45,11 +45,14 @@
 #include <asm/procinfo.h>
 #include <asm/setup.h>
 #include <xsm/xsm.h>
+#include <asm/acpi.h>
 
 struct bootinfo __initdata bootinfo;
 
 struct cpuinfo_arm __read_mostly boot_cpu_data;
 
+bool_t __read_mostly acpi_disabled;
+
 #ifdef CONFIG_ARM_32
 static unsigned long opt_xenheap_megabytes __initdata;
 integer_param("xenheap_megabytes", opt_xenheap_megabytes);
diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
new file mode 100644
index 0000000..e41e03b
--- /dev/null
+++ b/xen/include/asm-arm/acpi.h
@@ -0,0 +1,38 @@
+/*
+ *  Copyright (C) 2015, Shannon Zhao <shannon.zhao@linaro.org>
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#ifndef _ASM_ARM_ACPI_H
+#define _ASM_ARM_ACPI_H
+
+#include <xen/init.h>
+
+#define COMPILER_DEPENDENT_INT64   long long
+#define COMPILER_DEPENDENT_UINT64  unsigned long long
+
+extern bool_t acpi_disabled;
+/* Basic configuration for ACPI */
+static inline void disable_acpi(void)
+{
+    acpi_disabled = 1;
+}
+
+#endif /*_ASM_ARM_ACPI_H*/
-- 
2.1.0

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

* [PATCH v3 08/62] arm/acpi: Add arm specific acpi header file
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

Add architecture specific definitions and calls required for acpi in new
header file.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/setup.c       |  3 +++
 xen/include/asm-arm/acpi.h | 38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+)
 create mode 100644 xen/include/asm-arm/acpi.h

diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index e95759d..3b29904 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -45,11 +45,14 @@
 #include <asm/procinfo.h>
 #include <asm/setup.h>
 #include <xsm/xsm.h>
+#include <asm/acpi.h>
 
 struct bootinfo __initdata bootinfo;
 
 struct cpuinfo_arm __read_mostly boot_cpu_data;
 
+bool_t __read_mostly acpi_disabled;
+
 #ifdef CONFIG_ARM_32
 static unsigned long opt_xenheap_megabytes __initdata;
 integer_param("xenheap_megabytes", opt_xenheap_megabytes);
diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
new file mode 100644
index 0000000..e41e03b
--- /dev/null
+++ b/xen/include/asm-arm/acpi.h
@@ -0,0 +1,38 @@
+/*
+ *  Copyright (C) 2015, Shannon Zhao <shannon.zhao@linaro.org>
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#ifndef _ASM_ARM_ACPI_H
+#define _ASM_ARM_ACPI_H
+
+#include <xen/init.h>
+
+#define COMPILER_DEPENDENT_INT64   long long
+#define COMPILER_DEPENDENT_UINT64  unsigned long long
+
+extern bool_t acpi_disabled;
+/* Basic configuration for ACPI */
+static inline void disable_acpi(void)
+{
+    acpi_disabled = 1;
+}
+
+#endif /*_ASM_ARM_ACPI_H*/
-- 
2.1.0

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

* [PATCH v3 09/62] arm/acpi: Add basic ACPI initialization
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

acpi_boot_table_init() will be called in start_xen to get the RSDP and
all the table pointers. With this patch, we can get ACPI boot-time
tables from firmware on ARM64.

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>
---
 xen/arch/arm/acpi/Makefile |  1 +
 xen/arch/arm/acpi/boot.c   | 62 ++++++++++++++++++++++++++++++++++++++++++++++
 xen/arch/arm/setup.c       |  4 +++
 3 files changed, 67 insertions(+)
 create mode 100644 xen/arch/arm/acpi/boot.c

diff --git a/xen/arch/arm/acpi/Makefile b/xen/arch/arm/acpi/Makefile
index b5be22d..196c40a 100644
--- a/xen/arch/arm/acpi/Makefile
+++ b/xen/arch/arm/acpi/Makefile
@@ -1 +1,2 @@
 obj-y += lib.o
+obj-y += boot.o
diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c
new file mode 100644
index 0000000..ad51afc
--- /dev/null
+++ b/xen/arch/arm/acpi/boot.c
@@ -0,0 +1,62 @@
+/*
+ *  ARM Specific Low-Level ACPI Boot Support
+ *
+ *  Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
+ *  Copyright (C) 2001 Jun Nakajima <jun.nakajima@intel.com>
+ *  Copyright (C) 2014, Naresh Bhat <naresh.bhat@linaro.org>
+ *  Copyright (C) 2015, Shannon Zhao <shannon.zhao@linaro.org>
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#include <xen/init.h>
+#include <xen/acpi.h>
+
+#include <asm/acpi.h>
+
+/*
+ * acpi_boot_table_init() called from setup_arch(), always.
+ *      1. find RSDP and get its address, and then find XSDT
+ *      2. extract all tables and checksums them all
+ *
+ * return value: (currently ignored)
+ *	0: success
+ *	!0: failure
+ *
+ * We can parse ACPI boot-time tables such as FADT, MADT after
+ * this function is called.
+ */
+int __init acpi_boot_table_init(void)
+{
+    int error;
+
+    /* If acpi_disabled, bail out */
+    if ( acpi_disabled )
+        return 1;
+
+    /* Initialize the ACPI boot-time table parser. */
+    error = acpi_table_init();
+    if ( error )
+    {
+        disable_acpi();
+        return error;
+    }
+
+    return 0;
+}
diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index 3b29904..768312f 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -36,6 +36,7 @@
 #include <xen/pfn.h>
 #include <xen/vmap.h>
 #include <xen/libfdt/libfdt.h>
+#include <xen/acpi.h>
 #include <asm/page.h>
 #include <asm/current.h>
 #include <asm/setup.h>
@@ -753,6 +754,9 @@ void __init start_xen(unsigned long boot_phys_offset,
 
     setup_mm(fdt_paddr, fdt_size);
 
+    /* Parse the ACPI tables for possible boot-time configuration */
+    acpi_boot_table_init();
+
     vm_init();
     dt_unflatten_host_device_tree();
 
-- 
2.1.0

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

* [PATCH v3 09/62] arm/acpi: Add basic ACPI initialization
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

acpi_boot_table_init() will be called in start_xen to get the RSDP and
all the table pointers. With this patch, we can get ACPI boot-time
tables from firmware on ARM64.

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>
---
 xen/arch/arm/acpi/Makefile |  1 +
 xen/arch/arm/acpi/boot.c   | 62 ++++++++++++++++++++++++++++++++++++++++++++++
 xen/arch/arm/setup.c       |  4 +++
 3 files changed, 67 insertions(+)
 create mode 100644 xen/arch/arm/acpi/boot.c

diff --git a/xen/arch/arm/acpi/Makefile b/xen/arch/arm/acpi/Makefile
index b5be22d..196c40a 100644
--- a/xen/arch/arm/acpi/Makefile
+++ b/xen/arch/arm/acpi/Makefile
@@ -1 +1,2 @@
 obj-y += lib.o
+obj-y += boot.o
diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c
new file mode 100644
index 0000000..ad51afc
--- /dev/null
+++ b/xen/arch/arm/acpi/boot.c
@@ -0,0 +1,62 @@
+/*
+ *  ARM Specific Low-Level ACPI Boot Support
+ *
+ *  Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
+ *  Copyright (C) 2001 Jun Nakajima <jun.nakajima@intel.com>
+ *  Copyright (C) 2014, Naresh Bhat <naresh.bhat@linaro.org>
+ *  Copyright (C) 2015, Shannon Zhao <shannon.zhao@linaro.org>
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#include <xen/init.h>
+#include <xen/acpi.h>
+
+#include <asm/acpi.h>
+
+/*
+ * acpi_boot_table_init() called from setup_arch(), always.
+ *      1. find RSDP and get its address, and then find XSDT
+ *      2. extract all tables and checksums them all
+ *
+ * return value: (currently ignored)
+ *	0: success
+ *	!0: failure
+ *
+ * We can parse ACPI boot-time tables such as FADT, MADT after
+ * this function is called.
+ */
+int __init acpi_boot_table_init(void)
+{
+    int error;
+
+    /* If acpi_disabled, bail out */
+    if ( acpi_disabled )
+        return 1;
+
+    /* Initialize the ACPI boot-time table parser. */
+    error = acpi_table_init();
+    if ( error )
+    {
+        disable_acpi();
+        return error;
+    }
+
+    return 0;
+}
diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index 3b29904..768312f 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -36,6 +36,7 @@
 #include <xen/pfn.h>
 #include <xen/vmap.h>
 #include <xen/libfdt/libfdt.h>
+#include <xen/acpi.h>
 #include <asm/page.h>
 #include <asm/current.h>
 #include <asm/setup.h>
@@ -753,6 +754,9 @@ void __init start_xen(unsigned long boot_phys_offset,
 
     setup_mm(fdt_paddr, fdt_size);
 
+    /* Parse the ACPI tables for possible boot-time configuration */
+    acpi_boot_table_init();
+
     vm_init();
     dt_unflatten_host_device_tree();
 
-- 
2.1.0

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

* [PATCH v3 10/62] arm/acpi: Move end_boot_allocator after acpi_boot_table_init
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

If ACPI is initialized after the boot allocator has ended(the system
state is not early boot), assert happens in acpi_os_zalloc_memory and
acpi_boot_table_init will fail. So it needs to move end_boot_allocator
after acpi_boot_table_init.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/setup.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index 768312f..c15a09d 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -613,8 +613,6 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size)
        allocator. */
     init_xenheap_pages(pfn_to_paddr(xenheap_mfn_start),
                        pfn_to_paddr(boot_mfn_start));
-
-    end_boot_allocator();
 }
 #else /* CONFIG_ARM_64 */
 static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size)
@@ -682,8 +680,6 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size)
 
     setup_frametable_mappings(ram_start, ram_end);
     max_page = PFN_DOWN(ram_end);
-
-    end_boot_allocator();
 }
 #endif
 
@@ -757,6 +753,8 @@ void __init start_xen(unsigned long boot_phys_offset,
     /* Parse the ACPI tables for possible boot-time configuration */
     acpi_boot_table_init();
 
+    end_boot_allocator();
+
     vm_init();
     dt_unflatten_host_device_tree();
 
-- 
2.1.0

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

* [PATCH v3 10/62] arm/acpi: Move end_boot_allocator after acpi_boot_table_init
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

If ACPI is initialized after the boot allocator has ended(the system
state is not early boot), assert happens in acpi_os_zalloc_memory and
acpi_boot_table_init will fail. So it needs to move end_boot_allocator
after acpi_boot_table_init.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/setup.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index 768312f..c15a09d 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -613,8 +613,6 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size)
        allocator. */
     init_xenheap_pages(pfn_to_paddr(xenheap_mfn_start),
                        pfn_to_paddr(boot_mfn_start));
-
-    end_boot_allocator();
 }
 #else /* CONFIG_ARM_64 */
 static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size)
@@ -682,8 +680,6 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size)
 
     setup_frametable_mappings(ram_start, ram_end);
     max_page = PFN_DOWN(ram_end);
-
-    end_boot_allocator();
 }
 #endif
 
@@ -757,6 +753,8 @@ void __init start_xen(unsigned long boot_phys_offset,
     /* Parse the ACPI tables for possible boot-time configuration */
     acpi_boot_table_init();
 
+    end_boot_allocator();
+
     vm_init();
     dt_unflatten_host_device_tree();
 
-- 
2.1.0

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

* [PATCH v3 11/62] arm/acpi: Introduce ARM Boot Architecture Flags in FADT
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

The Power State Coordination Interface (PSCI) defines an API that
can be used to coordinate power control amongst the various supervisory
systems concurrently running on a device. ACPI support for this
technology would require the addition of two flags: PSCI_COMPLIANT and
PSCI_USE_HVC. When set, the former signals to the OS that the hardware
is PSCI compliant. The latter selects the appropriate conduit for PSCI
calls by toggling between Hypervisor Calls (HVC) and Secure Monitor
Calls (SMC).

An ARM Boot Architecture Flags structure to support new ARM hardware
was introduced in FADT in ACPI 5.1, add the code accordingly to
implement that in ACPICA core.

Since ACPI 5.1 doesn't support self defined PSCI function IDs,
which means that only PSCI 0.2+ is supported in ACPI.

Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Naresh Bhat <naresh.bhat@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/include/acpi/actbl.h | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/xen/include/acpi/actbl.h b/xen/include/acpi/actbl.h
index 856945d..66e29c3 100644
--- a/xen/include/acpi/actbl.h
+++ b/xen/include/acpi/actbl.h
@@ -244,7 +244,8 @@ struct acpi_table_fadt {
 	u32 flags;		/* Miscellaneous flag bits (see below for individual flags) */
 	struct acpi_generic_address reset_register;	/* 64-bit address of the Reset register */
 	u8 reset_value;		/* Value to write to the reset_register port to reset the system */
-	u8 reserved4[3];	/* Reserved, must be zero */
+	u16 arm_boot_flags;     /* ARM-Specific Boot Flags (see below for individual flags) (ACPI 5.1) */
+	u8 minor_revision;      /* FADT Minor Revision (ACPI 5.1) */
 	u64 Xfacs;		/* 64-bit physical address of FACS */
 	u64 Xdsdt;		/* 64-bit physical address of DSDT */
 	struct acpi_generic_address xpm1a_event_block;	/* 64-bit Extended Power Mgt 1a Event Reg Blk address */
@@ -259,7 +260,7 @@ struct acpi_table_fadt {
 	struct acpi_generic_address sleep_status;	/* 64-bit Sleep Status register */
 };
 
-/* Masks for FADT Boot Architecture Flags (boot_flags) */
+/* Masks for FADT IA-PC Boot Architecture Flags (boot_flags) */
 
 #define ACPI_FADT_LEGACY_DEVICES    (1)  	/* 00: [V2] System has LPC or ISA bus devices */
 #define ACPI_FADT_8042              (1<<1)	/* 01: [V3] System has an 8042 controller on port 60/64 */
@@ -270,6 +271,11 @@ struct acpi_table_fadt {
 
 #define FADT2_REVISION_ID               3
 
+/* Masks for FADT ARM Boot Architecture Flags (arm_boot_flags) ACPI 5.1 */
+
+#define ACPI_FADT_PSCI_COMPLIANT    (1)        /* 00:  [V5+] PSCI 0.2+ is implemented */
+#define ACPI_FADT_PSCI_USE_HVC      (1<<1)     /* 01:  [V5+] HVC must be used instead of SMC as the PSCI conduit */
+
 /* Masks for FADT flags */
 
 #define ACPI_FADT_WBINVD            (1)	/* 00: [V1] The wbinvd instruction works properly */
@@ -345,7 +351,7 @@ enum acpi_prefered_pm_profiles {
  *     FADT V5  size: 0x10C
  */
 #define ACPI_FADT_V1_SIZE       (u32) (ACPI_FADT_OFFSET (flags) + 4)
-#define ACPI_FADT_V2_SIZE       (u32) (ACPI_FADT_OFFSET (reserved4[0]) + 3)
+#define ACPI_FADT_V2_SIZE       (u32) (ACPI_FADT_OFFSET (minor_revision) + 1)
 #define ACPI_FADT_V3_SIZE       (u32) (ACPI_FADT_OFFSET (sleep_control))
 #define ACPI_FADT_V5_SIZE       (u32) (sizeof (struct acpi_table_fadt))
 
-- 
2.1.0

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

* [PATCH v3 11/62] arm/acpi: Introduce ARM Boot Architecture Flags in FADT
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

The Power State Coordination Interface (PSCI) defines an API that
can be used to coordinate power control amongst the various supervisory
systems concurrently running on a device. ACPI support for this
technology would require the addition of two flags: PSCI_COMPLIANT and
PSCI_USE_HVC. When set, the former signals to the OS that the hardware
is PSCI compliant. The latter selects the appropriate conduit for PSCI
calls by toggling between Hypervisor Calls (HVC) and Secure Monitor
Calls (SMC).

An ARM Boot Architecture Flags structure to support new ARM hardware
was introduced in FADT in ACPI 5.1, add the code accordingly to
implement that in ACPICA core.

Since ACPI 5.1 doesn't support self defined PSCI function IDs,
which means that only PSCI 0.2+ is supported in ACPI.

Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Naresh Bhat <naresh.bhat@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/include/acpi/actbl.h | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/xen/include/acpi/actbl.h b/xen/include/acpi/actbl.h
index 856945d..66e29c3 100644
--- a/xen/include/acpi/actbl.h
+++ b/xen/include/acpi/actbl.h
@@ -244,7 +244,8 @@ struct acpi_table_fadt {
 	u32 flags;		/* Miscellaneous flag bits (see below for individual flags) */
 	struct acpi_generic_address reset_register;	/* 64-bit address of the Reset register */
 	u8 reset_value;		/* Value to write to the reset_register port to reset the system */
-	u8 reserved4[3];	/* Reserved, must be zero */
+	u16 arm_boot_flags;     /* ARM-Specific Boot Flags (see below for individual flags) (ACPI 5.1) */
+	u8 minor_revision;      /* FADT Minor Revision (ACPI 5.1) */
 	u64 Xfacs;		/* 64-bit physical address of FACS */
 	u64 Xdsdt;		/* 64-bit physical address of DSDT */
 	struct acpi_generic_address xpm1a_event_block;	/* 64-bit Extended Power Mgt 1a Event Reg Blk address */
@@ -259,7 +260,7 @@ struct acpi_table_fadt {
 	struct acpi_generic_address sleep_status;	/* 64-bit Sleep Status register */
 };
 
-/* Masks for FADT Boot Architecture Flags (boot_flags) */
+/* Masks for FADT IA-PC Boot Architecture Flags (boot_flags) */
 
 #define ACPI_FADT_LEGACY_DEVICES    (1)  	/* 00: [V2] System has LPC or ISA bus devices */
 #define ACPI_FADT_8042              (1<<1)	/* 01: [V3] System has an 8042 controller on port 60/64 */
@@ -270,6 +271,11 @@ struct acpi_table_fadt {
 
 #define FADT2_REVISION_ID               3
 
+/* Masks for FADT ARM Boot Architecture Flags (arm_boot_flags) ACPI 5.1 */
+
+#define ACPI_FADT_PSCI_COMPLIANT    (1)        /* 00:  [V5+] PSCI 0.2+ is implemented */
+#define ACPI_FADT_PSCI_USE_HVC      (1<<1)     /* 01:  [V5+] HVC must be used instead of SMC as the PSCI conduit */
+
 /* Masks for FADT flags */
 
 #define ACPI_FADT_WBINVD            (1)	/* 00: [V1] The wbinvd instruction works properly */
@@ -345,7 +351,7 @@ enum acpi_prefered_pm_profiles {
  *     FADT V5  size: 0x10C
  */
 #define ACPI_FADT_V1_SIZE       (u32) (ACPI_FADT_OFFSET (flags) + 4)
-#define ACPI_FADT_V2_SIZE       (u32) (ACPI_FADT_OFFSET (reserved4[0]) + 3)
+#define ACPI_FADT_V2_SIZE       (u32) (ACPI_FADT_OFFSET (minor_revision) + 1)
 #define ACPI_FADT_V3_SIZE       (u32) (ACPI_FADT_OFFSET (sleep_control))
 #define ACPI_FADT_V5_SIZE       (u32) (sizeof (struct acpi_table_fadt))
 
-- 
2.1.0

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

* [PATCH v3 12/62] ACPICA: ACPI 6.0: Add changes for FADT table
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

From: Bob Moore <robert.moore@intel.com>

ACPICA commit 72b0b6741990f619f6aaa915302836b7cbb41ac4

One new 64-bit field at the end of the table.
FADT version is now 6.

Link: https://github.com/acpica/acpica/commit/72b0b674
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
[Linux commit aeb823bbacc2a3aaee29eda5875b58a049fa1f78]
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/include/acpi/actbl.h | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/xen/include/acpi/actbl.h b/xen/include/acpi/actbl.h
index 66e29c3..3079176 100644
--- a/xen/include/acpi/actbl.h
+++ b/xen/include/acpi/actbl.h
@@ -258,6 +258,7 @@ struct acpi_table_fadt {
 	struct acpi_generic_address xgpe1_block;	/* 64-bit Extended General Purpose Event 1 Reg Blk address */
 	struct acpi_generic_address sleep_control;	/* 64-bit Sleep Control register */
 	struct acpi_generic_address sleep_status;	/* 64-bit Sleep Status register */
+	u64 hypervisor_id;      /* Hypervisor Vendor ID (ACPI 6.0) */
 };
 
 /* Masks for FADT IA-PC Boot Architecture Flags (boot_flags) */
@@ -315,7 +316,7 @@ enum acpi_prefered_pm_profiles {
 	PM_TABLET = 8
 };
 
-/* Values for sleep_status and sleep_control registers (V5 FADT) */
+/* Values for sleep_status and sleep_control registers (V5+ FADT) */
 
 #define ACPI_X_WAKE_STATUS          0x80
 #define ACPI_X_SLEEP_TYPE_MASK      0x1C
@@ -344,15 +345,17 @@ enum acpi_prefered_pm_profiles {
  * FADT is the bottom line as to what the version really is.
  *
  * For reference, the values below are as follows:
- *     FADT V1  size: 0x074
- *     FADT V2  size: 0x084
- *     FADT V3  size: 0x0F4
- *     FADT V4  size: 0x0F4
- *     FADT V5  size: 0x10C
+ *     FADT V1 size: 0x074
+ *     FADT V2 size: 0x084
+ *     FADT V3 size: 0x0F4
+ *     FADT V4 size: 0x0F4
+ *     FADT V5 size: 0x10C
+ *     FADT V6 size: 0x114
  */
 #define ACPI_FADT_V1_SIZE       (u32) (ACPI_FADT_OFFSET (flags) + 4)
 #define ACPI_FADT_V2_SIZE       (u32) (ACPI_FADT_OFFSET (minor_revision) + 1)
 #define ACPI_FADT_V3_SIZE       (u32) (ACPI_FADT_OFFSET (sleep_control))
-#define ACPI_FADT_V5_SIZE       (u32) (sizeof (struct acpi_table_fadt))
+#define ACPI_FADT_V5_SIZE       (u32) (ACPI_FADT_OFFSET (hypervisor_id))
+#define ACPI_FADT_V6_SIZE       (u32) (sizeof (struct acpi_table_fadt))
 
 #endif				/* __ACTBL_H__ */
-- 
2.1.0

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

* [PATCH v3 12/62] ACPICA: ACPI 6.0: Add changes for FADT table
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

From: Bob Moore <robert.moore@intel.com>

ACPICA commit 72b0b6741990f619f6aaa915302836b7cbb41ac4

One new 64-bit field at the end of the table.
FADT version is now 6.

Link: https://github.com/acpica/acpica/commit/72b0b674
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
[Linux commit aeb823bbacc2a3aaee29eda5875b58a049fa1f78]
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/include/acpi/actbl.h | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/xen/include/acpi/actbl.h b/xen/include/acpi/actbl.h
index 66e29c3..3079176 100644
--- a/xen/include/acpi/actbl.h
+++ b/xen/include/acpi/actbl.h
@@ -258,6 +258,7 @@ struct acpi_table_fadt {
 	struct acpi_generic_address xgpe1_block;	/* 64-bit Extended General Purpose Event 1 Reg Blk address */
 	struct acpi_generic_address sleep_control;	/* 64-bit Sleep Control register */
 	struct acpi_generic_address sleep_status;	/* 64-bit Sleep Status register */
+	u64 hypervisor_id;      /* Hypervisor Vendor ID (ACPI 6.0) */
 };
 
 /* Masks for FADT IA-PC Boot Architecture Flags (boot_flags) */
@@ -315,7 +316,7 @@ enum acpi_prefered_pm_profiles {
 	PM_TABLET = 8
 };
 
-/* Values for sleep_status and sleep_control registers (V5 FADT) */
+/* Values for sleep_status and sleep_control registers (V5+ FADT) */
 
 #define ACPI_X_WAKE_STATUS          0x80
 #define ACPI_X_SLEEP_TYPE_MASK      0x1C
@@ -344,15 +345,17 @@ enum acpi_prefered_pm_profiles {
  * FADT is the bottom line as to what the version really is.
  *
  * For reference, the values below are as follows:
- *     FADT V1  size: 0x074
- *     FADT V2  size: 0x084
- *     FADT V3  size: 0x0F4
- *     FADT V4  size: 0x0F4
- *     FADT V5  size: 0x10C
+ *     FADT V1 size: 0x074
+ *     FADT V2 size: 0x084
+ *     FADT V3 size: 0x0F4
+ *     FADT V4 size: 0x0F4
+ *     FADT V5 size: 0x10C
+ *     FADT V6 size: 0x114
  */
 #define ACPI_FADT_V1_SIZE       (u32) (ACPI_FADT_OFFSET (flags) + 4)
 #define ACPI_FADT_V2_SIZE       (u32) (ACPI_FADT_OFFSET (minor_revision) + 1)
 #define ACPI_FADT_V3_SIZE       (u32) (ACPI_FADT_OFFSET (sleep_control))
-#define ACPI_FADT_V5_SIZE       (u32) (sizeof (struct acpi_table_fadt))
+#define ACPI_FADT_V5_SIZE       (u32) (ACPI_FADT_OFFSET (hypervisor_id))
+#define ACPI_FADT_V6_SIZE       (u32) (sizeof (struct acpi_table_fadt))
 
 #endif				/* __ACTBL_H__ */
-- 
2.1.0

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

* [PATCH v3 13/62] arm/acpi: Parse FADT table and get PSCI flags
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

There are two flags: PSCI_COMPLIANT and PSCI_USE_HVC. When set,
the former signals to the OS that the hardware is PSCI compliant.
The latter selects the appropriate conduit for PSCI calls by
toggling between Hypervisor Calls (HVC) and Secure Monitor Calls
(SMC).

FADT table contains such information, parse FADT to get the flags
for furture usage. At the same time, only ACPI 5.1 or higher verison
supports PSCI, and FADT Major.Minor version was introduced in ACPI
5.1, but for Xen it needs FADT hypervisor_id introduced by ACPI 6.0 to
tell Dom0 that it runs on Xen hypervisor, so we will check the version
and only parse FADT table with version >= 6.0.

If firmware provides ACPI tables with ACPI version less than 6.0,
OS will be messed up with those information, so disable ACPI if we
get an FADT table with version less that 6.0.

Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
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>
---
 xen/arch/arm/acpi/boot.c   | 31 +++++++++++++++++++++++++++++++
 xen/arch/arm/acpi/lib.c    | 12 ++++++++++++
 xen/include/asm-arm/acpi.h |  9 +++++++++
 3 files changed, 52 insertions(+)

diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c
index ad51afc..0fabe7d 100644
--- a/xen/arch/arm/acpi/boot.c
+++ b/xen/arch/arm/acpi/boot.c
@@ -27,9 +27,33 @@
 
 #include <xen/init.h>
 #include <xen/acpi.h>
+#include <xen/errno.h>
+#include <acpi/actables.h>
+#include <xen/mm.h>
 
 #include <asm/acpi.h>
 
+static int __init acpi_parse_fadt(struct acpi_table_header *table)
+{
+    struct acpi_table_fadt *fadt = (struct acpi_table_fadt *)table;
+
+    /*
+     * Revision in table header is the FADT Major revision, and there
+     * is a minor revision of FADT which was introduced by ACPI 6.0,
+     * we only deal with ACPI 6.0 or newer revision to get GIC and SMP
+     * boot protocol configuration data, or we will disable ACPI.
+     */
+    if ( table->revision > 6
+         || (table->revision == 6 && fadt->minor_revision >= 0) )
+        return 0;
+
+    printk("Unsupported FADT revision %d.%d, should be 6.0+, will disable ACPI\n",
+            table->revision, fadt->minor_revision);
+    disable_acpi();
+
+    return -EINVAL;
+}
+
 /*
  * acpi_boot_table_init() called from setup_arch(), always.
  *      1. find RSDP and get its address, and then find XSDT
@@ -58,5 +82,12 @@ int __init acpi_boot_table_init(void)
         return error;
     }
 
+    if ( acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt) )
+    {
+        /* disable ACPI if no FADT is found */
+        disable_acpi();
+        printk("Can't find FADT\n");
+    }
+
     return 0;
 }
diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c
index b68623b..d8b7635 100644
--- a/xen/arch/arm/acpi/lib.c
+++ b/xen/arch/arm/acpi/lib.c
@@ -31,3 +31,15 @@ arch_acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
 {
     return __va(phys);
 }
+
+/* 1 to indicate PSCI 0.2+ is implemented */
+bool_t __init acpi_psci_present(void)
+{
+    return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_COMPLIANT;
+}
+
+/* 1 to indicate HVC is present instead of SMC as the PSCI conduit */
+bool_t __init acpi_psci_hvc_present(void)
+{
+    return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_USE_HVC;
+}
diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
index e41e03b..65f80b1 100644
--- a/xen/include/asm-arm/acpi.h
+++ b/xen/include/asm-arm/acpi.h
@@ -29,6 +29,15 @@
 #define COMPILER_DEPENDENT_UINT64  unsigned long long
 
 extern bool_t acpi_disabled;
+
+#ifdef CONFIG_ACPI
+bool_t __init acpi_psci_present(void);
+bool_t __init acpi_psci_hvc_present(void);
+#else
+static inline bool_t acpi_psci_present(void) { return false; }
+static inline bool_t acpi_psci_hvc_present(void) {return false; }
+#endif /* CONFIG_ACPI */
+
 /* Basic configuration for ACPI */
 static inline void disable_acpi(void)
 {
-- 
2.1.0

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

* [PATCH v3 13/62] arm/acpi: Parse FADT table and get PSCI flags
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

There are two flags: PSCI_COMPLIANT and PSCI_USE_HVC. When set,
the former signals to the OS that the hardware is PSCI compliant.
The latter selects the appropriate conduit for PSCI calls by
toggling between Hypervisor Calls (HVC) and Secure Monitor Calls
(SMC).

FADT table contains such information, parse FADT to get the flags
for furture usage. At the same time, only ACPI 5.1 or higher verison
supports PSCI, and FADT Major.Minor version was introduced in ACPI
5.1, but for Xen it needs FADT hypervisor_id introduced by ACPI 6.0 to
tell Dom0 that it runs on Xen hypervisor, so we will check the version
and only parse FADT table with version >= 6.0.

If firmware provides ACPI tables with ACPI version less than 6.0,
OS will be messed up with those information, so disable ACPI if we
get an FADT table with version less that 6.0.

Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
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>
---
 xen/arch/arm/acpi/boot.c   | 31 +++++++++++++++++++++++++++++++
 xen/arch/arm/acpi/lib.c    | 12 ++++++++++++
 xen/include/asm-arm/acpi.h |  9 +++++++++
 3 files changed, 52 insertions(+)

diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c
index ad51afc..0fabe7d 100644
--- a/xen/arch/arm/acpi/boot.c
+++ b/xen/arch/arm/acpi/boot.c
@@ -27,9 +27,33 @@
 
 #include <xen/init.h>
 #include <xen/acpi.h>
+#include <xen/errno.h>
+#include <acpi/actables.h>
+#include <xen/mm.h>
 
 #include <asm/acpi.h>
 
+static int __init acpi_parse_fadt(struct acpi_table_header *table)
+{
+    struct acpi_table_fadt *fadt = (struct acpi_table_fadt *)table;
+
+    /*
+     * Revision in table header is the FADT Major revision, and there
+     * is a minor revision of FADT which was introduced by ACPI 6.0,
+     * we only deal with ACPI 6.0 or newer revision to get GIC and SMP
+     * boot protocol configuration data, or we will disable ACPI.
+     */
+    if ( table->revision > 6
+         || (table->revision == 6 && fadt->minor_revision >= 0) )
+        return 0;
+
+    printk("Unsupported FADT revision %d.%d, should be 6.0+, will disable ACPI\n",
+            table->revision, fadt->minor_revision);
+    disable_acpi();
+
+    return -EINVAL;
+}
+
 /*
  * acpi_boot_table_init() called from setup_arch(), always.
  *      1. find RSDP and get its address, and then find XSDT
@@ -58,5 +82,12 @@ int __init acpi_boot_table_init(void)
         return error;
     }
 
+    if ( acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt) )
+    {
+        /* disable ACPI if no FADT is found */
+        disable_acpi();
+        printk("Can't find FADT\n");
+    }
+
     return 0;
 }
diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c
index b68623b..d8b7635 100644
--- a/xen/arch/arm/acpi/lib.c
+++ b/xen/arch/arm/acpi/lib.c
@@ -31,3 +31,15 @@ arch_acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
 {
     return __va(phys);
 }
+
+/* 1 to indicate PSCI 0.2+ is implemented */
+bool_t __init acpi_psci_present(void)
+{
+    return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_COMPLIANT;
+}
+
+/* 1 to indicate HVC is present instead of SMC as the PSCI conduit */
+bool_t __init acpi_psci_hvc_present(void)
+{
+    return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_USE_HVC;
+}
diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
index e41e03b..65f80b1 100644
--- a/xen/include/asm-arm/acpi.h
+++ b/xen/include/asm-arm/acpi.h
@@ -29,6 +29,15 @@
 #define COMPILER_DEPENDENT_UINT64  unsigned long long
 
 extern bool_t acpi_disabled;
+
+#ifdef CONFIG_ACPI
+bool_t __init acpi_psci_present(void);
+bool_t __init acpi_psci_hvc_present(void);
+#else
+static inline bool_t acpi_psci_present(void) { return false; }
+static inline bool_t acpi_psci_hvc_present(void) {return false; }
+#endif /* CONFIG_ACPI */
+
 /* Basic configuration for ACPI */
 static inline void disable_acpi(void)
 {
-- 
2.1.0

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

* [PATCH v3 14/62] arm/acpi: Add Generic Interrupt and Distributor struct
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

Add Generic Interrupt and Distributor (ACPI 5.0) structure.
Add new features for MADT introduced by ACPI 5.1.
Comment on the GIC ID field of the GIC structure which is replaced
by CPU Interface Number.
Add new fields: Redistributor Base Address, GICV, GICH, and MPIDR.
Add new structures for GIC MSI frame and GICR.
Add flag definition for GICC flags.

Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Naresh Bhat <naresh.bhat@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/include/acpi/actbl1.h | 69 +++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 67 insertions(+), 2 deletions(-)

diff --git a/xen/include/acpi/actbl1.h b/xen/include/acpi/actbl1.h
index 9311e3a..2fb2ad7 100644
--- a/xen/include/acpi/actbl1.h
+++ b/xen/include/acpi/actbl1.h
@@ -639,7 +639,11 @@ enum acpi_madt_type {
 	ACPI_MADT_TYPE_INTERRUPT_SOURCE = 8,
 	ACPI_MADT_TYPE_LOCAL_X2APIC = 9,
 	ACPI_MADT_TYPE_LOCAL_X2APIC_NMI = 10,
-	ACPI_MADT_TYPE_RESERVED = 11	/* 11 and greater are reserved */
+	ACPI_MADT_TYPE_GENERIC_INTERRUPT = 11,
+	ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR = 12,
+	ACPI_MADT_TYPE_GENERIC_MSI_FRAME = 13,
+	ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR = 14,
+	ACPI_MADT_TYPE_RESERVED = 15    /* 15 and greater are reserved */
 };
 
 /*
@@ -760,11 +764,72 @@ struct acpi_madt_local_x2apic_nmi {
 	u8 reserved[3];
 };
 
+/* 11: Generic Interrupt (ACPI 5.0) */
+
+struct acpi_madt_generic_interrupt {
+	struct acpi_subtable_header header;
+	u16 reserved;           /* reserved - must be zero */
+	u32 cpu_interface_number;
+	u32 uid;
+	u32 flags;
+	u32 parking_version;
+	u32 performance_interrupt;
+	u64 parked_address;
+	u64 base_address;
+	u64 gicv_base_address;
+	u64 gich_base_address;
+	u32 vgic_interrupt;
+	u64 gicr_base_address;
+	u64 arm_mpidr;
+};
+
+/* Masks for Flags field above */
+
+/* ACPI_MADT_ENABLED                    (1)      Processor is usable if set */
+#define ACPI_MADT_PERFORMANCE_IRQ_MODE  (1<<1) /* 01: Performance Interrupt Mode */
+#define ACPI_MADT_VGIC_IRQ_MODE         (1<<2) /* 02: VGIC Maintenance Interrupt mode */
+
+/* 12: Generic Distributor (ACPI 5.0) */
+
+struct acpi_madt_generic_distributor {
+	struct acpi_subtable_header header;
+	u16 reserved;           /* reserved - must be zero */
+	u32 gic_id;
+	u64 base_address;
+	u32 global_irq_base;
+	u32 reserved2;          /* reserved - must be zero */
+};
+
+/* 13: GIC MSI Frame (ACPI 5.1) */
+
+struct acpi_madt_generic_msi_frame {
+	struct acpi_subtable_header header;
+	u16 reserved;		/* reserved - must be zero */
+	u32 msi_frame_id;
+	u64 base_address;
+	u32 flags;
+	u16 spi_count;
+	u16 spi_base;
+};
+
+/* Masks for Flags field above */
+
+#define ACPI_MADT_OVERRIDE_SPI_VALUES   (1)
+
+/* 14: GIC Redistributor (ACPI 5.1) */
+
+struct acpi_madt_generic_redistributor {
+	struct acpi_subtable_header header;
+	u16 reserved;		/* reserved - must be zero */
+	u64 base_address;
+	u32 length;
+};
+
 /*
  * Common flags fields for MADT subtables
  */
 
-/* MADT Local APIC flags (lapic_flags) */
+/* MADT Local APIC flags */
 
 #define ACPI_MADT_ENABLED           (1)	/* 00: Processor is usable if set */
 
-- 
2.1.0

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

* [PATCH v3 14/62] arm/acpi: Add Generic Interrupt and Distributor struct
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

Add Generic Interrupt and Distributor (ACPI 5.0) structure.
Add new features for MADT introduced by ACPI 5.1.
Comment on the GIC ID field of the GIC structure which is replaced
by CPU Interface Number.
Add new fields: Redistributor Base Address, GICV, GICH, and MPIDR.
Add new structures for GIC MSI frame and GICR.
Add flag definition for GICC flags.

Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Naresh Bhat <naresh.bhat@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/include/acpi/actbl1.h | 69 +++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 67 insertions(+), 2 deletions(-)

diff --git a/xen/include/acpi/actbl1.h b/xen/include/acpi/actbl1.h
index 9311e3a..2fb2ad7 100644
--- a/xen/include/acpi/actbl1.h
+++ b/xen/include/acpi/actbl1.h
@@ -639,7 +639,11 @@ enum acpi_madt_type {
 	ACPI_MADT_TYPE_INTERRUPT_SOURCE = 8,
 	ACPI_MADT_TYPE_LOCAL_X2APIC = 9,
 	ACPI_MADT_TYPE_LOCAL_X2APIC_NMI = 10,
-	ACPI_MADT_TYPE_RESERVED = 11	/* 11 and greater are reserved */
+	ACPI_MADT_TYPE_GENERIC_INTERRUPT = 11,
+	ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR = 12,
+	ACPI_MADT_TYPE_GENERIC_MSI_FRAME = 13,
+	ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR = 14,
+	ACPI_MADT_TYPE_RESERVED = 15    /* 15 and greater are reserved */
 };
 
 /*
@@ -760,11 +764,72 @@ struct acpi_madt_local_x2apic_nmi {
 	u8 reserved[3];
 };
 
+/* 11: Generic Interrupt (ACPI 5.0) */
+
+struct acpi_madt_generic_interrupt {
+	struct acpi_subtable_header header;
+	u16 reserved;           /* reserved - must be zero */
+	u32 cpu_interface_number;
+	u32 uid;
+	u32 flags;
+	u32 parking_version;
+	u32 performance_interrupt;
+	u64 parked_address;
+	u64 base_address;
+	u64 gicv_base_address;
+	u64 gich_base_address;
+	u32 vgic_interrupt;
+	u64 gicr_base_address;
+	u64 arm_mpidr;
+};
+
+/* Masks for Flags field above */
+
+/* ACPI_MADT_ENABLED                    (1)      Processor is usable if set */
+#define ACPI_MADT_PERFORMANCE_IRQ_MODE  (1<<1) /* 01: Performance Interrupt Mode */
+#define ACPI_MADT_VGIC_IRQ_MODE         (1<<2) /* 02: VGIC Maintenance Interrupt mode */
+
+/* 12: Generic Distributor (ACPI 5.0) */
+
+struct acpi_madt_generic_distributor {
+	struct acpi_subtable_header header;
+	u16 reserved;           /* reserved - must be zero */
+	u32 gic_id;
+	u64 base_address;
+	u32 global_irq_base;
+	u32 reserved2;          /* reserved - must be zero */
+};
+
+/* 13: GIC MSI Frame (ACPI 5.1) */
+
+struct acpi_madt_generic_msi_frame {
+	struct acpi_subtable_header header;
+	u16 reserved;		/* reserved - must be zero */
+	u32 msi_frame_id;
+	u64 base_address;
+	u32 flags;
+	u16 spi_count;
+	u16 spi_base;
+};
+
+/* Masks for Flags field above */
+
+#define ACPI_MADT_OVERRIDE_SPI_VALUES   (1)
+
+/* 14: GIC Redistributor (ACPI 5.1) */
+
+struct acpi_madt_generic_redistributor {
+	struct acpi_subtable_header header;
+	u16 reserved;		/* reserved - must be zero */
+	u64 base_address;
+	u32 length;
+};
+
 /*
  * Common flags fields for MADT subtables
  */
 
-/* MADT Local APIC flags (lapic_flags) */
+/* MADT Local APIC flags */
 
 #define ACPI_MADT_ENABLED           (1)	/* 00: Processor is usable if set */
 
-- 
2.1.0

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

* [PATCH v3 15/62] ACPICA: ACPI 6.0: Add changes for MADT table.
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

From: Bob Moore <robert.moore@intel.com>

ACPICA commit 02cbb41232bccf7a91967140cab95d5f48291f21

New subtable type. Some additions to existing subtables.

Link: https://github.com/acpica/acpica/commit/02cbb412
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
[Linux commit 0cff8dc0099f6d4f7431181918b37a472bcd1bbb]
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/include/acpi/actbl1.h | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/xen/include/acpi/actbl1.h b/xen/include/acpi/actbl1.h
index 2fb2ad7..7dd6960 100644
--- a/xen/include/acpi/actbl1.h
+++ b/xen/include/acpi/actbl1.h
@@ -643,7 +643,8 @@ enum acpi_madt_type {
 	ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR = 12,
 	ACPI_MADT_TYPE_GENERIC_MSI_FRAME = 13,
 	ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR = 14,
-	ACPI_MADT_TYPE_RESERVED = 15    /* 15 and greater are reserved */
+	ACPI_MADT_TYPE_GENERIC_TRANSLATOR = 15,
+	ACPI_MADT_TYPE_RESERVED = 16    /* 16 and greater are reserved */
 };
 
 /*
@@ -764,7 +765,7 @@ struct acpi_madt_local_x2apic_nmi {
 	u8 reserved[3];
 };
 
-/* 11: Generic Interrupt (ACPI 5.0) */
+/* 11: Generic Interrupt (ACPI 5.0 + ACPI 6.0 changes) */
 
 struct acpi_madt_generic_interrupt {
 	struct acpi_subtable_header header;
@@ -781,6 +782,8 @@ struct acpi_madt_generic_interrupt {
 	u32 vgic_interrupt;
 	u64 gicr_base_address;
 	u64 arm_mpidr;
+	u8 efficiency_class;
+	u8 reserved2[3];
 };
 
 /* Masks for Flags field above */
@@ -789,7 +792,7 @@ struct acpi_madt_generic_interrupt {
 #define ACPI_MADT_PERFORMANCE_IRQ_MODE  (1<<1) /* 01: Performance Interrupt Mode */
 #define ACPI_MADT_VGIC_IRQ_MODE         (1<<2) /* 02: VGIC Maintenance Interrupt mode */
 
-/* 12: Generic Distributor (ACPI 5.0) */
+/* 12: Generic Distributor (ACPI 5.0 + ACPI 6.0 changes) */
 
 struct acpi_madt_generic_distributor {
 	struct acpi_subtable_header header;
@@ -797,7 +800,8 @@ struct acpi_madt_generic_distributor {
 	u32 gic_id;
 	u64 base_address;
 	u32 global_irq_base;
-	u32 reserved2;          /* reserved - must be zero */
+	u8 version;
+	u8 reserved2[3];          /* reserved - must be zero */
 };
 
 /* 13: GIC MSI Frame (ACPI 5.1) */
@@ -825,6 +829,16 @@ struct acpi_madt_generic_redistributor {
 	u32 length;
 };
 
+/* 15: Generic Translator (ACPI 6.0) */
+
+struct acpi_madt_generic_translator {
+	struct acpi_subtable_header header;
+	u16 reserved;           /* reserved - must be zero */
+	u32 translation_id;
+	u64 base_address;
+	u32 reserved2;
+};
+
 /*
  * Common flags fields for MADT subtables
  */
-- 
2.1.0

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

* [PATCH v3 15/62] ACPICA: ACPI 6.0: Add changes for MADT table.
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

From: Bob Moore <robert.moore@intel.com>

ACPICA commit 02cbb41232bccf7a91967140cab95d5f48291f21

New subtable type. Some additions to existing subtables.

Link: https://github.com/acpica/acpica/commit/02cbb412
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
[Linux commit 0cff8dc0099f6d4f7431181918b37a472bcd1bbb]
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/include/acpi/actbl1.h | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/xen/include/acpi/actbl1.h b/xen/include/acpi/actbl1.h
index 2fb2ad7..7dd6960 100644
--- a/xen/include/acpi/actbl1.h
+++ b/xen/include/acpi/actbl1.h
@@ -643,7 +643,8 @@ enum acpi_madt_type {
 	ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR = 12,
 	ACPI_MADT_TYPE_GENERIC_MSI_FRAME = 13,
 	ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR = 14,
-	ACPI_MADT_TYPE_RESERVED = 15    /* 15 and greater are reserved */
+	ACPI_MADT_TYPE_GENERIC_TRANSLATOR = 15,
+	ACPI_MADT_TYPE_RESERVED = 16    /* 16 and greater are reserved */
 };
 
 /*
@@ -764,7 +765,7 @@ struct acpi_madt_local_x2apic_nmi {
 	u8 reserved[3];
 };
 
-/* 11: Generic Interrupt (ACPI 5.0) */
+/* 11: Generic Interrupt (ACPI 5.0 + ACPI 6.0 changes) */
 
 struct acpi_madt_generic_interrupt {
 	struct acpi_subtable_header header;
@@ -781,6 +782,8 @@ struct acpi_madt_generic_interrupt {
 	u32 vgic_interrupt;
 	u64 gicr_base_address;
 	u64 arm_mpidr;
+	u8 efficiency_class;
+	u8 reserved2[3];
 };
 
 /* Masks for Flags field above */
@@ -789,7 +792,7 @@ struct acpi_madt_generic_interrupt {
 #define ACPI_MADT_PERFORMANCE_IRQ_MODE  (1<<1) /* 01: Performance Interrupt Mode */
 #define ACPI_MADT_VGIC_IRQ_MODE         (1<<2) /* 02: VGIC Maintenance Interrupt mode */
 
-/* 12: Generic Distributor (ACPI 5.0) */
+/* 12: Generic Distributor (ACPI 5.0 + ACPI 6.0 changes) */
 
 struct acpi_madt_generic_distributor {
 	struct acpi_subtable_header header;
@@ -797,7 +800,8 @@ struct acpi_madt_generic_distributor {
 	u32 gic_id;
 	u64 base_address;
 	u32 global_irq_base;
-	u32 reserved2;          /* reserved - must be zero */
+	u8 version;
+	u8 reserved2[3];          /* reserved - must be zero */
 };
 
 /* 13: GIC MSI Frame (ACPI 5.1) */
@@ -825,6 +829,16 @@ struct acpi_madt_generic_redistributor {
 	u32 length;
 };
 
+/* 15: Generic Translator (ACPI 6.0) */
+
+struct acpi_madt_generic_translator {
+	struct acpi_subtable_header header;
+	u16 reserved;           /* reserved - must be zero */
+	u32 translation_id;
+	u64 base_address;
+	u32 reserved2;
+};
+
 /*
  * Common flags fields for MADT subtables
  */
-- 
2.1.0

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

* [PATCH v3 16/62] ACPICA: ACPI 6.0: Add values for MADT GIC version field
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

From: Hanjun Guo <hanjun.guo@linaro.org>

ACPICA commit 4b100dc43e8baee8c8b4891b23bc7ad03eba6a28

Support for the new version field in the generic distributor
subtable. Hanjun Guo <hanjun.guo@linaro.org>

Link: https://github.com/acpica/acpica/commit/4b100dc4
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
[Linux commit a8bd0f07eb594df51845d33f272fb1952fec1a6f]
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/include/acpi/actbl1.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/xen/include/acpi/actbl1.h b/xen/include/acpi/actbl1.h
index 7dd6960..cf31837 100644
--- a/xen/include/acpi/actbl1.h
+++ b/xen/include/acpi/actbl1.h
@@ -804,6 +804,17 @@ struct acpi_madt_generic_distributor {
 	u8 reserved2[3];          /* reserved - must be zero */
 };
 
+/* Values for Version field above */
+
+enum acpi_madt_gic_version {
+	ACPI_MADT_GIC_VERSION_NONE = 0,
+	ACPI_MADT_GIC_VERSION_V1 = 1,
+	ACPI_MADT_GIC_VERSION_V2 = 2,
+	ACPI_MADT_GIC_VERSION_V3 = 3,
+	ACPI_MADT_GIC_VERSION_V4 = 4,
+	ACPI_MADT_GIC_VERSION_RESERVED = 5      /* 5 and greater are reserved */
+};
+
 /* 13: GIC MSI Frame (ACPI 5.1) */
 
 struct acpi_madt_generic_msi_frame {
-- 
2.1.0

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

* [PATCH v3 16/62] ACPICA: ACPI 6.0: Add values for MADT GIC version field
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

From: Hanjun Guo <hanjun.guo@linaro.org>

ACPICA commit 4b100dc43e8baee8c8b4891b23bc7ad03eba6a28

Support for the new version field in the generic distributor
subtable. Hanjun Guo <hanjun.guo@linaro.org>

Link: https://github.com/acpica/acpica/commit/4b100dc4
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
[Linux commit a8bd0f07eb594df51845d33f272fb1952fec1a6f]
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/include/acpi/actbl1.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/xen/include/acpi/actbl1.h b/xen/include/acpi/actbl1.h
index 7dd6960..cf31837 100644
--- a/xen/include/acpi/actbl1.h
+++ b/xen/include/acpi/actbl1.h
@@ -804,6 +804,17 @@ struct acpi_madt_generic_distributor {
 	u8 reserved2[3];          /* reserved - must be zero */
 };
 
+/* Values for Version field above */
+
+enum acpi_madt_gic_version {
+	ACPI_MADT_GIC_VERSION_NONE = 0,
+	ACPI_MADT_GIC_VERSION_V1 = 1,
+	ACPI_MADT_GIC_VERSION_V2 = 2,
+	ACPI_MADT_GIC_VERSION_V3 = 3,
+	ACPI_MADT_GIC_VERSION_V4 = 4,
+	ACPI_MADT_GIC_VERSION_RESERVED = 5      /* 5 and greater are reserved */
+};
+
 /* 13: GIC MSI Frame (ACPI 5.1) */
 
 struct acpi_madt_generic_msi_frame {
-- 
2.1.0

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

* [PATCH v3 17/62] arm/acpi: Print GIC information when MADT is parsed
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

When MADT is parsed, print GIC information to make the boot
log look pretty.

Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
Signed-off-by: Naresh Bhat <naresh.bhat@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/drivers/acpi/tables.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/xen/drivers/acpi/tables.c b/xen/drivers/acpi/tables.c
index 60c4ab1..6573175 100644
--- a/xen/drivers/acpi/tables.c
+++ b/xen/drivers/acpi/tables.c
@@ -189,6 +189,30 @@ void __init acpi_table_print_madt_entry(struct acpi_subtable_header *header)
 		}
 		break;
 
+	case ACPI_MADT_TYPE_GENERIC_INTERRUPT:
+		{
+			struct acpi_madt_generic_interrupt *p =
+				(struct acpi_madt_generic_interrupt *)header;
+			printk(KERN_INFO PREFIX
+			       "GICC (acpi_id[0x%04x] address[%llx] MPIDR[0x%llx] %s)\n",
+			       p->uid, (long long unsigned int)p->base_address,
+			       (long long unsigned int)p->arm_mpidr,
+			       (p->flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
+
+		}
+		break;
+
+	case ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR:
+		{
+			struct acpi_madt_generic_distributor *p =
+				(struct acpi_madt_generic_distributor *)header;
+			printk(KERN_INFO PREFIX
+			       "GIC Distributor (gic_id[0x%04x] address[%llx] gsi_base[%d])\n",
+			       p->gic_id, (long long unsigned int)p->base_address,
+			       p->global_irq_base);
+		}
+		break;
+
 	default:
 		printk(KERN_WARNING PREFIX
 		       "Found unsupported MADT entry (type = %#x)\n",
-- 
2.1.0

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

* [PATCH v3 17/62] arm/acpi: Print GIC information when MADT is parsed
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

When MADT is parsed, print GIC information to make the boot
log look pretty.

Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
Signed-off-by: Naresh Bhat <naresh.bhat@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/drivers/acpi/tables.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/xen/drivers/acpi/tables.c b/xen/drivers/acpi/tables.c
index 60c4ab1..6573175 100644
--- a/xen/drivers/acpi/tables.c
+++ b/xen/drivers/acpi/tables.c
@@ -189,6 +189,30 @@ void __init acpi_table_print_madt_entry(struct acpi_subtable_header *header)
 		}
 		break;
 
+	case ACPI_MADT_TYPE_GENERIC_INTERRUPT:
+		{
+			struct acpi_madt_generic_interrupt *p =
+				(struct acpi_madt_generic_interrupt *)header;
+			printk(KERN_INFO PREFIX
+			       "GICC (acpi_id[0x%04x] address[%llx] MPIDR[0x%llx] %s)\n",
+			       p->uid, (long long unsigned int)p->base_address,
+			       (long long unsigned int)p->arm_mpidr,
+			       (p->flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");
+
+		}
+		break;
+
+	case ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR:
+		{
+			struct acpi_madt_generic_distributor *p =
+				(struct acpi_madt_generic_distributor *)header;
+			printk(KERN_INFO PREFIX
+			       "GIC Distributor (gic_id[0x%04x] address[%llx] gsi_base[%d])\n",
+			       p->gic_id, (long long unsigned int)p->base_address,
+			       p->global_irq_base);
+		}
+		break;
+
 	default:
 		printk(KERN_WARNING PREFIX
 		       "Found unsupported MADT entry (type = %#x)\n",
-- 
2.1.0

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

* [PATCH v3 18/62] arm/acpi: Parse MADT to map logical cpu to MPIDR and get cpu_possible_map
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

MADT contains the information for MPIDR which is essential for SMP
initialization, parse the GIC cpu interface structures to get the MPIDR
value and map it to cpu_logical_map(), and add enabled cpu with valid
MPIDR into cpu_possible_map.

Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
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>
---
 xen/arch/arm/acpi/boot.c   | 121 +++++++++++++++++++++++++++++++++++++++++++++
 xen/include/asm-arm/acpi.h |   2 +
 xen/include/xen/acpi.h     |   4 ++
 3 files changed, 127 insertions(+)

diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c
index 0fabe7d..913d2a5 100644
--- a/xen/arch/arm/acpi/boot.c
+++ b/xen/arch/arm/acpi/boot.c
@@ -32,6 +32,127 @@
 #include <xen/mm.h>
 
 #include <asm/acpi.h>
+#include <asm/smp.h>
+
+/* Processors with enabled flag and sane MPIDR */
+static int enabled_cpus;
+
+/* Boot CPU is valid or not in MADT */
+static bool_t __initdata bootcpu_valid;
+
+/* total number of cpus in this system */
+static unsigned int __initdata total_cpus = 0;
+
+/*
+ * acpi_map_gic_cpu_interface - generates a logical cpu number
+ * and map to MPIDR represented by GICC structure
+ */
+static void __init
+acpi_map_gic_cpu_interface(struct acpi_madt_generic_interrupt *processor)
+{
+    int i;
+    u64 mpidr = processor->arm_mpidr & MPIDR_HWID_MASK;
+    bool enabled = !!(processor->flags & ACPI_MADT_ENABLED);
+
+    if (mpidr == MPIDR_INVALID) {
+        printk("Skip MADT cpu entry with invalid MPIDR\n");
+        return;
+    }
+
+    total_cpus++;
+    if (!enabled)
+        return;
+
+    if (enabled_cpus >=  NR_CPUS) {
+        printk("NR_CPUS limit of %d reached, Processor %d/0x%"PRIx64" ignored.\n",
+               NR_CPUS, total_cpus, mpidr);
+        return;
+    }
+
+    /* Check if GICC structure of boot CPU is available in the MADT */
+    if (cpu_logical_map(0) == mpidr) {
+        if (bootcpu_valid) {
+            printk("Firmware bug, duplicate CPU MPIDR: 0x%"PRIx64" in MADT\n",
+                   mpidr);
+            return;
+        }
+
+        bootcpu_valid = true;
+    }
+
+    /*
+     * Duplicate MPIDRs are a recipe for disaster. Scan
+     * all initialized entries and check for
+     * duplicates. If any is found just ignore the CPU.
+     */
+    for (i = 1; i < enabled_cpus; i++) {
+        if (cpu_logical_map(i) == mpidr) {
+            printk("Firmware bug, duplicate CPU MPIDR: 0x%"PRIx64" in MADT\n",
+                   mpidr);
+            return;
+        }
+    }
+
+    if (!acpi_psci_present())
+        return;
+
+    /* CPU 0 was already initialized */
+    if (enabled_cpus) {
+        if (arch_cpu_init(enabled_cpus, NULL) < 0)
+            return;
+
+        /* map the logical cpu id to cpu MPIDR */
+        cpu_logical_map(enabled_cpus) = mpidr;
+    }
+
+    enabled_cpus++;
+}
+
+static int __init
+acpi_parse_gic_cpu_interface(struct acpi_subtable_header *header,
+                             const unsigned long end)
+{
+    struct acpi_madt_generic_interrupt *processor;
+
+    processor = (struct acpi_madt_generic_interrupt *)header;
+
+    if (BAD_MADT_ENTRY(processor, end))
+        return -EINVAL;
+
+    acpi_table_print_madt_entry(header);
+    acpi_map_gic_cpu_interface(processor);
+    return 0;
+}
+
+/* Parse GIC cpu interface entries in MADT for SMP init */
+void __init acpi_smp_init_cpus(void)
+{
+    int count, i;
+
+    /*
+     * do a partial walk of MADT to determine how many CPUs
+     * we have including disabled CPUs, and get information
+     * we need for SMP init
+     */
+    count = acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_INTERRUPT,
+                    acpi_parse_gic_cpu_interface, 0);
+
+    if (count <= 0) {
+        printk("Error parsing GIC CPU interface entry\n");
+        return;
+    }
+
+    if (!bootcpu_valid) {
+        printk("MADT missing boot CPU MPIDR, not enabling secondaries\n");
+        return;
+    }
+
+    for (i = 0; i < enabled_cpus; i++)
+        cpumask_set_cpu(i, &cpu_possible_map);
+
+    /* Make boot-up look pretty */
+    printk("%d CPUs enabled, %d CPUs total\n", enabled_cpus, total_cpus);
+}
 
 static int __init acpi_parse_fadt(struct acpi_table_header *table)
 {
diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
index 65f80b1..1efa29d 100644
--- a/xen/include/asm-arm/acpi.h
+++ b/xen/include/asm-arm/acpi.h
@@ -33,9 +33,11 @@ extern bool_t acpi_disabled;
 #ifdef CONFIG_ACPI
 bool_t __init acpi_psci_present(void);
 bool_t __init acpi_psci_hvc_present(void);
+void __init acpi_smp_init_cpus(void);
 #else
 static inline bool_t acpi_psci_present(void) { return false; }
 static inline bool_t acpi_psci_hvc_present(void) {return false; }
+static inline void acpi_smp_init_cpus(void) { }
 #endif /* CONFIG_ACPI */
 
 /* Basic configuration for ACPI */
diff --git a/xen/include/xen/acpi.h b/xen/include/xen/acpi.h
index 48d7810..723ece8 100644
--- a/xen/include/xen/acpi.h
+++ b/xen/include/xen/acpi.h
@@ -39,6 +39,10 @@
 #define ACPI_MADT_GET_POLARITY(inti)	ACPI_MADT_GET_(POLARITY, inti)
 #define ACPI_MADT_GET_TRIGGER(inti)	ACPI_MADT_GET_(TRIGGER, inti)
 
+#define BAD_MADT_ENTRY(entry, end) (                                        \
+                (!entry) || (unsigned long)entry + sizeof(*entry) > end ||  \
+                ((struct acpi_subtable_header *)entry)->length < sizeof(*entry))
+
 #ifdef CONFIG_ACPI_BOOT
 
 enum acpi_interrupt_id {
-- 
2.1.0

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

* [PATCH v3 18/62] arm/acpi: Parse MADT to map logical cpu to MPIDR and get cpu_possible_map
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

MADT contains the information for MPIDR which is essential for SMP
initialization, parse the GIC cpu interface structures to get the MPIDR
value and map it to cpu_logical_map(), and add enabled cpu with valid
MPIDR into cpu_possible_map.

Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
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>
---
 xen/arch/arm/acpi/boot.c   | 121 +++++++++++++++++++++++++++++++++++++++++++++
 xen/include/asm-arm/acpi.h |   2 +
 xen/include/xen/acpi.h     |   4 ++
 3 files changed, 127 insertions(+)

diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c
index 0fabe7d..913d2a5 100644
--- a/xen/arch/arm/acpi/boot.c
+++ b/xen/arch/arm/acpi/boot.c
@@ -32,6 +32,127 @@
 #include <xen/mm.h>
 
 #include <asm/acpi.h>
+#include <asm/smp.h>
+
+/* Processors with enabled flag and sane MPIDR */
+static int enabled_cpus;
+
+/* Boot CPU is valid or not in MADT */
+static bool_t __initdata bootcpu_valid;
+
+/* total number of cpus in this system */
+static unsigned int __initdata total_cpus = 0;
+
+/*
+ * acpi_map_gic_cpu_interface - generates a logical cpu number
+ * and map to MPIDR represented by GICC structure
+ */
+static void __init
+acpi_map_gic_cpu_interface(struct acpi_madt_generic_interrupt *processor)
+{
+    int i;
+    u64 mpidr = processor->arm_mpidr & MPIDR_HWID_MASK;
+    bool enabled = !!(processor->flags & ACPI_MADT_ENABLED);
+
+    if (mpidr == MPIDR_INVALID) {
+        printk("Skip MADT cpu entry with invalid MPIDR\n");
+        return;
+    }
+
+    total_cpus++;
+    if (!enabled)
+        return;
+
+    if (enabled_cpus >=  NR_CPUS) {
+        printk("NR_CPUS limit of %d reached, Processor %d/0x%"PRIx64" ignored.\n",
+               NR_CPUS, total_cpus, mpidr);
+        return;
+    }
+
+    /* Check if GICC structure of boot CPU is available in the MADT */
+    if (cpu_logical_map(0) == mpidr) {
+        if (bootcpu_valid) {
+            printk("Firmware bug, duplicate CPU MPIDR: 0x%"PRIx64" in MADT\n",
+                   mpidr);
+            return;
+        }
+
+        bootcpu_valid = true;
+    }
+
+    /*
+     * Duplicate MPIDRs are a recipe for disaster. Scan
+     * all initialized entries and check for
+     * duplicates. If any is found just ignore the CPU.
+     */
+    for (i = 1; i < enabled_cpus; i++) {
+        if (cpu_logical_map(i) == mpidr) {
+            printk("Firmware bug, duplicate CPU MPIDR: 0x%"PRIx64" in MADT\n",
+                   mpidr);
+            return;
+        }
+    }
+
+    if (!acpi_psci_present())
+        return;
+
+    /* CPU 0 was already initialized */
+    if (enabled_cpus) {
+        if (arch_cpu_init(enabled_cpus, NULL) < 0)
+            return;
+
+        /* map the logical cpu id to cpu MPIDR */
+        cpu_logical_map(enabled_cpus) = mpidr;
+    }
+
+    enabled_cpus++;
+}
+
+static int __init
+acpi_parse_gic_cpu_interface(struct acpi_subtable_header *header,
+                             const unsigned long end)
+{
+    struct acpi_madt_generic_interrupt *processor;
+
+    processor = (struct acpi_madt_generic_interrupt *)header;
+
+    if (BAD_MADT_ENTRY(processor, end))
+        return -EINVAL;
+
+    acpi_table_print_madt_entry(header);
+    acpi_map_gic_cpu_interface(processor);
+    return 0;
+}
+
+/* Parse GIC cpu interface entries in MADT for SMP init */
+void __init acpi_smp_init_cpus(void)
+{
+    int count, i;
+
+    /*
+     * do a partial walk of MADT to determine how many CPUs
+     * we have including disabled CPUs, and get information
+     * we need for SMP init
+     */
+    count = acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_INTERRUPT,
+                    acpi_parse_gic_cpu_interface, 0);
+
+    if (count <= 0) {
+        printk("Error parsing GIC CPU interface entry\n");
+        return;
+    }
+
+    if (!bootcpu_valid) {
+        printk("MADT missing boot CPU MPIDR, not enabling secondaries\n");
+        return;
+    }
+
+    for (i = 0; i < enabled_cpus; i++)
+        cpumask_set_cpu(i, &cpu_possible_map);
+
+    /* Make boot-up look pretty */
+    printk("%d CPUs enabled, %d CPUs total\n", enabled_cpus, total_cpus);
+}
 
 static int __init acpi_parse_fadt(struct acpi_table_header *table)
 {
diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
index 65f80b1..1efa29d 100644
--- a/xen/include/asm-arm/acpi.h
+++ b/xen/include/asm-arm/acpi.h
@@ -33,9 +33,11 @@ extern bool_t acpi_disabled;
 #ifdef CONFIG_ACPI
 bool_t __init acpi_psci_present(void);
 bool_t __init acpi_psci_hvc_present(void);
+void __init acpi_smp_init_cpus(void);
 #else
 static inline bool_t acpi_psci_present(void) { return false; }
 static inline bool_t acpi_psci_hvc_present(void) {return false; }
+static inline void acpi_smp_init_cpus(void) { }
 #endif /* CONFIG_ACPI */
 
 /* Basic configuration for ACPI */
diff --git a/xen/include/xen/acpi.h b/xen/include/xen/acpi.h
index 48d7810..723ece8 100644
--- a/xen/include/xen/acpi.h
+++ b/xen/include/xen/acpi.h
@@ -39,6 +39,10 @@
 #define ACPI_MADT_GET_POLARITY(inti)	ACPI_MADT_GET_(POLARITY, inti)
 #define ACPI_MADT_GET_TRIGGER(inti)	ACPI_MADT_GET_(TRIGGER, inti)
 
+#define BAD_MADT_ENTRY(entry, end) (                                        \
+                (!entry) || (unsigned long)entry + sizeof(*entry) > end ||  \
+                ((struct acpi_subtable_header *)entry)->length < sizeof(*entry))
+
 #ifdef CONFIG_ACPI_BOOT
 
 enum acpi_interrupt_id {
-- 
2.1.0

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

* [PATCH v3 19/62] arm/smpboot: Move dt specific code in smp to seperate functions
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

Partition smp initialization functions into generic and dt specific
parts, this will be useful when introducing new functions for smp
initialization based on acpi.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/arm64/smpboot.c |  7 ++++++-
 xen/arch/arm/smpboot.c       | 29 ++++++++++++++++++-----------
 2 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/xen/arch/arm/arm64/smpboot.c b/xen/arch/arm/arm64/smpboot.c
index 62e6abb..7928f69 100644
--- a/xen/arch/arm/arm64/smpboot.c
+++ b/xen/arch/arm/arm64/smpboot.c
@@ -70,7 +70,7 @@ int __init arch_smp_init(void)
     return 0;
 }
 
-int __init arch_cpu_init(int cpu, struct dt_device_node *dn)
+static int __init dt_arch_cpu_init(int cpu, struct dt_device_node *dn)
 {
     const char *enable_method;
 
@@ -94,6 +94,11 @@ int __init arch_cpu_init(int cpu, struct dt_device_node *dn)
     return 0;
 }
 
+int __init arch_cpu_init(int cpu, struct dt_device_node *dn)
+{
+    return dt_arch_cpu_init(cpu, dn);
+}
+
 int __init arch_cpu_up(int cpu)
 {
     if ( !smp_enable_ops[cpu].prepare_cpu )
diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c
index a96cda2..d115228 100644
--- a/xen/arch/arm/smpboot.c
+++ b/xen/arch/arm/smpboot.c
@@ -92,7 +92,7 @@ smp_clear_cpu_maps (void)
  * MPIDR values related to logical cpus
  * Code base on Linux arch/arm/kernel/devtree.c
  */
-void __init smp_init_cpus(void)
+static void __init dt_smp_init_cpus(void)
 {
     register_t mpidr;
     struct dt_device_node *cpus = dt_find_node_by_path("/cpus");
@@ -106,16 +106,6 @@ void __init smp_init_cpus(void)
     bool_t bootcpu_valid = 0;
     int rc;
 
-    /* scan the DTB for a PSCI node and set a global variable */
-    psci_init();
-
-    if ( (rc = arch_smp_init()) < 0 )
-    {
-        printk(XENLOG_WARNING "SMP init failed (%d)\n"
-               "Using only 1 CPU\n", rc);
-        return;
-    }
-
     mpidr = boot_cpu_data.mpidr.bits & MPIDR_HWID_MASK;
 
     if ( !cpus )
@@ -243,6 +233,23 @@ void __init smp_init_cpus(void)
     }
 }
 
+void __init smp_init_cpus(void)
+{
+    int rc;
+
+    /* initialize PSCI and set a global variable */
+    psci_init();
+
+    if ( (rc = arch_smp_init()) < 0 )
+    {
+        printk(XENLOG_WARNING "SMP init failed (%d)\n"
+               "Using only 1 CPU\n", rc);
+        return;
+    }
+
+    dt_smp_init_cpus();
+}
+
 int __init
 smp_get_max_cpus (void)
 {
-- 
2.1.0

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

* [PATCH v3 19/62] arm/smpboot: Move dt specific code in smp to seperate functions
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

Partition smp initialization functions into generic and dt specific
parts, this will be useful when introducing new functions for smp
initialization based on acpi.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/arm64/smpboot.c |  7 ++++++-
 xen/arch/arm/smpboot.c       | 29 ++++++++++++++++++-----------
 2 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/xen/arch/arm/arm64/smpboot.c b/xen/arch/arm/arm64/smpboot.c
index 62e6abb..7928f69 100644
--- a/xen/arch/arm/arm64/smpboot.c
+++ b/xen/arch/arm/arm64/smpboot.c
@@ -70,7 +70,7 @@ int __init arch_smp_init(void)
     return 0;
 }
 
-int __init arch_cpu_init(int cpu, struct dt_device_node *dn)
+static int __init dt_arch_cpu_init(int cpu, struct dt_device_node *dn)
 {
     const char *enable_method;
 
@@ -94,6 +94,11 @@ int __init arch_cpu_init(int cpu, struct dt_device_node *dn)
     return 0;
 }
 
+int __init arch_cpu_init(int cpu, struct dt_device_node *dn)
+{
+    return dt_arch_cpu_init(cpu, dn);
+}
+
 int __init arch_cpu_up(int cpu)
 {
     if ( !smp_enable_ops[cpu].prepare_cpu )
diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c
index a96cda2..d115228 100644
--- a/xen/arch/arm/smpboot.c
+++ b/xen/arch/arm/smpboot.c
@@ -92,7 +92,7 @@ smp_clear_cpu_maps (void)
  * MPIDR values related to logical cpus
  * Code base on Linux arch/arm/kernel/devtree.c
  */
-void __init smp_init_cpus(void)
+static void __init dt_smp_init_cpus(void)
 {
     register_t mpidr;
     struct dt_device_node *cpus = dt_find_node_by_path("/cpus");
@@ -106,16 +106,6 @@ void __init smp_init_cpus(void)
     bool_t bootcpu_valid = 0;
     int rc;
 
-    /* scan the DTB for a PSCI node and set a global variable */
-    psci_init();
-
-    if ( (rc = arch_smp_init()) < 0 )
-    {
-        printk(XENLOG_WARNING "SMP init failed (%d)\n"
-               "Using only 1 CPU\n", rc);
-        return;
-    }
-
     mpidr = boot_cpu_data.mpidr.bits & MPIDR_HWID_MASK;
 
     if ( !cpus )
@@ -243,6 +233,23 @@ void __init smp_init_cpus(void)
     }
 }
 
+void __init smp_init_cpus(void)
+{
+    int rc;
+
+    /* initialize PSCI and set a global variable */
+    psci_init();
+
+    if ( (rc = arch_smp_init()) < 0 )
+    {
+        printk(XENLOG_WARNING "SMP init failed (%d)\n"
+               "Using only 1 CPU\n", rc);
+        return;
+    }
+
+    dt_smp_init_cpus();
+}
+
 int __init
 smp_get_max_cpus (void)
 {
-- 
2.1.0

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

* [PATCH v3 20/62] arm/acpi: Add ACPI support for SMP initialization
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

ACPI 5.1 only has two explicit methods to boot up SMP, PSCI and Parking
protocol, but the Parking protocol is only specified for ARMv7 now, so
make PSCI as the only way for the SMP boot protocol before some updates
for the ACPI spec or the Parking protocol spec.

Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/arm64/smpboot.c |  7 ++++++-
 xen/arch/arm/psci.c          | 30 +++++++++++++++++++++++-------
 xen/arch/arm/smpboot.c       |  7 ++++++-
 3 files changed, 35 insertions(+), 9 deletions(-)

diff --git a/xen/arch/arm/arm64/smpboot.c b/xen/arch/arm/arm64/smpboot.c
index 7928f69..93cb6b3 100644
--- a/xen/arch/arm/arm64/smpboot.c
+++ b/xen/arch/arm/arm64/smpboot.c
@@ -7,6 +7,7 @@
 #include <xen/vmap.h>
 #include <asm/io.h>
 #include <asm/psci.h>
+#include <asm/acpi.h>
 
 struct smp_enable_ops {
         int             (*prepare_cpu)(int);
@@ -96,7 +97,11 @@ static int __init dt_arch_cpu_init(int cpu, struct dt_device_node *dn)
 
 int __init arch_cpu_init(int cpu, struct dt_device_node *dn)
 {
-    return dt_arch_cpu_init(cpu, dn);
+    if( acpi_disabled )
+        return dt_arch_cpu_init(cpu, dn);
+    else
+        /* acpi only supports psci at present */
+        return smp_psci_init(cpu);
 }
 
 int __init arch_cpu_up(int cpu)
diff --git a/xen/arch/arm/psci.c b/xen/arch/arm/psci.c
index d800cb6..dede0e1 100644
--- a/xen/arch/arm/psci.c
+++ b/xen/arch/arm/psci.c
@@ -22,6 +22,7 @@
 #include <xen/mm.h>
 #include <xen/smp.h>
 #include <asm/psci.h>
+#include <asm/acpi.h>
 
 /*
  * While a 64-bit OS can make calls with SMC32 calling conventions, for
@@ -86,6 +87,9 @@ int __init psci_init_0_1(void)
     int ret;
     const struct dt_device_node *psci;
 
+    if ( !acpi_disabled )
+        return -EINVAL;
+
     psci = dt_find_compatible_node(NULL, NULL, "arm,psci");
     if ( !psci )
         return -EOPNOTSUPP;
@@ -116,15 +120,24 @@ int __init psci_init_0_2(void)
         { /* sentinel */ },
     };
     int ret;
-    const struct dt_device_node *psci;
 
-    psci = dt_find_matching_node(NULL, psci_ids);
-    if ( !psci )
-        return -EOPNOTSUPP;
+    if( acpi_disabled )
+    {
+        const struct dt_device_node *psci;
 
-    ret = psci_is_smc_method(psci);
-    if ( ret )
-        return -EINVAL;
+        psci = dt_find_matching_node(NULL, psci_ids);
+        if ( !psci )
+            return -EOPNOTSUPP;
+
+        ret = psci_is_smc_method(psci);
+        if ( ret )
+            return -EINVAL;
+    }
+    else
+    {
+        if ( acpi_psci_hvc_present() )
+            return -EINVAL;
+    }
 
     psci_ver = call_smc(PSCI_0_2_FN_PSCI_VERSION, 0, 0, 0);
 
@@ -148,6 +161,9 @@ int __init psci_init(void)
 {
     int ret;
 
+    if( !acpi_disabled && !acpi_psci_present() )
+        return -EOPNOTSUPP;
+
     ret = psci_init_0_2();
     if ( ret )
         ret = psci_init_0_1();
diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c
index d115228..513f1f6 100644
--- a/xen/arch/arm/smpboot.c
+++ b/xen/arch/arm/smpboot.c
@@ -31,6 +31,7 @@
 #include <xen/console.h>
 #include <asm/gic.h>
 #include <asm/psci.h>
+#include <asm/acpi.h>
 
 cpumask_t cpu_online_map;
 cpumask_t cpu_present_map;
@@ -247,7 +248,11 @@ void __init smp_init_cpus(void)
         return;
     }
 
-    dt_smp_init_cpus();
+    if ( acpi_disabled )
+        dt_smp_init_cpus();
+    else
+        acpi_smp_init_cpus();
+
 }
 
 int __init
-- 
2.1.0

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

* [PATCH v3 20/62] arm/acpi: Add ACPI support for SMP initialization
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

ACPI 5.1 only has two explicit methods to boot up SMP, PSCI and Parking
protocol, but the Parking protocol is only specified for ARMv7 now, so
make PSCI as the only way for the SMP boot protocol before some updates
for the ACPI spec or the Parking protocol spec.

Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/arm64/smpboot.c |  7 ++++++-
 xen/arch/arm/psci.c          | 30 +++++++++++++++++++++++-------
 xen/arch/arm/smpboot.c       |  7 ++++++-
 3 files changed, 35 insertions(+), 9 deletions(-)

diff --git a/xen/arch/arm/arm64/smpboot.c b/xen/arch/arm/arm64/smpboot.c
index 7928f69..93cb6b3 100644
--- a/xen/arch/arm/arm64/smpboot.c
+++ b/xen/arch/arm/arm64/smpboot.c
@@ -7,6 +7,7 @@
 #include <xen/vmap.h>
 #include <asm/io.h>
 #include <asm/psci.h>
+#include <asm/acpi.h>
 
 struct smp_enable_ops {
         int             (*prepare_cpu)(int);
@@ -96,7 +97,11 @@ static int __init dt_arch_cpu_init(int cpu, struct dt_device_node *dn)
 
 int __init arch_cpu_init(int cpu, struct dt_device_node *dn)
 {
-    return dt_arch_cpu_init(cpu, dn);
+    if( acpi_disabled )
+        return dt_arch_cpu_init(cpu, dn);
+    else
+        /* acpi only supports psci at present */
+        return smp_psci_init(cpu);
 }
 
 int __init arch_cpu_up(int cpu)
diff --git a/xen/arch/arm/psci.c b/xen/arch/arm/psci.c
index d800cb6..dede0e1 100644
--- a/xen/arch/arm/psci.c
+++ b/xen/arch/arm/psci.c
@@ -22,6 +22,7 @@
 #include <xen/mm.h>
 #include <xen/smp.h>
 #include <asm/psci.h>
+#include <asm/acpi.h>
 
 /*
  * While a 64-bit OS can make calls with SMC32 calling conventions, for
@@ -86,6 +87,9 @@ int __init psci_init_0_1(void)
     int ret;
     const struct dt_device_node *psci;
 
+    if ( !acpi_disabled )
+        return -EINVAL;
+
     psci = dt_find_compatible_node(NULL, NULL, "arm,psci");
     if ( !psci )
         return -EOPNOTSUPP;
@@ -116,15 +120,24 @@ int __init psci_init_0_2(void)
         { /* sentinel */ },
     };
     int ret;
-    const struct dt_device_node *psci;
 
-    psci = dt_find_matching_node(NULL, psci_ids);
-    if ( !psci )
-        return -EOPNOTSUPP;
+    if( acpi_disabled )
+    {
+        const struct dt_device_node *psci;
 
-    ret = psci_is_smc_method(psci);
-    if ( ret )
-        return -EINVAL;
+        psci = dt_find_matching_node(NULL, psci_ids);
+        if ( !psci )
+            return -EOPNOTSUPP;
+
+        ret = psci_is_smc_method(psci);
+        if ( ret )
+            return -EINVAL;
+    }
+    else
+    {
+        if ( acpi_psci_hvc_present() )
+            return -EINVAL;
+    }
 
     psci_ver = call_smc(PSCI_0_2_FN_PSCI_VERSION, 0, 0, 0);
 
@@ -148,6 +161,9 @@ int __init psci_init(void)
 {
     int ret;
 
+    if( !acpi_disabled && !acpi_psci_present() )
+        return -EOPNOTSUPP;
+
     ret = psci_init_0_2();
     if ( ret )
         ret = psci_init_0_1();
diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c
index d115228..513f1f6 100644
--- a/xen/arch/arm/smpboot.c
+++ b/xen/arch/arm/smpboot.c
@@ -31,6 +31,7 @@
 #include <xen/console.h>
 #include <asm/gic.h>
 #include <asm/psci.h>
+#include <asm/acpi.h>
 
 cpumask_t cpu_online_map;
 cpumask_t cpu_present_map;
@@ -247,7 +248,11 @@ void __init smp_init_cpus(void)
         return;
     }
 
-    dt_smp_init_cpus();
+    if ( acpi_disabled )
+        dt_smp_init_cpus();
+    else
+        acpi_smp_init_cpus();
+
 }
 
 int __init
-- 
2.1.0

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

* [PATCH v3 21/62] arm/gic-v2: Refactor gicv2_init into generic and dt specific parts
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

Refactor gic-v2 related functions into dt and generic parts. This will be
helpful when adding acpi support for gic.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/gic-v2.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
index 01e36b5..e31d38e 100644
--- a/xen/arch/arm/gic-v2.c
+++ b/xen/arch/arm/gic-v2.c
@@ -628,13 +628,12 @@ static bool_t gicv2_is_aliased(paddr_t cbase, paddr_t csize)
     return ((val_low & 0xfff0fff) == 0x0202043B && val_low == val_high);
 }
 
-static int __init gicv2_init(void)
+static paddr_t __initdata hbase, dbase, cbase, csize, vbase;
+
+static void __init dt_gicv2_init(void)
 {
     int res;
-    paddr_t hbase, dbase;
-    paddr_t cbase, csize;
-    paddr_t vbase, vsize;
-    uint32_t aliased_offset = 0;
+    paddr_t vsize;
     const struct dt_device_node *node = gicv2_info.node;
 
     res = dt_device_get_address(node, 0, &dbase, NULL);
@@ -680,6 +679,13 @@ static int __init gicv2_init(void)
     if ( csize != vsize )
         panic("GICv2: Sizes of GICC (%#"PRIpaddr") and GICV (%#"PRIpaddr") don't match\n",
                csize, vsize);
+}
+
+static int __init gicv2_init(void)
+{
+    uint32_t aliased_offset = 0;
+
+    dt_gicv2_init();
 
     printk("GICv2 initialization:\n"
               "        gic_dist_addr=%"PRIpaddr"\n"
@@ -765,7 +771,8 @@ const static struct gic_hw_operations gicv2_ops = {
 };
 
 /* Set up the GIC */
-static int __init gicv2_preinit(struct dt_device_node *node, const void *data)
+static int __init dt_gicv2_preinit(struct dt_device_node *node,
+                                   const void *data)
 {
     gicv2_info.hw_version = GIC_V2;
     gicv2_info.node = node;
@@ -783,7 +790,7 @@ static const struct dt_device_match gicv2_dt_match[] __initconst =
 
 DT_DEVICE_START(gicv2, "GICv2", DEVICE_GIC)
         .dt_match = gicv2_dt_match,
-        .init = gicv2_preinit,
+        .init = dt_gicv2_preinit,
 DT_DEVICE_END
 
 /*
-- 
2.1.0

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

* [PATCH v3 21/62] arm/gic-v2: Refactor gicv2_init into generic and dt specific parts
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

Refactor gic-v2 related functions into dt and generic parts. This will be
helpful when adding acpi support for gic.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/gic-v2.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
index 01e36b5..e31d38e 100644
--- a/xen/arch/arm/gic-v2.c
+++ b/xen/arch/arm/gic-v2.c
@@ -628,13 +628,12 @@ static bool_t gicv2_is_aliased(paddr_t cbase, paddr_t csize)
     return ((val_low & 0xfff0fff) == 0x0202043B && val_low == val_high);
 }
 
-static int __init gicv2_init(void)
+static paddr_t __initdata hbase, dbase, cbase, csize, vbase;
+
+static void __init dt_gicv2_init(void)
 {
     int res;
-    paddr_t hbase, dbase;
-    paddr_t cbase, csize;
-    paddr_t vbase, vsize;
-    uint32_t aliased_offset = 0;
+    paddr_t vsize;
     const struct dt_device_node *node = gicv2_info.node;
 
     res = dt_device_get_address(node, 0, &dbase, NULL);
@@ -680,6 +679,13 @@ static int __init gicv2_init(void)
     if ( csize != vsize )
         panic("GICv2: Sizes of GICC (%#"PRIpaddr") and GICV (%#"PRIpaddr") don't match\n",
                csize, vsize);
+}
+
+static int __init gicv2_init(void)
+{
+    uint32_t aliased_offset = 0;
+
+    dt_gicv2_init();
 
     printk("GICv2 initialization:\n"
               "        gic_dist_addr=%"PRIpaddr"\n"
@@ -765,7 +771,8 @@ const static struct gic_hw_operations gicv2_ops = {
 };
 
 /* Set up the GIC */
-static int __init gicv2_preinit(struct dt_device_node *node, const void *data)
+static int __init dt_gicv2_preinit(struct dt_device_node *node,
+                                   const void *data)
 {
     gicv2_info.hw_version = GIC_V2;
     gicv2_info.node = node;
@@ -783,7 +790,7 @@ static const struct dt_device_match gicv2_dt_match[] __initconst =
 
 DT_DEVICE_START(gicv2, "GICv2", DEVICE_GIC)
         .dt_match = gicv2_dt_match,
-        .init = gicv2_preinit,
+        .init = dt_gicv2_preinit,
 DT_DEVICE_END
 
 /*
-- 
2.1.0

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

* [PATCH v3 22/62] arm/gic-v3: Refactor gicv3_init into generic and dt specific parts
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

Refactor gic-v3 related functions into dt and generic parts. This will be
helpful when adding acpi support for gic-v3.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/gic-v3.c | 95 +++++++++++++++++++++++++++------------------------
 1 file changed, 51 insertions(+), 44 deletions(-)

diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
index 4fe0c37..bd13010 100644
--- a/xen/arch/arm/gic-v3.c
+++ b/xen/arch/arm/gic-v3.c
@@ -1138,62 +1138,27 @@ static int __init cmp_rdist(const void *a, const void *b)
     return ( l->base < r->base) ? -1 : 0;
 }
 
+static paddr_t __initdata dbase = 0, cbase = 0, csize = 0, vbase = 0;
+
 /* If the GICv3 supports GICv2, initialize it */
-static void __init gicv3_init_v2(const struct dt_device_node *node,
-                                 paddr_t dbase)
+static void __init gicv3_init_v2(void)
 {
-    int res;
-    paddr_t cbase, csize;
-    paddr_t vbase, vsize;
-
-    /*
-     * For GICv3 supporting GICv2, GICC and GICV base address will be
-     * provided.
-     */
-    res = dt_device_get_address(node, 1 + gicv3.rdist_count,
-                                &cbase, &csize);
-    if ( res )
+    if ( cbase == 0 || vbase == 0 )
         return;
 
-    res = dt_device_get_address(node, 1 + gicv3.rdist_count + 2,
-                                &vbase, &vsize);
-    if ( res )
-        return;
-
-    /*
-     * We emulate a vGICv2 using a GIC CPU interface of GUEST_GICC_SIZE.
-     * So only support GICv2 on GICv3 when the virtual CPU interface is
-     * at least GUEST_GICC_SIZE.
-     */
-    if ( vsize < GUEST_GICC_SIZE )
-    {
-        printk(XENLOG_WARNING
-               "GICv3: WARNING: Not enabling support for GICv2 compat mode.\n"
-               "Size of GICV (%#"PRIpaddr") must at least be %#llx.\n",
-               vsize, GUEST_GICC_SIZE);
-        return;
-    }
-
     printk("GICv3 compatible with GICv2 cbase %#"PRIpaddr" vbase %#"PRIpaddr"\n",
            cbase, vbase);
 
     vgic_v2_setup_hw(dbase, cbase, csize, vbase, 0);
 }
 
-/* Set up the GIC */
-static int __init gicv3_init(void)
+static void __init dt_gicv3_init(void)
 {
     struct rdist_region *rdist_regs;
     int res, i;
     uint32_t reg;
     const struct dt_device_node *node = gicv3_info.node;
-    paddr_t dbase;
-
-    if ( !cpu_has_gicv3 )
-    {
-        dprintk(XENLOG_ERR, "GICv3: driver requires system register support\n");
-        return -ENODEV;
-    }
+    paddr_t vsize;
 
     res = dt_device_get_address(node, 0, &dbase, NULL);
     if ( res )
@@ -1248,6 +1213,48 @@ static int __init gicv3_init(void)
         panic("GICv3: Cannot find the maintenance IRQ");
     gicv3_info.maintenance_irq = res;
 
+    /*
+     * For GICv3 supporting GICv2, GICC and GICV base address will be
+     * provided.
+     */
+    res = dt_device_get_address(node, 1 + gicv3.rdist_count,
+                                &cbase, &csize);
+    if ( res )
+        return;
+
+    res = dt_device_get_address(node, 1 + gicv3.rdist_count + 2,
+                                &vbase, &vsize);
+    if ( res )
+        return;
+
+    /*
+     * We emulate a vGICv2 using a GIC CPU interface of GUEST_GICC_SIZE.
+     * So only support GICv2 on GICv3 when the virtual CPU interface is
+     * at least GUEST_GICC_SIZE.
+     */
+    if ( vsize < GUEST_GICC_SIZE )
+    {
+        printk(XENLOG_WARNING
+               "GICv3: WARNING: Not enabling support for GICv2 compat mode.\n"
+               "Size of GICV (%#"PRIpaddr") must@least be %#llx.\n",
+               vsize, GUEST_GICC_SIZE);
+        return;
+    }
+}
+
+/* Set up the GIC */
+static int __init gicv3_init(void)
+{
+    int res, i;
+
+    if ( !cpu_has_gicv3 )
+    {
+        dprintk(XENLOG_ERR, "GICv3: driver requires system register support\n");
+        return -ENODEV;
+    }
+
+    dt_gicv3_init();
+
     for ( i = 0; i < gicv3.rdist_count; i++ )
     {
         /* map dbase & rdist regions */
@@ -1277,7 +1284,7 @@ static int __init gicv3_init(void)
 
     vgic_v3_setup_hw(dbase, gicv3.rdist_count, gicv3.rdist_regions,
                      gicv3.rdist_stride);
-    gicv3_init_v2(node, dbase);
+    gicv3_init_v2();
 
     spin_lock_init(&gicv3.lock);
 
@@ -1317,7 +1324,7 @@ static const struct gic_hw_operations gicv3_ops = {
     .make_hwdom_dt_node  = gicv3_make_hwdom_dt_node,
 };
 
-static int __init gicv3_preinit(struct dt_device_node *node, const void *data)
+static int __init dt_gicv3_preinit(struct dt_device_node *node, const void *data)
 {
     gicv3_info.hw_version = GIC_V3;
     gicv3_info.node = node;
@@ -1335,7 +1342,7 @@ static const struct dt_device_match gicv3_dt_match[] __initconst =
 
 DT_DEVICE_START(gicv3, "GICv3", DEVICE_GIC)
         .dt_match = gicv3_dt_match,
-        .init = gicv3_preinit,
+        .init = dt_gicv3_preinit,
 DT_DEVICE_END
 
 /*
-- 
2.1.0

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

* [PATCH v3 22/62] arm/gic-v3: Refactor gicv3_init into generic and dt specific parts
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

Refactor gic-v3 related functions into dt and generic parts. This will be
helpful when adding acpi support for gic-v3.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/gic-v3.c | 95 +++++++++++++++++++++++++++------------------------
 1 file changed, 51 insertions(+), 44 deletions(-)

diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
index 4fe0c37..bd13010 100644
--- a/xen/arch/arm/gic-v3.c
+++ b/xen/arch/arm/gic-v3.c
@@ -1138,62 +1138,27 @@ static int __init cmp_rdist(const void *a, const void *b)
     return ( l->base < r->base) ? -1 : 0;
 }
 
+static paddr_t __initdata dbase = 0, cbase = 0, csize = 0, vbase = 0;
+
 /* If the GICv3 supports GICv2, initialize it */
-static void __init gicv3_init_v2(const struct dt_device_node *node,
-                                 paddr_t dbase)
+static void __init gicv3_init_v2(void)
 {
-    int res;
-    paddr_t cbase, csize;
-    paddr_t vbase, vsize;
-
-    /*
-     * For GICv3 supporting GICv2, GICC and GICV base address will be
-     * provided.
-     */
-    res = dt_device_get_address(node, 1 + gicv3.rdist_count,
-                                &cbase, &csize);
-    if ( res )
+    if ( cbase == 0 || vbase == 0 )
         return;
 
-    res = dt_device_get_address(node, 1 + gicv3.rdist_count + 2,
-                                &vbase, &vsize);
-    if ( res )
-        return;
-
-    /*
-     * We emulate a vGICv2 using a GIC CPU interface of GUEST_GICC_SIZE.
-     * So only support GICv2 on GICv3 when the virtual CPU interface is
-     * at least GUEST_GICC_SIZE.
-     */
-    if ( vsize < GUEST_GICC_SIZE )
-    {
-        printk(XENLOG_WARNING
-               "GICv3: WARNING: Not enabling support for GICv2 compat mode.\n"
-               "Size of GICV (%#"PRIpaddr") must at least be %#llx.\n",
-               vsize, GUEST_GICC_SIZE);
-        return;
-    }
-
     printk("GICv3 compatible with GICv2 cbase %#"PRIpaddr" vbase %#"PRIpaddr"\n",
            cbase, vbase);
 
     vgic_v2_setup_hw(dbase, cbase, csize, vbase, 0);
 }
 
-/* Set up the GIC */
-static int __init gicv3_init(void)
+static void __init dt_gicv3_init(void)
 {
     struct rdist_region *rdist_regs;
     int res, i;
     uint32_t reg;
     const struct dt_device_node *node = gicv3_info.node;
-    paddr_t dbase;
-
-    if ( !cpu_has_gicv3 )
-    {
-        dprintk(XENLOG_ERR, "GICv3: driver requires system register support\n");
-        return -ENODEV;
-    }
+    paddr_t vsize;
 
     res = dt_device_get_address(node, 0, &dbase, NULL);
     if ( res )
@@ -1248,6 +1213,48 @@ static int __init gicv3_init(void)
         panic("GICv3: Cannot find the maintenance IRQ");
     gicv3_info.maintenance_irq = res;
 
+    /*
+     * For GICv3 supporting GICv2, GICC and GICV base address will be
+     * provided.
+     */
+    res = dt_device_get_address(node, 1 + gicv3.rdist_count,
+                                &cbase, &csize);
+    if ( res )
+        return;
+
+    res = dt_device_get_address(node, 1 + gicv3.rdist_count + 2,
+                                &vbase, &vsize);
+    if ( res )
+        return;
+
+    /*
+     * We emulate a vGICv2 using a GIC CPU interface of GUEST_GICC_SIZE.
+     * So only support GICv2 on GICv3 when the virtual CPU interface is
+     * at least GUEST_GICC_SIZE.
+     */
+    if ( vsize < GUEST_GICC_SIZE )
+    {
+        printk(XENLOG_WARNING
+               "GICv3: WARNING: Not enabling support for GICv2 compat mode.\n"
+               "Size of GICV (%#"PRIpaddr") must at least be %#llx.\n",
+               vsize, GUEST_GICC_SIZE);
+        return;
+    }
+}
+
+/* Set up the GIC */
+static int __init gicv3_init(void)
+{
+    int res, i;
+
+    if ( !cpu_has_gicv3 )
+    {
+        dprintk(XENLOG_ERR, "GICv3: driver requires system register support\n");
+        return -ENODEV;
+    }
+
+    dt_gicv3_init();
+
     for ( i = 0; i < gicv3.rdist_count; i++ )
     {
         /* map dbase & rdist regions */
@@ -1277,7 +1284,7 @@ static int __init gicv3_init(void)
 
     vgic_v3_setup_hw(dbase, gicv3.rdist_count, gicv3.rdist_regions,
                      gicv3.rdist_stride);
-    gicv3_init_v2(node, dbase);
+    gicv3_init_v2();
 
     spin_lock_init(&gicv3.lock);
 
@@ -1317,7 +1324,7 @@ static const struct gic_hw_operations gicv3_ops = {
     .make_hwdom_dt_node  = gicv3_make_hwdom_dt_node,
 };
 
-static int __init gicv3_preinit(struct dt_device_node *node, const void *data)
+static int __init dt_gicv3_preinit(struct dt_device_node *node, const void *data)
 {
     gicv3_info.hw_version = GIC_V3;
     gicv3_info.node = node;
@@ -1335,7 +1342,7 @@ static const struct dt_device_match gicv3_dt_match[] __initconst =
 
 DT_DEVICE_START(gicv3, "GICv3", DEVICE_GIC)
         .dt_match = gicv3_dt_match,
-        .init = gicv3_preinit,
+        .init = dt_gicv3_preinit,
 DT_DEVICE_END
 
 /*
-- 
2.1.0

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

* [PATCH v3 23/62] acpi/table: Introduce acpi_parse_entries
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

Add new function acpi_parse_entries which takes acpi table as argument.
This will avoid fetching table everytime in acpi_table_parse_entries.
This function will be used in acpi_gicv2_init within another patch.

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>
---
 xen/drivers/acpi/tables.c | 53 ++++++++++++++++++++++++++++++++++-------------
 xen/include/xen/acpi.h    |  3 +++
 2 files changed, 42 insertions(+), 14 deletions(-)

diff --git a/xen/drivers/acpi/tables.c b/xen/drivers/acpi/tables.c
index 6573175..2fba206 100644
--- a/xen/drivers/acpi/tables.c
+++ b/xen/drivers/acpi/tables.c
@@ -221,29 +221,27 @@ void __init acpi_table_print_madt_entry(struct acpi_subtable_header *header)
 	}
 }
 
-
 int __init
-acpi_table_parse_entries(char *id,
-			     unsigned long table_size,
-			     int entry_id,
-			     acpi_table_entry_handler handler,
-			     unsigned int max_entries)
+acpi_parse_entries(char *id,
+		      unsigned long table_size,
+		      acpi_table_entry_handler handler,
+		      struct acpi_table_header *table_header,
+		      int entry_id,
+		      unsigned int max_entries)
 {
-	struct acpi_table_header *table_header = NULL;
 	struct acpi_subtable_header *entry;
 	unsigned int count = 0;
 	unsigned long table_end;
 
-	if (!handler)
+	if ( !handler )
 		return -EINVAL;
 
-	if (strncmp(id, ACPI_SIG_MADT, 4) == 0)
-		acpi_get_table(id, acpi_apic_instance, &table_header);
-	else
-		acpi_get_table(id, 0, &table_header);
+	if ( !table_size )
+		return -EINVAL;
 
-	if (!table_header) {
-		printk(KERN_WARNING PREFIX "%4.4s not present\n", id);
+	if ( !table_header )
+	{
+		printk("Table header not present\n");
 		return -ENODEV;
 	}
 
@@ -279,6 +277,33 @@ acpi_table_parse_entries(char *id,
 	}
 
 	return count;
+
+}
+
+int __init
+acpi_table_parse_entries(char *id,
+			     unsigned long table_size,
+			     int entry_id,
+			     acpi_table_entry_handler handler,
+			     unsigned int max_entries)
+{
+	struct acpi_table_header *table_header = NULL;
+
+	if (!handler)
+		return -EINVAL;
+
+	if (strncmp(id, ACPI_SIG_MADT, 4) == 0)
+		acpi_get_table(id, acpi_apic_instance, &table_header);
+	else
+		acpi_get_table(id, 0, &table_header);
+
+	if (!table_header) {
+		printk(KERN_WARNING PREFIX "%4.4s not present\n", id);
+		return -ENODEV;
+	}
+
+	return acpi_parse_entries(id, table_size, handler, table_header,
+				  entry_id, max_entries);
 }
 
 int __init
diff --git a/xen/include/xen/acpi.h b/xen/include/xen/acpi.h
index 723ece8..23f8261 100644
--- a/xen/include/xen/acpi.h
+++ b/xen/include/xen/acpi.h
@@ -72,6 +72,9 @@ int acpi_table_init (void);
 int acpi_table_parse(char *id, acpi_table_handler handler);
 int acpi_table_parse_entries(char *id, unsigned long table_size,
 	int entry_id, acpi_table_entry_handler handler, unsigned int max_entries);
+int acpi_parse_entries(char *id, unsigned long table_size,
+	acpi_table_entry_handler handler, struct acpi_table_header *table_header,
+	int entry_id, unsigned int max_entries);
 int acpi_table_parse_madt(enum acpi_madt_type id, acpi_table_entry_handler handler, unsigned int max_entries);
 int acpi_table_parse_srat(int id, acpi_madt_entry_handler handler,
 	unsigned int max_entries);
-- 
2.1.0

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

* [PATCH v3 23/62] acpi/table: Introduce acpi_parse_entries
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

Add new function acpi_parse_entries which takes acpi table as argument.
This will avoid fetching table everytime in acpi_table_parse_entries.
This function will be used in acpi_gicv2_init within another patch.

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>
---
 xen/drivers/acpi/tables.c | 53 ++++++++++++++++++++++++++++++++++-------------
 xen/include/xen/acpi.h    |  3 +++
 2 files changed, 42 insertions(+), 14 deletions(-)

diff --git a/xen/drivers/acpi/tables.c b/xen/drivers/acpi/tables.c
index 6573175..2fba206 100644
--- a/xen/drivers/acpi/tables.c
+++ b/xen/drivers/acpi/tables.c
@@ -221,29 +221,27 @@ void __init acpi_table_print_madt_entry(struct acpi_subtable_header *header)
 	}
 }
 
-
 int __init
-acpi_table_parse_entries(char *id,
-			     unsigned long table_size,
-			     int entry_id,
-			     acpi_table_entry_handler handler,
-			     unsigned int max_entries)
+acpi_parse_entries(char *id,
+		      unsigned long table_size,
+		      acpi_table_entry_handler handler,
+		      struct acpi_table_header *table_header,
+		      int entry_id,
+		      unsigned int max_entries)
 {
-	struct acpi_table_header *table_header = NULL;
 	struct acpi_subtable_header *entry;
 	unsigned int count = 0;
 	unsigned long table_end;
 
-	if (!handler)
+	if ( !handler )
 		return -EINVAL;
 
-	if (strncmp(id, ACPI_SIG_MADT, 4) == 0)
-		acpi_get_table(id, acpi_apic_instance, &table_header);
-	else
-		acpi_get_table(id, 0, &table_header);
+	if ( !table_size )
+		return -EINVAL;
 
-	if (!table_header) {
-		printk(KERN_WARNING PREFIX "%4.4s not present\n", id);
+	if ( !table_header )
+	{
+		printk("Table header not present\n");
 		return -ENODEV;
 	}
 
@@ -279,6 +277,33 @@ acpi_table_parse_entries(char *id,
 	}
 
 	return count;
+
+}
+
+int __init
+acpi_table_parse_entries(char *id,
+			     unsigned long table_size,
+			     int entry_id,
+			     acpi_table_entry_handler handler,
+			     unsigned int max_entries)
+{
+	struct acpi_table_header *table_header = NULL;
+
+	if (!handler)
+		return -EINVAL;
+
+	if (strncmp(id, ACPI_SIG_MADT, 4) == 0)
+		acpi_get_table(id, acpi_apic_instance, &table_header);
+	else
+		acpi_get_table(id, 0, &table_header);
+
+	if (!table_header) {
+		printk(KERN_WARNING PREFIX "%4.4s not present\n", id);
+		return -ENODEV;
+	}
+
+	return acpi_parse_entries(id, table_size, handler, table_header,
+				  entry_id, max_entries);
 }
 
 int __init
diff --git a/xen/include/xen/acpi.h b/xen/include/xen/acpi.h
index 723ece8..23f8261 100644
--- a/xen/include/xen/acpi.h
+++ b/xen/include/xen/acpi.h
@@ -72,6 +72,9 @@ int acpi_table_init (void);
 int acpi_table_parse(char *id, acpi_table_handler handler);
 int acpi_table_parse_entries(char *id, unsigned long table_size,
 	int entry_id, acpi_table_entry_handler handler, unsigned int max_entries);
+int acpi_parse_entries(char *id, unsigned long table_size,
+	acpi_table_entry_handler handler, struct acpi_table_header *table_header,
+	int entry_id, unsigned int max_entries);
 int acpi_table_parse_madt(enum acpi_madt_type id, acpi_table_entry_handler handler, unsigned int max_entries);
 int acpi_table_parse_srat(int id, acpi_madt_entry_handler handler,
 	unsigned int max_entries);
-- 
2.1.0

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

* [PATCH v3 24/62] arm: Introduce a generic way to use a device from acpi
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

Add generic way to use device from acpi similar to the way it is
supported in device tree.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/device.c        | 19 +++++++++++++++++++
 xen/arch/arm/xen.lds.S       |  7 +++++++
 xen/include/asm-arm/device.h | 30 ++++++++++++++++++++++++++++++
 3 files changed, 56 insertions(+)

diff --git a/xen/arch/arm/device.c b/xen/arch/arm/device.c
index 0b53f6a..5494de0 100644
--- a/xen/arch/arm/device.c
+++ b/xen/arch/arm/device.c
@@ -22,6 +22,7 @@
 #include <xen/lib.h>
 
 extern const struct device_desc _sdevice[], _edevice[];
+extern const struct acpi_device_desc _asdevice[], _aedevice[];
 
 int __init device_init(struct dt_device_node *dev, enum device_class class,
                        const void *data)
@@ -50,6 +51,24 @@ int __init device_init(struct dt_device_node *dev, enum device_class class,
     return -EBADF;
 }
 
+int __init acpi_device_init(enum device_class class, const void *data, int class_type)
+{
+    const struct acpi_device_desc *desc;
+
+    for ( desc = _asdevice; desc != _aedevice; desc++ )
+    {
+        if ( ( desc->class != class ) && ( desc->class_type != class_type ) )
+            continue;
+
+
+        ASSERT(desc->init != NULL);
+
+        return desc->init(data);
+    }
+
+    return -EBADF;
+}
+
 enum device_class device_get_class(const struct dt_device_node *dev)
 {
     const struct device_desc *desc;
diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S
index 0488f37..60802f6 100644
--- a/xen/arch/arm/xen.lds.S
+++ b/xen/arch/arm/xen.lds.S
@@ -100,6 +100,13 @@ SECTIONS
       _edevice = .;
   } :text
 
+  . = ALIGN(8);
+  .adev.info : {
+      _asdevice = .;
+      *(.adev.info)
+      _aedevice = .;
+  } :text
+
   . = ALIGN(PAGE_SIZE);             /* Init code and data */
   __init_begin = .;
   .init.text : {
diff --git a/xen/include/asm-arm/device.h b/xen/include/asm-arm/device.h
index 5d0a4cd..085f221 100644
--- a/xen/include/asm-arm/device.h
+++ b/xen/include/asm-arm/device.h
@@ -50,6 +50,27 @@ struct device_desc {
     int (*init)(struct dt_device_node *dev, const void *data);
 };
 
+struct acpi_device_desc {
+    /* Device name */
+    const char *name;
+    /* Device class */
+    enum device_class class;
+    /* type of device supported by the driver */
+    const int class_type;
+    /* Device initialization */
+    int (*init)(const void *data);
+};
+
+/**
+ *  acpi_device_init - Initialize a device
+ *  @class: class of the device (serial, network...)
+ *  @data: specific data for initializing the device
+ *
+ *  Return 0 on success.
+ */
+int __init acpi_device_init(enum device_class class,
+                            const void *data, int class_type);
+
 /**
  *  device_init - Initialize a device
  *  @dev: device to initialize
@@ -78,6 +99,15 @@ __section(".dev.info") = {                                          \
 #define DT_DEVICE_END                                               \
 };
 
+#define ACPI_DEVICE_START(_name, _namestr, _class)                    \
+static const struct acpi_device_desc __dev_desc_##_name __used           \
+__attribute__((__section__(".adev.info"))) = {                       \
+    .name = _namestr,                                               \
+    .class = _class,                                                \
+
+#define ACPI_DEVICE_END                                               \
+};
+
 #endif /* __ASM_ARM_DEVICE_H */
 
 /*
-- 
2.1.0

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

* [PATCH v3 24/62] arm: Introduce a generic way to use a device from acpi
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

Add generic way to use device from acpi similar to the way it is
supported in device tree.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/device.c        | 19 +++++++++++++++++++
 xen/arch/arm/xen.lds.S       |  7 +++++++
 xen/include/asm-arm/device.h | 30 ++++++++++++++++++++++++++++++
 3 files changed, 56 insertions(+)

diff --git a/xen/arch/arm/device.c b/xen/arch/arm/device.c
index 0b53f6a..5494de0 100644
--- a/xen/arch/arm/device.c
+++ b/xen/arch/arm/device.c
@@ -22,6 +22,7 @@
 #include <xen/lib.h>
 
 extern const struct device_desc _sdevice[], _edevice[];
+extern const struct acpi_device_desc _asdevice[], _aedevice[];
 
 int __init device_init(struct dt_device_node *dev, enum device_class class,
                        const void *data)
@@ -50,6 +51,24 @@ int __init device_init(struct dt_device_node *dev, enum device_class class,
     return -EBADF;
 }
 
+int __init acpi_device_init(enum device_class class, const void *data, int class_type)
+{
+    const struct acpi_device_desc *desc;
+
+    for ( desc = _asdevice; desc != _aedevice; desc++ )
+    {
+        if ( ( desc->class != class ) && ( desc->class_type != class_type ) )
+            continue;
+
+
+        ASSERT(desc->init != NULL);
+
+        return desc->init(data);
+    }
+
+    return -EBADF;
+}
+
 enum device_class device_get_class(const struct dt_device_node *dev)
 {
     const struct device_desc *desc;
diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S
index 0488f37..60802f6 100644
--- a/xen/arch/arm/xen.lds.S
+++ b/xen/arch/arm/xen.lds.S
@@ -100,6 +100,13 @@ SECTIONS
       _edevice = .;
   } :text
 
+  . = ALIGN(8);
+  .adev.info : {
+      _asdevice = .;
+      *(.adev.info)
+      _aedevice = .;
+  } :text
+
   . = ALIGN(PAGE_SIZE);             /* Init code and data */
   __init_begin = .;
   .init.text : {
diff --git a/xen/include/asm-arm/device.h b/xen/include/asm-arm/device.h
index 5d0a4cd..085f221 100644
--- a/xen/include/asm-arm/device.h
+++ b/xen/include/asm-arm/device.h
@@ -50,6 +50,27 @@ struct device_desc {
     int (*init)(struct dt_device_node *dev, const void *data);
 };
 
+struct acpi_device_desc {
+    /* Device name */
+    const char *name;
+    /* Device class */
+    enum device_class class;
+    /* type of device supported by the driver */
+    const int class_type;
+    /* Device initialization */
+    int (*init)(const void *data);
+};
+
+/**
+ *  acpi_device_init - Initialize a device
+ *  @class: class of the device (serial, network...)
+ *  @data: specific data for initializing the device
+ *
+ *  Return 0 on success.
+ */
+int __init acpi_device_init(enum device_class class,
+                            const void *data, int class_type);
+
 /**
  *  device_init - Initialize a device
  *  @dev: device to initialize
@@ -78,6 +99,15 @@ __section(".dev.info") = {                                          \
 #define DT_DEVICE_END                                               \
 };
 
+#define ACPI_DEVICE_START(_name, _namestr, _class)                    \
+static const struct acpi_device_desc __dev_desc_##_name __used           \
+__attribute__((__section__(".adev.info"))) = {                       \
+    .name = _namestr,                                               \
+    .class = _class,                                                \
+
+#define ACPI_DEVICE_END                                               \
+};
+
 #endif /* __ASM_ARM_DEVICE_H */
 
 /*
-- 
2.1.0

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

* [PATCH v3 25/62] acpi/table: Introduce acpi_get_entry to get specified entry
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

When constructing MADT table for Dom0, it needs to create GICC subtable
according to the dom0_max_vcpus. This function could be used for get the
specified entry.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/drivers/acpi/tables.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
 xen/include/xen/acpi.h    |  4 ++++
 2 files changed, 49 insertions(+)

diff --git a/xen/drivers/acpi/tables.c b/xen/drivers/acpi/tables.c
index 2fba206..3ba8bad 100644
--- a/xen/drivers/acpi/tables.c
+++ b/xen/drivers/acpi/tables.c
@@ -221,6 +221,51 @@ void __init acpi_table_print_madt_entry(struct acpi_subtable_header *header)
 	}
 }
 
+struct acpi_subtable_header * __init
+acpi_get_entry(char *id, unsigned long table_size,
+	       struct acpi_table_header *table_header, int entry_id,
+	       unsigned int entry_index)
+{
+	struct acpi_subtable_header *entry;
+	unsigned int count = 0;
+	unsigned long table_end;
+
+	if ( !table_size )
+		return NULL;
+
+	if ( !table_header )
+	{
+		printk("Table header not present\n");
+		return NULL;
+	}
+
+	table_end = (unsigned long)table_header + table_header->length;
+
+	/* Parse all entries looking for a match. */
+	entry = (struct acpi_subtable_header *)
+	    ((unsigned long)table_header + table_size);
+
+	while (((unsigned long)entry) + sizeof(struct acpi_subtable_header) <
+	       table_end) {
+		if (entry->length < sizeof(*entry)) {
+			printk(KERN_ERR PREFIX "[%4.4s:%#x] Invalid length\n",
+			       id, entry_id);
+			return NULL;
+		}
+
+		if (entry->type == entry_id) {
+			if (count == entry_index)
+				return entry;
+			count++;
+		}
+
+		entry = (struct acpi_subtable_header *)
+		    ((unsigned long)entry + entry->length);
+	}
+
+	return NULL;
+}
+
 int __init
 acpi_parse_entries(char *id,
 		      unsigned long table_size,
diff --git a/xen/include/xen/acpi.h b/xen/include/xen/acpi.h
index 23f8261..3339374 100644
--- a/xen/include/xen/acpi.h
+++ b/xen/include/xen/acpi.h
@@ -72,6 +72,10 @@ int acpi_table_init (void);
 int acpi_table_parse(char *id, acpi_table_handler handler);
 int acpi_table_parse_entries(char *id, unsigned long table_size,
 	int entry_id, acpi_table_entry_handler handler, unsigned int max_entries);
+struct acpi_subtable_header *
+acpi_get_entry(char *id, unsigned long table_size,
+	       struct acpi_table_header *table_header, int entry_id,
+	       unsigned int entry_index);
 int acpi_parse_entries(char *id, unsigned long table_size,
 	acpi_table_entry_handler handler, struct acpi_table_header *table_header,
 	int entry_id, unsigned int max_entries);
-- 
2.1.0

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

* [PATCH v3 25/62] acpi/table: Introduce acpi_get_entry to get specified entry
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

When constructing MADT table for Dom0, it needs to create GICC subtable
according to the dom0_max_vcpus. This function could be used for get the
specified entry.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/drivers/acpi/tables.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
 xen/include/xen/acpi.h    |  4 ++++
 2 files changed, 49 insertions(+)

diff --git a/xen/drivers/acpi/tables.c b/xen/drivers/acpi/tables.c
index 2fba206..3ba8bad 100644
--- a/xen/drivers/acpi/tables.c
+++ b/xen/drivers/acpi/tables.c
@@ -221,6 +221,51 @@ void __init acpi_table_print_madt_entry(struct acpi_subtable_header *header)
 	}
 }
 
+struct acpi_subtable_header * __init
+acpi_get_entry(char *id, unsigned long table_size,
+	       struct acpi_table_header *table_header, int entry_id,
+	       unsigned int entry_index)
+{
+	struct acpi_subtable_header *entry;
+	unsigned int count = 0;
+	unsigned long table_end;
+
+	if ( !table_size )
+		return NULL;
+
+	if ( !table_header )
+	{
+		printk("Table header not present\n");
+		return NULL;
+	}
+
+	table_end = (unsigned long)table_header + table_header->length;
+
+	/* Parse all entries looking for a match. */
+	entry = (struct acpi_subtable_header *)
+	    ((unsigned long)table_header + table_size);
+
+	while (((unsigned long)entry) + sizeof(struct acpi_subtable_header) <
+	       table_end) {
+		if (entry->length < sizeof(*entry)) {
+			printk(KERN_ERR PREFIX "[%4.4s:%#x] Invalid length\n",
+			       id, entry_id);
+			return NULL;
+		}
+
+		if (entry->type == entry_id) {
+			if (count == entry_index)
+				return entry;
+			count++;
+		}
+
+		entry = (struct acpi_subtable_header *)
+		    ((unsigned long)entry + entry->length);
+	}
+
+	return NULL;
+}
+
 int __init
 acpi_parse_entries(char *id,
 		      unsigned long table_size,
diff --git a/xen/include/xen/acpi.h b/xen/include/xen/acpi.h
index 23f8261..3339374 100644
--- a/xen/include/xen/acpi.h
+++ b/xen/include/xen/acpi.h
@@ -72,6 +72,10 @@ int acpi_table_init (void);
 int acpi_table_parse(char *id, acpi_table_handler handler);
 int acpi_table_parse_entries(char *id, unsigned long table_size,
 	int entry_id, acpi_table_entry_handler handler, unsigned int max_entries);
+struct acpi_subtable_header *
+acpi_get_entry(char *id, unsigned long table_size,
+	       struct acpi_table_header *table_header, int entry_id,
+	       unsigned int entry_index);
 int acpi_parse_entries(char *id, unsigned long table_size,
 	acpi_table_entry_handler handler, struct acpi_table_header *table_header,
 	int entry_id, unsigned int max_entries);
-- 
2.1.0

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

* [PATCH v3 26/62] arm/gic-v2: Add ACPI boot support for GICv2
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

ACPI on Xen hypervisor uses MADT table for proper GIC initialization.
First get the GIC version from GIC Distributor. Then parse GIC related
subtables, collect CPU interface and distributor addresses and call
driver initialization function (which is hardware abstraction agnostic).
In a similar way, FDT initialize GICv2.

Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
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>
---
 xen/arch/arm/gic-v2.c | 122 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 121 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
index e31d38e..9a9fcd5 100644
--- a/xen/arch/arm/gic-v2.c
+++ b/xen/arch/arm/gic-v2.c
@@ -29,6 +29,8 @@
 #include <xen/device_tree.h>
 #include <xen/libfdt/libfdt.h>
 #include <xen/sizes.h>
+#include <xen/acpi.h>
+#include <acpi/actables.h>
 #include <asm/p2m.h>
 #include <asm/domain.h>
 #include <asm/platform.h>
@@ -36,6 +38,7 @@
 
 #include <asm/io.h>
 #include <asm/gic.h>
+#include <asm/acpi.h>
 
 /*
  * LR register definitions are GIC v2 specific.
@@ -681,11 +684,113 @@ static void __init dt_gicv2_init(void)
                csize, vsize);
 }
 
+#ifdef CONFIG_ACPI
+static int __init
+gic_acpi_parse_madt_cpu(struct acpi_subtable_header *header,
+                        const unsigned long end)
+{
+    static int cpu_base_assigned = 0;
+    struct acpi_madt_generic_interrupt *processor;
+
+    processor = (struct acpi_madt_generic_interrupt *)header;
+
+    if ( BAD_MADT_ENTRY(processor, end) )
+        return -EINVAL;
+
+    /* Read from APIC table and fill up the GIC variables */
+    if ( cpu_base_assigned == 0 )
+    {
+        cbase = processor->base_address;
+        csize = SZ_8K;
+        hbase = processor->gich_base_address;
+        vbase = processor->gicv_base_address;
+        gicv2_info.maintenance_irq = processor->vgic_interrupt;
+
+        if( processor->flags & ACPI_MADT_VGIC_IRQ_MODE )
+            irq_set_type(gicv2_info.maintenance_irq, ACPI_IRQ_TYPE_EDGE_BOTH);
+        else
+            irq_set_type(gicv2_info.maintenance_irq, ACPI_IRQ_TYPE_LEVEL_MASK);
+
+	cpu_base_assigned = 1;
+    }
+    else
+    {
+        if ( cbase != processor->base_address
+             || hbase != processor->gich_base_address
+             || vbase != processor->gicv_base_address
+             || gicv2_info.maintenance_irq != processor->vgic_interrupt )
+        {
+	    printk("GICv2: GICC entries are not same in MADT table\n");
+	    return -EINVAL;
+        }
+    }
+
+    return 0;
+}
+
+static int __init
+gic_acpi_parse_madt_distributor(struct acpi_subtable_header *header,
+                                const unsigned long end)
+{
+    struct acpi_madt_generic_distributor *dist;
+
+    dist = (struct acpi_madt_generic_distributor *)header;
+
+    if ( BAD_MADT_ENTRY(dist, end) )
+        return -EINVAL;
+
+    dbase = dist->base_address;
+
+    return 0;
+}
+
+static void __init acpi_gicv2_init(void)
+{
+    acpi_status status;
+    struct acpi_table_header *table;
+    int count;
+
+    status = acpi_get_table(ACPI_SIG_MADT, 0, &table);
+
+    if ( ACPI_FAILURE(status) )
+    {
+        const char *msg = acpi_format_exception(status);
+
+        panic("GICv2: Failed to get MADT table, %s", msg);
+    }
+
+    /* Collect CPU base addresses */
+    count = acpi_parse_entries(ACPI_SIG_MADT, sizeof(struct acpi_table_madt),
+                               gic_acpi_parse_madt_cpu, table,
+                               ACPI_MADT_TYPE_GENERIC_INTERRUPT, 0);
+    if ( count <= 0 )
+        panic("GICv2: No valid GICC entries exists");
+
+    /*
+     * Find distributor base address. We expect one distributor entry since
+     * ACPI 5.0 spec neither support multi-GIC instances nor GIC cascade.
+     */
+    count = acpi_parse_entries(ACPI_SIG_MADT, sizeof(struct acpi_table_madt),
+                               gic_acpi_parse_madt_distributor, table,
+                               ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR, 0);
+    if ( count <= 0 )
+        panic("GICv2: No valid GICD entries exists");
+}
+#else
+static void __init acpi_gicv2_init(void)
+{
+/* Should never reach here */
+}
+#endif
+
 static int __init gicv2_init(void)
 {
     uint32_t aliased_offset = 0;
 
-    dt_gicv2_init();
+    if( acpi_disabled )
+        dt_gicv2_init();
+    else
+        acpi_gicv2_init();
 
     printk("GICv2 initialization:\n"
               "        gic_dist_addr=%"PRIpaddr"\n"
@@ -793,6 +898,21 @@ DT_DEVICE_START(gicv2, "GICv2", DEVICE_GIC)
         .init = dt_gicv2_preinit,
 DT_DEVICE_END
 
+#ifdef CONFIG_ACPI
+/* Set up the GIC */
+static int __init acpi_gicv2_preinit(const void *data)
+{
+    gicv2_info.hw_version = GIC_V2;
+    register_gic_ops(&gicv2_ops);
+
+    return 0;
+}
+
+ACPI_DEVICE_START(agicv2, "GICv2", DEVICE_GIC)
+        .class_type = GIC_V2,
+        .init = acpi_gicv2_preinit,
+ACPI_DEVICE_END
+#endif
 /*
  * Local variables:
  * mode: C
-- 
2.1.0

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

* [PATCH v3 26/62] arm/gic-v2: Add ACPI boot support for GICv2
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

ACPI on Xen hypervisor uses MADT table for proper GIC initialization.
First get the GIC version from GIC Distributor. Then parse GIC related
subtables, collect CPU interface and distributor addresses and call
driver initialization function (which is hardware abstraction agnostic).
In a similar way, FDT initialize GICv2.

Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
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>
---
 xen/arch/arm/gic-v2.c | 122 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 121 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
index e31d38e..9a9fcd5 100644
--- a/xen/arch/arm/gic-v2.c
+++ b/xen/arch/arm/gic-v2.c
@@ -29,6 +29,8 @@
 #include <xen/device_tree.h>
 #include <xen/libfdt/libfdt.h>
 #include <xen/sizes.h>
+#include <xen/acpi.h>
+#include <acpi/actables.h>
 #include <asm/p2m.h>
 #include <asm/domain.h>
 #include <asm/platform.h>
@@ -36,6 +38,7 @@
 
 #include <asm/io.h>
 #include <asm/gic.h>
+#include <asm/acpi.h>
 
 /*
  * LR register definitions are GIC v2 specific.
@@ -681,11 +684,113 @@ static void __init dt_gicv2_init(void)
                csize, vsize);
 }
 
+#ifdef CONFIG_ACPI
+static int __init
+gic_acpi_parse_madt_cpu(struct acpi_subtable_header *header,
+                        const unsigned long end)
+{
+    static int cpu_base_assigned = 0;
+    struct acpi_madt_generic_interrupt *processor;
+
+    processor = (struct acpi_madt_generic_interrupt *)header;
+
+    if ( BAD_MADT_ENTRY(processor, end) )
+        return -EINVAL;
+
+    /* Read from APIC table and fill up the GIC variables */
+    if ( cpu_base_assigned == 0 )
+    {
+        cbase = processor->base_address;
+        csize = SZ_8K;
+        hbase = processor->gich_base_address;
+        vbase = processor->gicv_base_address;
+        gicv2_info.maintenance_irq = processor->vgic_interrupt;
+
+        if( processor->flags & ACPI_MADT_VGIC_IRQ_MODE )
+            irq_set_type(gicv2_info.maintenance_irq, ACPI_IRQ_TYPE_EDGE_BOTH);
+        else
+            irq_set_type(gicv2_info.maintenance_irq, ACPI_IRQ_TYPE_LEVEL_MASK);
+
+	cpu_base_assigned = 1;
+    }
+    else
+    {
+        if ( cbase != processor->base_address
+             || hbase != processor->gich_base_address
+             || vbase != processor->gicv_base_address
+             || gicv2_info.maintenance_irq != processor->vgic_interrupt )
+        {
+	    printk("GICv2: GICC entries are not same in MADT table\n");
+	    return -EINVAL;
+        }
+    }
+
+    return 0;
+}
+
+static int __init
+gic_acpi_parse_madt_distributor(struct acpi_subtable_header *header,
+                                const unsigned long end)
+{
+    struct acpi_madt_generic_distributor *dist;
+
+    dist = (struct acpi_madt_generic_distributor *)header;
+
+    if ( BAD_MADT_ENTRY(dist, end) )
+        return -EINVAL;
+
+    dbase = dist->base_address;
+
+    return 0;
+}
+
+static void __init acpi_gicv2_init(void)
+{
+    acpi_status status;
+    struct acpi_table_header *table;
+    int count;
+
+    status = acpi_get_table(ACPI_SIG_MADT, 0, &table);
+
+    if ( ACPI_FAILURE(status) )
+    {
+        const char *msg = acpi_format_exception(status);
+
+        panic("GICv2: Failed to get MADT table, %s", msg);
+    }
+
+    /* Collect CPU base addresses */
+    count = acpi_parse_entries(ACPI_SIG_MADT, sizeof(struct acpi_table_madt),
+                               gic_acpi_parse_madt_cpu, table,
+                               ACPI_MADT_TYPE_GENERIC_INTERRUPT, 0);
+    if ( count <= 0 )
+        panic("GICv2: No valid GICC entries exists");
+
+    /*
+     * Find distributor base address. We expect one distributor entry since
+     * ACPI 5.0 spec neither support multi-GIC instances nor GIC cascade.
+     */
+    count = acpi_parse_entries(ACPI_SIG_MADT, sizeof(struct acpi_table_madt),
+                               gic_acpi_parse_madt_distributor, table,
+                               ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR, 0);
+    if ( count <= 0 )
+        panic("GICv2: No valid GICD entries exists");
+}
+#else
+static void __init acpi_gicv2_init(void)
+{
+/* Should never reach here */
+}
+#endif
+
 static int __init gicv2_init(void)
 {
     uint32_t aliased_offset = 0;
 
-    dt_gicv2_init();
+    if( acpi_disabled )
+        dt_gicv2_init();
+    else
+        acpi_gicv2_init();
 
     printk("GICv2 initialization:\n"
               "        gic_dist_addr=%"PRIpaddr"\n"
@@ -793,6 +898,21 @@ DT_DEVICE_START(gicv2, "GICv2", DEVICE_GIC)
         .init = dt_gicv2_preinit,
 DT_DEVICE_END
 
+#ifdef CONFIG_ACPI
+/* Set up the GIC */
+static int __init acpi_gicv2_preinit(const void *data)
+{
+    gicv2_info.hw_version = GIC_V2;
+    register_gic_ops(&gicv2_ops);
+
+    return 0;
+}
+
+ACPI_DEVICE_START(agicv2, "GICv2", DEVICE_GIC)
+        .class_type = GIC_V2,
+        .init = acpi_gicv2_preinit,
+ACPI_DEVICE_END
+#endif
 /*
  * Local variables:
  * mode: C
-- 
2.1.0

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

* [PATCH v3 27/62] arm/gic-v3: Add ACPI boot support for GICv3
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

Like GICv2, ACPI on Xen hypervisor uses MADT table for proper GICv3
initialization. Parse GIC distributor subtable, redistributor subtable
and interrupt subtable.

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

diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
index bd13010..fa732d7 100644
--- a/xen/arch/arm/gic-v3.c
+++ b/xen/arch/arm/gic-v3.c
@@ -34,6 +34,8 @@
 #include <xen/sizes.h>
 #include <xen/libfdt/libfdt.h>
 #include <xen/sort.h>
+#include <xen/acpi.h>
+#include <acpi/actables.h>
 #include <asm/p2m.h>
 #include <asm/domain.h>
 #include <asm/io.h>
@@ -41,6 +43,7 @@
 #include <asm/gic.h>
 #include <asm/gic_v3_defs.h>
 #include <asm/cpufeature.h>
+#include <asm/acpi.h>
 
 /* Global state */
 static struct {
@@ -1242,6 +1245,164 @@ static void __init dt_gicv3_init(void)
     }
 }
 
+#ifdef CONFIG_ACPI
+static int __init
+gic_acpi_parse_madt_cpu(struct acpi_subtable_header *header,
+                        const unsigned long end)
+{
+    static bool cpu_base_assigned = false;
+    struct acpi_madt_generic_interrupt *processor;
+
+    processor = (struct acpi_madt_generic_interrupt *)header;
+
+    if ( BAD_MADT_ENTRY(processor, end) )
+        return -EINVAL;
+
+    /* Read from APIC table and fill up the GIC variables */
+    if ( !cpu_base_assigned )
+    {
+        cbase = processor->base_address;
+        csize = SZ_8K;
+        vbase = processor->gicv_base_address;
+        gicv3_info.maintenance_irq = processor->vgic_interrupt;
+
+        if( processor->flags & ACPI_MADT_VGIC_IRQ_MODE )
+            irq_set_type(gicv3_info.maintenance_irq, ACPI_IRQ_TYPE_EDGE_BOTH);
+        else
+            irq_set_type(gicv3_info.maintenance_irq, ACPI_IRQ_TYPE_LEVEL_MASK);
+
+	cpu_base_assigned = true;
+    }
+    else
+    {
+        if ( cbase != processor->base_address
+             || vbase != processor->gicv_base_address
+             || gicv3_info.maintenance_irq != processor->vgic_interrupt )
+        {
+	    printk("GICv3: GICC entries are not same in MADT table\n");
+	    return -EINVAL;
+        }
+    }
+
+    return 0;
+}
+
+static int __init
+gic_acpi_parse_madt_distributor(struct acpi_subtable_header *header,
+                                const unsigned long end)
+{
+    struct acpi_madt_generic_distributor *dist;
+
+    dist = (struct acpi_madt_generic_distributor *)header;
+
+    if ( BAD_MADT_ENTRY(dist, end) )
+        return -EINVAL;
+
+    dbase = dist->base_address;
+
+    return 0;
+}
+static int __init
+gic_acpi_get_madt_redistributor_num(struct acpi_subtable_header *header,
+                                    const unsigned long end)
+{
+    return 0;
+}
+
+static void __init acpi_gicv3_init(void)
+{
+    struct acpi_table_header *table;
+    struct rdist_region *rdist_regs;
+    acpi_status status;
+    int count, i;
+    uint32_t reg;
+
+    status = acpi_get_table(ACPI_SIG_MADT, 0, &table);
+
+    if ( ACPI_FAILURE(status) )
+    {
+        const char *msg = acpi_format_exception(status);
+
+        panic("GICv3: Failed to get MADT table, %s", msg);
+    }
+
+    /*
+     * Find distributor base address. We expect one distributor entry since
+     * ACPI 5.0 spec neither support multi-GIC instances nor GIC cascade.
+     */
+    count = acpi_parse_entries(ACPI_SIG_MADT, sizeof(struct acpi_table_madt),
+                               gic_acpi_parse_madt_distributor, table,
+                               ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR, 0);
+
+    if ( count <= 0 )
+        panic("GICv3: No valid GICD entries exists");
+
+    if ( (dbase & ~PAGE_MASK) )
+        panic("GICv3: Found unaligned distributor address %"PRIpaddr"",
+              dbase);
+
+    gicv3.map_dbase = ioremap_nocache(dbase, SZ_64K);
+    if ( !gicv3.map_dbase )
+        panic("GICv3: Failed to ioremap for GIC distributor\n");
+
+    reg = readl_relaxed(GICD + GICD_PIDR2) & GIC_PIDR2_ARCH_MASK;
+    if ( reg != GIC_PIDR2_ARCH_GICv3 )
+         panic("GICv3: no distributor detected\n");
+
+    /* Get number of redistributor */
+    count = acpi_parse_entries(ACPI_SIG_MADT, sizeof(struct acpi_table_madt),
+                               gic_acpi_get_madt_redistributor_num, table,
+                               ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR, 0);
+    if ( count <= 0 )
+        panic("GICv3: No valid GICR entries exists");
+
+    gicv3.rdist_count = count;
+
+    if ( gicv3.rdist_count > MAX_RDIST_COUNT )
+        panic("GICv3: Number of redistributor regions is more than"
+              "%d (Increase MAX_RDIST_COUNT!!)\n", MAX_RDIST_COUNT);
+
+    rdist_regs = xzalloc_array(struct rdist_region, gicv3.rdist_count);
+    if ( !rdist_regs )
+        panic("GICv3: Failed to allocate memory for rdist regions\n");
+
+    for ( i = 0; i < gicv3.rdist_count; i++ )
+    {
+        struct acpi_subtable_header *subtable;
+        struct acpi_madt_generic_redistributor *gic_rdist;
+
+        subtable = acpi_get_entry(ACPI_SIG_MADT, sizeof(struct acpi_table_madt),
+                                  table, ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR,
+                                  i);
+        if ( !subtable )
+            panic("GICv3: Can't get GICR entry");
+
+	gic_rdist = (struct acpi_madt_generic_redistributor *)subtable;
+        rdist_regs[i].base = gic_rdist->base_address;
+        rdist_regs[i].size = gic_rdist->length;
+    }
+
+    /* The vGIC code requires the region to be sorted */
+    sort(rdist_regs, gicv3.rdist_count, sizeof(*rdist_regs), cmp_rdist, NULL);
+
+    gicv3.rdist_regions= rdist_regs;
+
+    /* Collect CPU base addresses */
+    count = acpi_parse_entries(ACPI_SIG_MADT, sizeof(struct acpi_table_madt),
+                               gic_acpi_parse_madt_cpu, table,
+                               ACPI_MADT_TYPE_GENERIC_INTERRUPT, 0);
+    if ( count <= 0 )
+        panic("GICv3: No valid GICC entries exists");
+
+    gicv3.rdist_stride = 0;
+}
+#else
+static void __init acpi_gicv3_init(void)
+{
+/* Should never reach here */
+}
+#endif
+
 /* Set up the GIC */
 static int __init gicv3_init(void)
 {
@@ -1253,7 +1414,10 @@ static int __init gicv3_init(void)
         return -ENODEV;
     }
 
-    dt_gicv3_init();
+    if( acpi_disabled )
+        dt_gicv3_init();
+    else
+        acpi_gicv3_init();
 
     for ( i = 0; i < gicv3.rdist_count; i++ )
     {
@@ -1345,6 +1509,22 @@ DT_DEVICE_START(gicv3, "GICv3", DEVICE_GIC)
         .init = dt_gicv3_preinit,
 DT_DEVICE_END
 
+#ifdef CONFIG_ACPI
+/* Set up the GIC */
+static int __init acpi_gicv3_preinit(const void *data)
+{
+    gicv3_info.hw_version = GIC_V3;
+    register_gic_ops(&gicv3_ops);
+
+    return 0;
+}
+
+ACPI_DEVICE_START(agicv3, "GICv3", DEVICE_GIC)
+        .class_type = GIC_V3,
+        .init = acpi_gicv3_preinit,
+ACPI_DEVICE_END
+#endif
+
 /*
  * Local variables:
  * mode: C
-- 
2.1.0

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

* [PATCH v3 27/62] arm/gic-v3: Add ACPI boot support for GICv3
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

Like GICv2, ACPI on Xen hypervisor uses MADT table for proper GICv3
initialization. Parse GIC distributor subtable, redistributor subtable
and interrupt subtable.

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

diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
index bd13010..fa732d7 100644
--- a/xen/arch/arm/gic-v3.c
+++ b/xen/arch/arm/gic-v3.c
@@ -34,6 +34,8 @@
 #include <xen/sizes.h>
 #include <xen/libfdt/libfdt.h>
 #include <xen/sort.h>
+#include <xen/acpi.h>
+#include <acpi/actables.h>
 #include <asm/p2m.h>
 #include <asm/domain.h>
 #include <asm/io.h>
@@ -41,6 +43,7 @@
 #include <asm/gic.h>
 #include <asm/gic_v3_defs.h>
 #include <asm/cpufeature.h>
+#include <asm/acpi.h>
 
 /* Global state */
 static struct {
@@ -1242,6 +1245,164 @@ static void __init dt_gicv3_init(void)
     }
 }
 
+#ifdef CONFIG_ACPI
+static int __init
+gic_acpi_parse_madt_cpu(struct acpi_subtable_header *header,
+                        const unsigned long end)
+{
+    static bool cpu_base_assigned = false;
+    struct acpi_madt_generic_interrupt *processor;
+
+    processor = (struct acpi_madt_generic_interrupt *)header;
+
+    if ( BAD_MADT_ENTRY(processor, end) )
+        return -EINVAL;
+
+    /* Read from APIC table and fill up the GIC variables */
+    if ( !cpu_base_assigned )
+    {
+        cbase = processor->base_address;
+        csize = SZ_8K;
+        vbase = processor->gicv_base_address;
+        gicv3_info.maintenance_irq = processor->vgic_interrupt;
+
+        if( processor->flags & ACPI_MADT_VGIC_IRQ_MODE )
+            irq_set_type(gicv3_info.maintenance_irq, ACPI_IRQ_TYPE_EDGE_BOTH);
+        else
+            irq_set_type(gicv3_info.maintenance_irq, ACPI_IRQ_TYPE_LEVEL_MASK);
+
+	cpu_base_assigned = true;
+    }
+    else
+    {
+        if ( cbase != processor->base_address
+             || vbase != processor->gicv_base_address
+             || gicv3_info.maintenance_irq != processor->vgic_interrupt )
+        {
+	    printk("GICv3: GICC entries are not same in MADT table\n");
+	    return -EINVAL;
+        }
+    }
+
+    return 0;
+}
+
+static int __init
+gic_acpi_parse_madt_distributor(struct acpi_subtable_header *header,
+                                const unsigned long end)
+{
+    struct acpi_madt_generic_distributor *dist;
+
+    dist = (struct acpi_madt_generic_distributor *)header;
+
+    if ( BAD_MADT_ENTRY(dist, end) )
+        return -EINVAL;
+
+    dbase = dist->base_address;
+
+    return 0;
+}
+static int __init
+gic_acpi_get_madt_redistributor_num(struct acpi_subtable_header *header,
+                                    const unsigned long end)
+{
+    return 0;
+}
+
+static void __init acpi_gicv3_init(void)
+{
+    struct acpi_table_header *table;
+    struct rdist_region *rdist_regs;
+    acpi_status status;
+    int count, i;
+    uint32_t reg;
+
+    status = acpi_get_table(ACPI_SIG_MADT, 0, &table);
+
+    if ( ACPI_FAILURE(status) )
+    {
+        const char *msg = acpi_format_exception(status);
+
+        panic("GICv3: Failed to get MADT table, %s", msg);
+    }
+
+    /*
+     * Find distributor base address. We expect one distributor entry since
+     * ACPI 5.0 spec neither support multi-GIC instances nor GIC cascade.
+     */
+    count = acpi_parse_entries(ACPI_SIG_MADT, sizeof(struct acpi_table_madt),
+                               gic_acpi_parse_madt_distributor, table,
+                               ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR, 0);
+
+    if ( count <= 0 )
+        panic("GICv3: No valid GICD entries exists");
+
+    if ( (dbase & ~PAGE_MASK) )
+        panic("GICv3: Found unaligned distributor address %"PRIpaddr"",
+              dbase);
+
+    gicv3.map_dbase = ioremap_nocache(dbase, SZ_64K);
+    if ( !gicv3.map_dbase )
+        panic("GICv3: Failed to ioremap for GIC distributor\n");
+
+    reg = readl_relaxed(GICD + GICD_PIDR2) & GIC_PIDR2_ARCH_MASK;
+    if ( reg != GIC_PIDR2_ARCH_GICv3 )
+         panic("GICv3: no distributor detected\n");
+
+    /* Get number of redistributor */
+    count = acpi_parse_entries(ACPI_SIG_MADT, sizeof(struct acpi_table_madt),
+                               gic_acpi_get_madt_redistributor_num, table,
+                               ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR, 0);
+    if ( count <= 0 )
+        panic("GICv3: No valid GICR entries exists");
+
+    gicv3.rdist_count = count;
+
+    if ( gicv3.rdist_count > MAX_RDIST_COUNT )
+        panic("GICv3: Number of redistributor regions is more than"
+              "%d (Increase MAX_RDIST_COUNT!!)\n", MAX_RDIST_COUNT);
+
+    rdist_regs = xzalloc_array(struct rdist_region, gicv3.rdist_count);
+    if ( !rdist_regs )
+        panic("GICv3: Failed to allocate memory for rdist regions\n");
+
+    for ( i = 0; i < gicv3.rdist_count; i++ )
+    {
+        struct acpi_subtable_header *subtable;
+        struct acpi_madt_generic_redistributor *gic_rdist;
+
+        subtable = acpi_get_entry(ACPI_SIG_MADT, sizeof(struct acpi_table_madt),
+                                  table, ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR,
+                                  i);
+        if ( !subtable )
+            panic("GICv3: Can't get GICR entry");
+
+	gic_rdist = (struct acpi_madt_generic_redistributor *)subtable;
+        rdist_regs[i].base = gic_rdist->base_address;
+        rdist_regs[i].size = gic_rdist->length;
+    }
+
+    /* The vGIC code requires the region to be sorted */
+    sort(rdist_regs, gicv3.rdist_count, sizeof(*rdist_regs), cmp_rdist, NULL);
+
+    gicv3.rdist_regions= rdist_regs;
+
+    /* Collect CPU base addresses */
+    count = acpi_parse_entries(ACPI_SIG_MADT, sizeof(struct acpi_table_madt),
+                               gic_acpi_parse_madt_cpu, table,
+                               ACPI_MADT_TYPE_GENERIC_INTERRUPT, 0);
+    if ( count <= 0 )
+        panic("GICv3: No valid GICC entries exists");
+
+    gicv3.rdist_stride = 0;
+}
+#else
+static void __init acpi_gicv3_init(void)
+{
+/* Should never reach here */
+}
+#endif
+
 /* Set up the GIC */
 static int __init gicv3_init(void)
 {
@@ -1253,7 +1414,10 @@ static int __init gicv3_init(void)
         return -ENODEV;
     }
 
-    dt_gicv3_init();
+    if( acpi_disabled )
+        dt_gicv3_init();
+    else
+        acpi_gicv3_init();
 
     for ( i = 0; i < gicv3.rdist_count; i++ )
     {
@@ -1345,6 +1509,22 @@ DT_DEVICE_START(gicv3, "GICv3", DEVICE_GIC)
         .init = dt_gicv3_preinit,
 DT_DEVICE_END
 
+#ifdef CONFIG_ACPI
+/* Set up the GIC */
+static int __init acpi_gicv3_preinit(const void *data)
+{
+    gicv3_info.hw_version = GIC_V3;
+    register_gic_ops(&gicv3_ops);
+
+    return 0;
+}
+
+ACPI_DEVICE_START(agicv3, "GICv3", DEVICE_GIC)
+        .class_type = GIC_V3,
+        .init = acpi_gicv3_preinit,
+ACPI_DEVICE_END
+#endif
+
 /*
  * Local variables:
  * mode: C
-- 
2.1.0

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

* [PATCH v3 28/62] arm/gic: Add ACPI support for GIC preinit
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

Since ACPI 6.0 defines that GIC Distributor Structure contains the GIC
version filed, it could get GIC version from that. According to the
version, call different preinit functions.

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

diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c
index 1e1e5ba..ac82588 100644
--- a/xen/arch/arm/gic.c
+++ b/xen/arch/arm/gic.c
@@ -27,6 +27,7 @@
 #include <xen/softirq.h>
 #include <xen/list.h>
 #include <xen/device_tree.h>
+#include <xen/acpi.h>
 #include <asm/p2m.h>
 #include <asm/domain.h>
 #include <asm/platform.h>
@@ -34,6 +35,7 @@
 #include <asm/io.h>
 #include <asm/gic.h>
 #include <asm/vgic.h>
+#include <asm/acpi.h>
 
 static void gic_restore_pending_irqs(struct vcpu *v);
 
@@ -228,10 +230,7 @@ int gic_irq_xlate(const u32 *intspec, unsigned int intsize,
     return 0;
 }
 
-/* Find the interrupt controller and set up the callback to translate
- * device tree IRQ.
- */
-void __init gic_preinit(void)
+void __init dt_gic_preinit(void)
 {
     int rc;
     struct dt_device_node *node;
@@ -261,6 +260,54 @@ void __init gic_preinit(void)
     dt_device_set_used_by(node, DOMID_XEN);
 }
 
+#ifdef CONFIG_ACPI
+static void __init acpi_gic_preinit(void)
+{
+    int rc = 0;
+    acpi_status status;
+    struct acpi_table_header *table;
+    struct acpi_subtable_header * subtable;
+    struct acpi_madt_generic_distributor *dist;
+
+    status = acpi_get_table(ACPI_SIG_MADT, 0, &table);
+    if ( ACPI_FAILURE(status) )
+    {
+        const char *msg = acpi_format_exception(status);
+
+        panic("Failed to get MADT table, %s", msg);
+    }
+
+    subtable = acpi_get_entry(ACPI_SIG_MADT, sizeof(struct acpi_table_madt),
+                              table, ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR, 0);
+    if ( !subtable )
+        panic("No valid GICD entries exists");
+
+    dist = (struct acpi_madt_generic_distributor *)subtable;
+
+    if ( dist->version == ACPI_MADT_GIC_VERSION_V2 )
+        rc = acpi_device_init(DEVICE_GIC, NULL, GIC_V2);
+    else if ( dist->version == ACPI_MADT_GIC_VERSION_V3 )
+        rc = acpi_device_init(DEVICE_GIC, NULL, GIC_V3);
+    else
+        panic("Wrong GIC version or unsupported GIC");
+    if ( rc )
+        panic("Unable to find compatible GIC in the ACPI table");
+}
+#else
+static void __init acpi_gic_preinit(void) {}
+#endif
+
+/* Find the interrupt controller and set up the callback to translate
+ * device tree IRQ.
+ */
+void __init gic_preinit(void)
+{
+    if( acpi_disabled )
+        dt_gic_preinit();
+    else
+        acpi_gic_preinit();
+}
+
 /* Set up the GIC */
 void __init gic_init(void)
 {
-- 
2.1.0

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

* [PATCH v3 28/62] arm/gic: Add ACPI support for GIC preinit
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

Since ACPI 6.0 defines that GIC Distributor Structure contains the GIC
version filed, it could get GIC version from that. According to the
version, call different preinit functions.

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

diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c
index 1e1e5ba..ac82588 100644
--- a/xen/arch/arm/gic.c
+++ b/xen/arch/arm/gic.c
@@ -27,6 +27,7 @@
 #include <xen/softirq.h>
 #include <xen/list.h>
 #include <xen/device_tree.h>
+#include <xen/acpi.h>
 #include <asm/p2m.h>
 #include <asm/domain.h>
 #include <asm/platform.h>
@@ -34,6 +35,7 @@
 #include <asm/io.h>
 #include <asm/gic.h>
 #include <asm/vgic.h>
+#include <asm/acpi.h>
 
 static void gic_restore_pending_irqs(struct vcpu *v);
 
@@ -228,10 +230,7 @@ int gic_irq_xlate(const u32 *intspec, unsigned int intsize,
     return 0;
 }
 
-/* Find the interrupt controller and set up the callback to translate
- * device tree IRQ.
- */
-void __init gic_preinit(void)
+void __init dt_gic_preinit(void)
 {
     int rc;
     struct dt_device_node *node;
@@ -261,6 +260,54 @@ void __init gic_preinit(void)
     dt_device_set_used_by(node, DOMID_XEN);
 }
 
+#ifdef CONFIG_ACPI
+static void __init acpi_gic_preinit(void)
+{
+    int rc = 0;
+    acpi_status status;
+    struct acpi_table_header *table;
+    struct acpi_subtable_header * subtable;
+    struct acpi_madt_generic_distributor *dist;
+
+    status = acpi_get_table(ACPI_SIG_MADT, 0, &table);
+    if ( ACPI_FAILURE(status) )
+    {
+        const char *msg = acpi_format_exception(status);
+
+        panic("Failed to get MADT table, %s", msg);
+    }
+
+    subtable = acpi_get_entry(ACPI_SIG_MADT, sizeof(struct acpi_table_madt),
+                              table, ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR, 0);
+    if ( !subtable )
+        panic("No valid GICD entries exists");
+
+    dist = (struct acpi_madt_generic_distributor *)subtable;
+
+    if ( dist->version == ACPI_MADT_GIC_VERSION_V2 )
+        rc = acpi_device_init(DEVICE_GIC, NULL, GIC_V2);
+    else if ( dist->version == ACPI_MADT_GIC_VERSION_V3 )
+        rc = acpi_device_init(DEVICE_GIC, NULL, GIC_V3);
+    else
+        panic("Wrong GIC version or unsupported GIC");
+    if ( rc )
+        panic("Unable to find compatible GIC in the ACPI table");
+}
+#else
+static void __init acpi_gic_preinit(void) {}
+#endif
+
+/* Find the interrupt controller and set up the callback to translate
+ * device tree IRQ.
+ */
+void __init gic_preinit(void)
+{
+    if( acpi_disabled )
+        dt_gic_preinit();
+    else
+        acpi_gic_preinit();
+}
+
 /* Set up the GIC */
 void __init gic_init(void)
 {
-- 
2.1.0

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

* [PATCH v3 29/62] arm/acpi: Add GTDT support updated by ACPI 5.1
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

With ACPI 5.0, we got per-processor timer support in GTDT,
and ACPI 5.1 introduced the support for platform (memory-mapped)
timers: GT Block and SBSA watchdog timer, add the code needed
for the spec change.

Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
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>
---
 xen/include/acpi/actbl3.h  | 98 +++++++++++++++++++++++++++++++++++++++-------
 xen/include/asm-arm/acpi.h |  2 +
 2 files changed, 85 insertions(+), 15 deletions(-)

diff --git a/xen/include/acpi/actbl3.h b/xen/include/acpi/actbl3.h
index 8c61b5f..fc96963 100644
--- a/xen/include/acpi/actbl3.h
+++ b/xen/include/acpi/actbl3.h
@@ -241,33 +241,101 @@ struct acpi_s3pt_suspend {
 
 /*******************************************************************************
  *
- * GTDT - Generic Timer Description Table (ACPI 5.0)
- *        Version 1
+ * GTDT - Generic Timer Description Table (ACPI 5.1)
+ *        Version 2
  *
  ******************************************************************************/
 
 struct acpi_table_gtdt {
 	struct acpi_table_header header;	/* Common ACPI table header */
-	u64 address;
-	u32 flags;
-	u32 secure_pl1_interrupt;
-	u32 secure_pl1_flags;
-	u32 non_secure_pl1_interrupt;
-	u32 non_secure_pl1_flags;
+	u64 counter_block_addresss;
+	u32 reserved;
+	u32 secure_el1_interrupt;
+	u32 secure_el1_flags;
+	u32 non_secure_el1_interrupt;
+	u32 non_secure_el1_flags;
 	u32 virtual_timer_interrupt;
 	u32 virtual_timer_flags;
-	u32 non_secure_pl2_interrupt;
-	u32 non_secure_pl2_flags;
+	u32 non_secure_el2_interrupt;
+	u32 non_secure_el2_flags;
+	u64 counter_read_block_address;
+	u32 platform_timer_count;
+	u32 platform_timer_offset;
 };
 
-/* Values for Flags field above */
+/* Flag Definitions: Timer Block Physical Timers and Virtual timers */
+
+#define ACPI_GTDT_INTERRUPT_MODE        (1)
+#define ACPI_GTDT_INTERRUPT_POLARITY    (1<<1)
+#define ACPI_GTDT_ALWAYS_ON             (1<<2)
+
+/* Common GTDT subtable header */
+
+struct acpi_gtdt_header {
+	u8 type;
+	u16 length;
+};
+
+/* Values for GTDT subtable type above */
+
+enum acpi_gtdt_type {
+	ACPI_GTDT_TYPE_TIMER_BLOCK = 0,
+	ACPI_GTDT_TYPE_WATCHDOG = 1,
+	ACPI_GTDT_TYPE_RESERVED = 2	/* 2 and greater are reserved */
+};
+
+/* GTDT Subtables, correspond to Type in struct acpi_gtdt_header */
 
-#define ACPI_GTDT_MAPPED_BLOCK_PRESENT      1
+/* 0: Generic Timer Block */
+
+struct acpi_gtdt_timer_block {
+	struct acpi_gtdt_header header;
+	u8 reserved;
+	u64 block_address;
+	u32 timer_count;
+	u32 timer_offset;
+};
+
+/* Timer Sub-Structure, one per timer */
+
+struct acpi_gtdt_timer_entry {
+	u8 frame_number;
+	u8 reserved[3];
+	u64 base_address;
+	u64 el0_base_address;
+	u32 timer_interrupt;
+	u32 timer_flags;
+	u32 virtual_timer_interrupt;
+	u32 virtual_timer_flags;
+	u32 common_flags;
+};
+
+/* Flag Definitions: timer_flags and virtual_timer_flags above */
+
+#define ACPI_GTDT_GT_IRQ_MODE               (1)
+#define ACPI_GTDT_GT_IRQ_POLARITY           (1<<1)
+
+/* Flag Definitions: common_flags above */
+
+#define ACPI_GTDT_GT_IS_SECURE_TIMER        (1)
+#define ACPI_GTDT_GT_ALWAYS_ON              (1<<1)
+
+/* 1: SBSA Generic Watchdog Structure */
+
+struct acpi_gtdt_watchdog {
+	struct acpi_gtdt_header header;
+	u8 reserved;
+	u64 refresh_frame_address;
+	u64 control_frame_address;
+	u32 timer_interrupt;
+	u32 timer_flags;
+};
 
-/* Values for all "TimerFlags" fields above */
+/* Flag Definitions: timer_flags above */
 
-#define ACPI_GTDT_INTERRUPT_MODE            1
-#define ACPI_GTDT_INTERRUPT_POLARITY        2
+#define ACPI_GTDT_WATCHDOG_IRQ_MODE         (1)
+#define ACPI_GTDT_WATCHDOG_IRQ_POLARITY     (1<<1)
+#define ACPI_GTDT_WATCHDOG_SECURE           (1<<2)
 
 /*******************************************************************************
  *
diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
index 1efa29d..714e596 100644
--- a/xen/include/asm-arm/acpi.h
+++ b/xen/include/asm-arm/acpi.h
@@ -46,4 +46,6 @@ static inline void disable_acpi(void)
     acpi_disabled = 1;
 }
 
+#define ACPI_GTDT_INTR_MASK ( ACPI_GTDT_INTERRUPT_MODE | ACPI_GTDT_INTERRUPT_POLARITY )
+
 #endif /*_ASM_ARM_ACPI_H*/
-- 
2.1.0

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

* [PATCH v3 29/62] arm/acpi: Add GTDT support updated by ACPI 5.1
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

With ACPI 5.0, we got per-processor timer support in GTDT,
and ACPI 5.1 introduced the support for platform (memory-mapped)
timers: GT Block and SBSA watchdog timer, add the code needed
for the spec change.

Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
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>
---
 xen/include/acpi/actbl3.h  | 98 +++++++++++++++++++++++++++++++++++++++-------
 xen/include/asm-arm/acpi.h |  2 +
 2 files changed, 85 insertions(+), 15 deletions(-)

diff --git a/xen/include/acpi/actbl3.h b/xen/include/acpi/actbl3.h
index 8c61b5f..fc96963 100644
--- a/xen/include/acpi/actbl3.h
+++ b/xen/include/acpi/actbl3.h
@@ -241,33 +241,101 @@ struct acpi_s3pt_suspend {
 
 /*******************************************************************************
  *
- * GTDT - Generic Timer Description Table (ACPI 5.0)
- *        Version 1
+ * GTDT - Generic Timer Description Table (ACPI 5.1)
+ *        Version 2
  *
  ******************************************************************************/
 
 struct acpi_table_gtdt {
 	struct acpi_table_header header;	/* Common ACPI table header */
-	u64 address;
-	u32 flags;
-	u32 secure_pl1_interrupt;
-	u32 secure_pl1_flags;
-	u32 non_secure_pl1_interrupt;
-	u32 non_secure_pl1_flags;
+	u64 counter_block_addresss;
+	u32 reserved;
+	u32 secure_el1_interrupt;
+	u32 secure_el1_flags;
+	u32 non_secure_el1_interrupt;
+	u32 non_secure_el1_flags;
 	u32 virtual_timer_interrupt;
 	u32 virtual_timer_flags;
-	u32 non_secure_pl2_interrupt;
-	u32 non_secure_pl2_flags;
+	u32 non_secure_el2_interrupt;
+	u32 non_secure_el2_flags;
+	u64 counter_read_block_address;
+	u32 platform_timer_count;
+	u32 platform_timer_offset;
 };
 
-/* Values for Flags field above */
+/* Flag Definitions: Timer Block Physical Timers and Virtual timers */
+
+#define ACPI_GTDT_INTERRUPT_MODE        (1)
+#define ACPI_GTDT_INTERRUPT_POLARITY    (1<<1)
+#define ACPI_GTDT_ALWAYS_ON             (1<<2)
+
+/* Common GTDT subtable header */
+
+struct acpi_gtdt_header {
+	u8 type;
+	u16 length;
+};
+
+/* Values for GTDT subtable type above */
+
+enum acpi_gtdt_type {
+	ACPI_GTDT_TYPE_TIMER_BLOCK = 0,
+	ACPI_GTDT_TYPE_WATCHDOG = 1,
+	ACPI_GTDT_TYPE_RESERVED = 2	/* 2 and greater are reserved */
+};
+
+/* GTDT Subtables, correspond to Type in struct acpi_gtdt_header */
 
-#define ACPI_GTDT_MAPPED_BLOCK_PRESENT      1
+/* 0: Generic Timer Block */
+
+struct acpi_gtdt_timer_block {
+	struct acpi_gtdt_header header;
+	u8 reserved;
+	u64 block_address;
+	u32 timer_count;
+	u32 timer_offset;
+};
+
+/* Timer Sub-Structure, one per timer */
+
+struct acpi_gtdt_timer_entry {
+	u8 frame_number;
+	u8 reserved[3];
+	u64 base_address;
+	u64 el0_base_address;
+	u32 timer_interrupt;
+	u32 timer_flags;
+	u32 virtual_timer_interrupt;
+	u32 virtual_timer_flags;
+	u32 common_flags;
+};
+
+/* Flag Definitions: timer_flags and virtual_timer_flags above */
+
+#define ACPI_GTDT_GT_IRQ_MODE               (1)
+#define ACPI_GTDT_GT_IRQ_POLARITY           (1<<1)
+
+/* Flag Definitions: common_flags above */
+
+#define ACPI_GTDT_GT_IS_SECURE_TIMER        (1)
+#define ACPI_GTDT_GT_ALWAYS_ON              (1<<1)
+
+/* 1: SBSA Generic Watchdog Structure */
+
+struct acpi_gtdt_watchdog {
+	struct acpi_gtdt_header header;
+	u8 reserved;
+	u64 refresh_frame_address;
+	u64 control_frame_address;
+	u32 timer_interrupt;
+	u32 timer_flags;
+};
 
-/* Values for all "TimerFlags" fields above */
+/* Flag Definitions: timer_flags above */
 
-#define ACPI_GTDT_INTERRUPT_MODE            1
-#define ACPI_GTDT_INTERRUPT_POLARITY        2
+#define ACPI_GTDT_WATCHDOG_IRQ_MODE         (1)
+#define ACPI_GTDT_WATCHDOG_IRQ_POLARITY     (1<<1)
+#define ACPI_GTDT_WATCHDOG_SECURE           (1<<2)
 
 /*******************************************************************************
  *
diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
index 1efa29d..714e596 100644
--- a/xen/include/asm-arm/acpi.h
+++ b/xen/include/asm-arm/acpi.h
@@ -46,4 +46,6 @@ static inline void disable_acpi(void)
     acpi_disabled = 1;
 }
 
+#define ACPI_GTDT_INTR_MASK ( ACPI_GTDT_INTERRUPT_MODE | ACPI_GTDT_INTERRUPT_POLARITY )
+
 #endif /*_ASM_ARM_ACPI_H*/
-- 
2.1.0

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

* [PATCH v3 30/62] arm/irq: Add helper function for setting interrupt type
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

Add a helper function to set edge/level type information for an
interrupt.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/irq.c        | 22 +++++++++++++++-------
 xen/include/asm-arm/irq.h |  2 ++
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c
index 1f38605..90b6e58 100644
--- a/xen/arch/arm/irq.c
+++ b/xen/arch/arm/irq.c
@@ -655,6 +655,19 @@ unlock:
     return ret;
 }
 
+int irq_set_type(unsigned int irq, unsigned int type)
+{
+    int res;
+
+    /* Setup the IRQ type */
+    if ( irq < NR_LOCAL_IRQS )
+        res = irq_local_set_type(irq, type);
+    else
+        res = irq_set_spi_type(irq, type);
+
+    return res;
+}
+
 int platform_get_irq(const struct dt_device_node *device, int index)
 {
     struct dt_irq dt_irq;
@@ -668,14 +681,9 @@ int platform_get_irq(const struct dt_device_node *device, int index)
     irq = dt_irq.irq;
     type = dt_irq.type;
 
-    /* Setup the IRQ type */
-    if ( irq < NR_LOCAL_IRQS )
-        res = irq_local_set_type(irq, type);
-    else
-        res = irq_set_spi_type(irq, type);
-
+    res = irq_set_type(irq, type);
     if ( res )
-            return -1;
+        return -1;
 
     return irq;
 }
diff --git a/xen/include/asm-arm/irq.h b/xen/include/asm-arm/irq.h
index f33c331..493773c 100644
--- a/xen/include/asm-arm/irq.h
+++ b/xen/include/asm-arm/irq.h
@@ -52,6 +52,8 @@ void arch_move_irqs(struct vcpu *v);
 /* Set IRQ type for an SPI */
 int irq_set_spi_type(unsigned int spi, unsigned int type);
 
+int irq_set_type(unsigned int irq, unsigned int type);
+
 int platform_get_irq(const struct dt_device_node *device, int index);
 
 void irq_set_affinity(struct irq_desc *desc, const cpumask_t *cpu_mask);
-- 
2.1.0

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

* [PATCH v3 30/62] arm/irq: Add helper function for setting interrupt type
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

Add a helper function to set edge/level type information for an
interrupt.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/irq.c        | 22 +++++++++++++++-------
 xen/include/asm-arm/irq.h |  2 ++
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c
index 1f38605..90b6e58 100644
--- a/xen/arch/arm/irq.c
+++ b/xen/arch/arm/irq.c
@@ -655,6 +655,19 @@ unlock:
     return ret;
 }
 
+int irq_set_type(unsigned int irq, unsigned int type)
+{
+    int res;
+
+    /* Setup the IRQ type */
+    if ( irq < NR_LOCAL_IRQS )
+        res = irq_local_set_type(irq, type);
+    else
+        res = irq_set_spi_type(irq, type);
+
+    return res;
+}
+
 int platform_get_irq(const struct dt_device_node *device, int index)
 {
     struct dt_irq dt_irq;
@@ -668,14 +681,9 @@ int platform_get_irq(const struct dt_device_node *device, int index)
     irq = dt_irq.irq;
     type = dt_irq.type;
 
-    /* Setup the IRQ type */
-    if ( irq < NR_LOCAL_IRQS )
-        res = irq_local_set_type(irq, type);
-    else
-        res = irq_set_spi_type(irq, type);
-
+    res = irq_set_type(irq, type);
     if ( res )
-            return -1;
+        return -1;
 
     return irq;
 }
diff --git a/xen/include/asm-arm/irq.h b/xen/include/asm-arm/irq.h
index f33c331..493773c 100644
--- a/xen/include/asm-arm/irq.h
+++ b/xen/include/asm-arm/irq.h
@@ -52,6 +52,8 @@ void arch_move_irqs(struct vcpu *v);
 /* Set IRQ type for an SPI */
 int irq_set_spi_type(unsigned int spi, unsigned int type);
 
+int irq_set_type(unsigned int irq, unsigned int type);
+
 int platform_get_irq(const struct dt_device_node *device, int index);
 
 void irq_set_affinity(struct irq_desc *desc, const cpumask_t *cpu_mask);
-- 
2.1.0

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

* [PATCH v3 31/62] arm/acpi: Add a helper function to get interrupt type
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

Add a helper funtion to get the type of interrupts in ACPI table.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/acpi/lib.c    | 27 +++++++++++++++++++++++++++
 xen/include/asm-arm/acpi.h | 39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 66 insertions(+)

diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c
index d8b7635..47f4c6a 100644
--- a/xen/arch/arm/acpi/lib.c
+++ b/xen/arch/arm/acpi/lib.c
@@ -43,3 +43,30 @@ bool_t __init acpi_psci_hvc_present(void)
 {
     return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_USE_HVC;
 }
+
+unsigned int acpi_get_irq_type(u32 flags)
+{
+    int trigger, polarity;
+
+    trigger = (flags & ACPI_GTDT_INTERRUPT_MODE) ? ACPI_EDGE_SENSITIVE
+               : ACPI_LEVEL_SENSITIVE;
+
+    polarity = (flags & ACPI_GTDT_INTERRUPT_POLARITY) ? ACPI_ACTIVE_LOW
+                : ACPI_ACTIVE_HIGH;
+
+    switch (polarity) {
+    case ACPI_ACTIVE_LOW:
+        return trigger == ACPI_EDGE_SENSITIVE ?
+            ACPI_IRQ_TYPE_EDGE_FALLING :
+            ACPI_IRQ_TYPE_LEVEL_LOW;
+    case ACPI_ACTIVE_HIGH:
+        return trigger == ACPI_EDGE_SENSITIVE ?
+            ACPI_IRQ_TYPE_EDGE_RISING :
+            ACPI_IRQ_TYPE_LEVEL_HIGH;
+    case ACPI_ACTIVE_BOTH:
+        if (trigger == ACPI_EDGE_SENSITIVE)
+            return ACPI_IRQ_TYPE_EDGE_BOTH;
+    default:
+        return ACPI_IRQ_TYPE_NONE;
+    }
+}
diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
index 714e596..214fc4e 100644
--- a/xen/include/asm-arm/acpi.h
+++ b/xen/include/asm-arm/acpi.h
@@ -34,10 +34,12 @@ extern bool_t acpi_disabled;
 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_irq_type(u32 flags);
 #else
 static inline bool_t acpi_psci_present(void) { return false; }
 static inline bool_t acpi_psci_hvc_present(void) {return false; }
 static inline void acpi_smp_init_cpus(void) { }
+static inline unsigned int acpi_get_irq_type(u32 flags) { return 0; }
 #endif /* CONFIG_ACPI */
 
 /* Basic configuration for ACPI */
@@ -48,4 +50,41 @@ static inline void disable_acpi(void)
 
 #define ACPI_GTDT_INTR_MASK ( ACPI_GTDT_INTERRUPT_MODE | ACPI_GTDT_INTERRUPT_POLARITY )
 
+/* Triggering */
+
+#define ACPI_LEVEL_SENSITIVE            (u8) 0x00
+#define ACPI_EDGE_SENSITIVE             (u8) 0x01
+
+/* Polarity */
+
+#define ACPI_ACTIVE_HIGH                (u8) 0x00
+#define ACPI_ACTIVE_LOW                 (u8) 0x01
+#define ACPI_ACTIVE_BOTH                (u8) 0x02
+
+/**
+ * IRQ line type.
+ *
+ * ACPI_IRQ_TYPE_NONE            - default, unspecified type
+ * ACPI_IRQ_TYPE_EDGE_RISING     - rising edge triggered
+ * ACPI_IRQ_TYPE_EDGE_FALLING    - falling edge triggered
+ * ACPI_IRQ_TYPE_EDGE_BOTH       - rising and falling edge triggered
+ * ACPI_IRQ_TYPE_LEVEL_HIGH      - high level triggered
+ * ACPI_IRQ_TYPE_LEVEL_LOW       - low level triggered
+ * ACPI_IRQ_TYPE_LEVEL_MASK      - Mask to filter out the level bits
+ * ACPI_IRQ_TYPE_SENSE_MASK      - Mask for all the above bits
+ * ACPI_IRQ_TYPE_INVALID         - Use to initialize the type
+ */
+#define ACPI_IRQ_TYPE_NONE           0x00000000
+#define ACPI_IRQ_TYPE_EDGE_RISING    0x00000001
+#define ACPI_IRQ_TYPE_EDGE_FALLING   0x00000002
+#define ACPI_IRQ_TYPE_EDGE_BOTH                           \
+    (ACPI_IRQ_TYPE_EDGE_FALLING | ACPI_IRQ_TYPE_EDGE_RISING)
+#define ACPI_IRQ_TYPE_LEVEL_HIGH     0x00000004
+#define ACPI_IRQ_TYPE_LEVEL_LOW      0x00000008
+#define ACPI_IRQ_TYPE_LEVEL_MASK                          \
+    (ACPI_IRQ_TYPE_LEVEL_LOW | ACPI_IRQ_TYPE_LEVEL_HIGH)
+#define ACPI_IRQ_TYPE_SENSE_MASK     0x0000000f
+
+#define ACPI_IRQ_TYPE_INVALID        0x00000010
+
 #endif /*_ASM_ARM_ACPI_H*/
-- 
2.1.0

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

* [PATCH v3 31/62] arm/acpi: Add a helper function to get interrupt type
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

Add a helper funtion to get the type of interrupts in ACPI table.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/acpi/lib.c    | 27 +++++++++++++++++++++++++++
 xen/include/asm-arm/acpi.h | 39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 66 insertions(+)

diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c
index d8b7635..47f4c6a 100644
--- a/xen/arch/arm/acpi/lib.c
+++ b/xen/arch/arm/acpi/lib.c
@@ -43,3 +43,30 @@ bool_t __init acpi_psci_hvc_present(void)
 {
     return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_USE_HVC;
 }
+
+unsigned int acpi_get_irq_type(u32 flags)
+{
+    int trigger, polarity;
+
+    trigger = (flags & ACPI_GTDT_INTERRUPT_MODE) ? ACPI_EDGE_SENSITIVE
+               : ACPI_LEVEL_SENSITIVE;
+
+    polarity = (flags & ACPI_GTDT_INTERRUPT_POLARITY) ? ACPI_ACTIVE_LOW
+                : ACPI_ACTIVE_HIGH;
+
+    switch (polarity) {
+    case ACPI_ACTIVE_LOW:
+        return trigger == ACPI_EDGE_SENSITIVE ?
+            ACPI_IRQ_TYPE_EDGE_FALLING :
+            ACPI_IRQ_TYPE_LEVEL_LOW;
+    case ACPI_ACTIVE_HIGH:
+        return trigger == ACPI_EDGE_SENSITIVE ?
+            ACPI_IRQ_TYPE_EDGE_RISING :
+            ACPI_IRQ_TYPE_LEVEL_HIGH;
+    case ACPI_ACTIVE_BOTH:
+        if (trigger == ACPI_EDGE_SENSITIVE)
+            return ACPI_IRQ_TYPE_EDGE_BOTH;
+    default:
+        return ACPI_IRQ_TYPE_NONE;
+    }
+}
diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
index 714e596..214fc4e 100644
--- a/xen/include/asm-arm/acpi.h
+++ b/xen/include/asm-arm/acpi.h
@@ -34,10 +34,12 @@ extern bool_t acpi_disabled;
 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_irq_type(u32 flags);
 #else
 static inline bool_t acpi_psci_present(void) { return false; }
 static inline bool_t acpi_psci_hvc_present(void) {return false; }
 static inline void acpi_smp_init_cpus(void) { }
+static inline unsigned int acpi_get_irq_type(u32 flags) { return 0; }
 #endif /* CONFIG_ACPI */
 
 /* Basic configuration for ACPI */
@@ -48,4 +50,41 @@ static inline void disable_acpi(void)
 
 #define ACPI_GTDT_INTR_MASK ( ACPI_GTDT_INTERRUPT_MODE | ACPI_GTDT_INTERRUPT_POLARITY )
 
+/* Triggering */
+
+#define ACPI_LEVEL_SENSITIVE            (u8) 0x00
+#define ACPI_EDGE_SENSITIVE             (u8) 0x01
+
+/* Polarity */
+
+#define ACPI_ACTIVE_HIGH                (u8) 0x00
+#define ACPI_ACTIVE_LOW                 (u8) 0x01
+#define ACPI_ACTIVE_BOTH                (u8) 0x02
+
+/**
+ * IRQ line type.
+ *
+ * ACPI_IRQ_TYPE_NONE            - default, unspecified type
+ * ACPI_IRQ_TYPE_EDGE_RISING     - rising edge triggered
+ * ACPI_IRQ_TYPE_EDGE_FALLING    - falling edge triggered
+ * ACPI_IRQ_TYPE_EDGE_BOTH       - rising and falling edge triggered
+ * ACPI_IRQ_TYPE_LEVEL_HIGH      - high level triggered
+ * ACPI_IRQ_TYPE_LEVEL_LOW       - low level triggered
+ * ACPI_IRQ_TYPE_LEVEL_MASK      - Mask to filter out the level bits
+ * ACPI_IRQ_TYPE_SENSE_MASK      - Mask for all the above bits
+ * ACPI_IRQ_TYPE_INVALID         - Use to initialize the type
+ */
+#define ACPI_IRQ_TYPE_NONE           0x00000000
+#define ACPI_IRQ_TYPE_EDGE_RISING    0x00000001
+#define ACPI_IRQ_TYPE_EDGE_FALLING   0x00000002
+#define ACPI_IRQ_TYPE_EDGE_BOTH                           \
+    (ACPI_IRQ_TYPE_EDGE_FALLING | ACPI_IRQ_TYPE_EDGE_RISING)
+#define ACPI_IRQ_TYPE_LEVEL_HIGH     0x00000004
+#define ACPI_IRQ_TYPE_LEVEL_LOW      0x00000008
+#define ACPI_IRQ_TYPE_LEVEL_MASK                          \
+    (ACPI_IRQ_TYPE_LEVEL_LOW | ACPI_IRQ_TYPE_LEVEL_HIGH)
+#define ACPI_IRQ_TYPE_SENSE_MASK     0x0000000f
+
+#define ACPI_IRQ_TYPE_INVALID        0x00000010
+
 #endif /*_ASM_ARM_ACPI_H*/
-- 
2.1.0

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

* [PATCH v3 32/62] arm/acpi: Parse GTDT to initialize timer
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

Parse GTDT (Generic Timer Descriptor Table) to initialize timer. Using
the information presented by GTDT to initialize the arch timer (not
memory-mapped).

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>
---
 xen/arch/arm/time.c | 73 +++++++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 62 insertions(+), 11 deletions(-)

diff --git a/xen/arch/arm/time.c b/xen/arch/arm/time.c
index 5ded30c..adbfc2a 100644
--- a/xen/arch/arm/time.c
+++ b/xen/arch/arm/time.c
@@ -29,6 +29,7 @@
 #include <xen/time.h>
 #include <xen/sched.h>
 #include <xen/event.h>
+#include <xen/acpi.h>
 #include <asm/system.h>
 #include <asm/time.h>
 #include <asm/gic.h>
@@ -65,8 +66,45 @@ unsigned int timer_get_irq(enum timer_ppi ppi)
 
 static __initdata struct dt_device_node *timer;
 
+#ifdef CONFIG_ACPI
+/* Initialize per-processor generic timer */
+static int __init arch_timer_acpi_init(struct acpi_table_header *table)
+{
+    unsigned int irq_type;
+    struct acpi_table_gtdt *gtdt;
+
+    gtdt = container_of(table, struct acpi_table_gtdt, header);
+
+    /* Initialize all the generic timer IRQ variable from GTDT table */
+    irq_type = acpi_get_irq_type(gtdt->non_secure_el1_flags);
+    irq_set_type(gtdt->non_secure_el1_interrupt, irq_type);
+    timer_irq[TIMER_PHYS_NONSECURE_PPI] = gtdt->non_secure_el1_interrupt;
+
+    irq_type = acpi_get_irq_type(gtdt->secure_el1_flags);
+    irq_set_type(gtdt->secure_el1_interrupt, irq_type);
+    timer_irq[TIMER_PHYS_SECURE_PPI] = gtdt->secure_el1_interrupt;
+
+    irq_type = acpi_get_irq_type(gtdt->virtual_timer_flags);
+    irq_set_type(gtdt->virtual_timer_interrupt, irq_type);
+    timer_irq[TIMER_VIRT_PPI] = gtdt->virtual_timer_interrupt;
+
+    irq_type = acpi_get_irq_type(gtdt->non_secure_el2_flags);
+    irq_set_type(gtdt->non_secure_el2_interrupt, irq_type);
+    timer_irq[TIMER_HYP_PPI] = gtdt->non_secure_el2_interrupt;
+
+    return 0;
+}
+
+void __init acpi_preinit_xen_time(void)
+{
+	acpi_table_parse(ACPI_SIG_GTDT, arch_timer_acpi_init);
+}
+#else
+static inline void acpi_preinit_xen_time(void) { }
+#endif
+
 /* Set up the timer on the boot CPU (early init function) */
-void __init preinit_xen_time(void)
+static void __init dt_preinit_xen_time(void)
 {
     static const struct dt_device_match timer_ids[] __initconst =
     {
@@ -74,7 +112,6 @@ void __init preinit_xen_time(void)
         { /* sentinel */ },
     };
     int res;
-    u32 rate;
 
     timer = dt_find_matching_node(NULL, timer_ids);
     if ( !timer )
@@ -86,8 +123,19 @@ void __init preinit_xen_time(void)
     if ( res )
         panic("Timer: Cannot initialize platform timer");
 
-    res = dt_property_read_u32(timer, "clock-frequency", &rate);
-    if ( res )
+}
+
+void __init preinit_xen_time(void)
+{
+    u32 rate;
+
+    /* Initialize all the generic timers presented in GTDT */
+    if ( acpi_disabled )
+        dt_preinit_xen_time();
+    else
+        acpi_preinit_xen_time();
+
+    if( acpi_disabled && dt_property_read_u32(timer, "clock-frequency", &rate) )
     {
         cpu_khz = rate / 1000;
         timer_dt_clock_frequency = rate;
@@ -104,14 +152,17 @@ int __init init_xen_time(void)
     int res;
     unsigned int i;
 
-    /* Retrieve all IRQs for the timer */
-    for ( i = TIMER_PHYS_SECURE_PPI; i < MAX_TIMER_PPI; i++ )
+    if( acpi_disabled )
     {
-        res = platform_get_irq(timer, i);
-
-        if ( res < 0 )
-            panic("Timer: Unable to retrieve IRQ %u from the device tree", i);
-        timer_irq[i] = res;
+        /* Retrieve all IRQs for the timer */
+        for ( i = TIMER_PHYS_SECURE_PPI; i < MAX_TIMER_PPI; i++ )
+        {
+            res = platform_get_irq(timer, i);
+
+            if ( res < 0 )
+                panic("Timer: Unable to retrieve IRQ %u from the device tree", i);
+            timer_irq[i] = res;
+        }
     }
 
     /* Check that this CPU supports the Generic Timer interface */
-- 
2.1.0

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

* [PATCH v3 32/62] arm/acpi: Parse GTDT to initialize timer
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

Parse GTDT (Generic Timer Descriptor Table) to initialize timer. Using
the information presented by GTDT to initialize the arch timer (not
memory-mapped).

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>
---
 xen/arch/arm/time.c | 73 +++++++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 62 insertions(+), 11 deletions(-)

diff --git a/xen/arch/arm/time.c b/xen/arch/arm/time.c
index 5ded30c..adbfc2a 100644
--- a/xen/arch/arm/time.c
+++ b/xen/arch/arm/time.c
@@ -29,6 +29,7 @@
 #include <xen/time.h>
 #include <xen/sched.h>
 #include <xen/event.h>
+#include <xen/acpi.h>
 #include <asm/system.h>
 #include <asm/time.h>
 #include <asm/gic.h>
@@ -65,8 +66,45 @@ unsigned int timer_get_irq(enum timer_ppi ppi)
 
 static __initdata struct dt_device_node *timer;
 
+#ifdef CONFIG_ACPI
+/* Initialize per-processor generic timer */
+static int __init arch_timer_acpi_init(struct acpi_table_header *table)
+{
+    unsigned int irq_type;
+    struct acpi_table_gtdt *gtdt;
+
+    gtdt = container_of(table, struct acpi_table_gtdt, header);
+
+    /* Initialize all the generic timer IRQ variable from GTDT table */
+    irq_type = acpi_get_irq_type(gtdt->non_secure_el1_flags);
+    irq_set_type(gtdt->non_secure_el1_interrupt, irq_type);
+    timer_irq[TIMER_PHYS_NONSECURE_PPI] = gtdt->non_secure_el1_interrupt;
+
+    irq_type = acpi_get_irq_type(gtdt->secure_el1_flags);
+    irq_set_type(gtdt->secure_el1_interrupt, irq_type);
+    timer_irq[TIMER_PHYS_SECURE_PPI] = gtdt->secure_el1_interrupt;
+
+    irq_type = acpi_get_irq_type(gtdt->virtual_timer_flags);
+    irq_set_type(gtdt->virtual_timer_interrupt, irq_type);
+    timer_irq[TIMER_VIRT_PPI] = gtdt->virtual_timer_interrupt;
+
+    irq_type = acpi_get_irq_type(gtdt->non_secure_el2_flags);
+    irq_set_type(gtdt->non_secure_el2_interrupt, irq_type);
+    timer_irq[TIMER_HYP_PPI] = gtdt->non_secure_el2_interrupt;
+
+    return 0;
+}
+
+void __init acpi_preinit_xen_time(void)
+{
+	acpi_table_parse(ACPI_SIG_GTDT, arch_timer_acpi_init);
+}
+#else
+static inline void acpi_preinit_xen_time(void) { }
+#endif
+
 /* Set up the timer on the boot CPU (early init function) */
-void __init preinit_xen_time(void)
+static void __init dt_preinit_xen_time(void)
 {
     static const struct dt_device_match timer_ids[] __initconst =
     {
@@ -74,7 +112,6 @@ void __init preinit_xen_time(void)
         { /* sentinel */ },
     };
     int res;
-    u32 rate;
 
     timer = dt_find_matching_node(NULL, timer_ids);
     if ( !timer )
@@ -86,8 +123,19 @@ void __init preinit_xen_time(void)
     if ( res )
         panic("Timer: Cannot initialize platform timer");
 
-    res = dt_property_read_u32(timer, "clock-frequency", &rate);
-    if ( res )
+}
+
+void __init preinit_xen_time(void)
+{
+    u32 rate;
+
+    /* Initialize all the generic timers presented in GTDT */
+    if ( acpi_disabled )
+        dt_preinit_xen_time();
+    else
+        acpi_preinit_xen_time();
+
+    if( acpi_disabled && dt_property_read_u32(timer, "clock-frequency", &rate) )
     {
         cpu_khz = rate / 1000;
         timer_dt_clock_frequency = rate;
@@ -104,14 +152,17 @@ int __init init_xen_time(void)
     int res;
     unsigned int i;
 
-    /* Retrieve all IRQs for the timer */
-    for ( i = TIMER_PHYS_SECURE_PPI; i < MAX_TIMER_PPI; i++ )
+    if( acpi_disabled )
     {
-        res = platform_get_irq(timer, i);
-
-        if ( res < 0 )
-            panic("Timer: Unable to retrieve IRQ %u from the device tree", i);
-        timer_irq[i] = res;
+        /* Retrieve all IRQs for the timer */
+        for ( i = TIMER_PHYS_SECURE_PPI; i < MAX_TIMER_PPI; i++ )
+        {
+            res = platform_get_irq(timer, i);
+
+            if ( res < 0 )
+                panic("Timer: Unable to retrieve IRQ %u from the device tree", i);
+            timer_irq[i] = res;
+        }
     }
 
     /* Check that this CPU supports the Generic Timer interface */
-- 
2.1.0

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

* [PATCH v3 33/62] arm/uart: Create generic uart initialization function
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

Rename dt-uart.c to arm-uart.c and create new generic uart init function.
Move dt_uart_init to arm_uart_init.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/setup.c        |   2 +-
 xen/drivers/char/Makefile   |   2 +-
 xen/drivers/char/arm-uart.c | 136 ++++++++++++++++++++++++++++++++++++++++++++
 xen/drivers/char/dt-uart.c  | 107 ----------------------------------
 xen/include/xen/serial.h    |   2 +-
 5 files changed, 139 insertions(+), 110 deletions(-)
 create mode 100644 xen/drivers/char/arm-uart.c
 delete mode 100644 xen/drivers/char/dt-uart.c

diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index c15a09d..63feadf 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -766,7 +766,7 @@ void __init start_xen(unsigned long boot_phys_offset,
 
     gic_preinit();
 
-    dt_uart_init();
+    arm_uart_init();
     console_init_preirq();
     console_init_ring();
 
diff --git a/xen/drivers/char/Makefile b/xen/drivers/char/Makefile
index 47fc3f9..a8f65c1 100644
--- a/xen/drivers/char/Makefile
+++ b/xen/drivers/char/Makefile
@@ -6,5 +6,5 @@ obj-$(HAS_EXYNOS4210) += exynos4210-uart.o
 obj-$(HAS_OMAP) += omap-uart.o
 obj-$(HAS_SCIF) += scif-uart.o
 obj-$(HAS_EHCI) += ehci-dbgp.o
-obj-$(CONFIG_ARM) += dt-uart.o
+obj-$(CONFIG_ARM) += arm-uart.o
 obj-y += serial.o
diff --git a/xen/drivers/char/arm-uart.c b/xen/drivers/char/arm-uart.c
new file mode 100644
index 0000000..2ddd744
--- /dev/null
+++ b/xen/drivers/char/arm-uart.c
@@ -0,0 +1,136 @@
+/*
+ * xen/drivers/char/arm-uart.c
+ *
+ * Generic uart retrieved via the device tree or acpi
+ *
+ * Julien Grall <julien.grall@linaro.org>
+ * Copyright (c) 2013 Linaro Limited.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <asm/device.h>
+#include <asm/types.h>
+#include <xen/console.h>
+#include <xen/device_tree.h>
+#include <xen/serial.h>
+#include <xen/errno.h>
+#include <xen/acpi.h>
+
+/*
+ * Configure UART port with a string:
+ * path:options
+ *
+ * @path: full path used in the device tree for the UART. If the path
+ * doesn't start with '/', we assuming that it's an alias.
+ * @options: UART speficic options (see in each UART driver)
+ */
+static char __initdata opt_dtuart[256] = "";
+string_param("dtuart", opt_dtuart);
+
+static void __init dt_uart_init(void)
+{
+    struct dt_device_node *dev;
+    int ret;
+    const char *devpath = opt_dtuart;
+    char *options;
+
+    if ( !console_has("dtuart") )
+        return; /* Not for us */
+
+    if ( !strcmp(opt_dtuart, "") )
+    {
+        const struct dt_device_node *chosen = dt_find_node_by_path("/chosen");
+
+        if ( chosen )
+        {
+            const char *stdout;
+
+            ret = dt_property_read_string(chosen, "stdout-path", &stdout);
+            if ( ret >= 0 )
+            {
+                printk("Taking dtuart configuration from /chosen/stdout-path\n");
+                if ( strlcpy(opt_dtuart, stdout, sizeof(opt_dtuart))
+                     >= sizeof(opt_dtuart) )
+                    printk("WARNING: /chosen/stdout-path too long, truncated\n");
+            }
+            else if ( ret != -EINVAL /* Not present */ )
+                printk("Failed to read /chosen/stdout-path (%d)\n", ret);
+        }
+    }
+
+    if ( !strcmp(opt_dtuart, "") )
+    {
+        printk("No dtuart path configured\n");
+        return;
+    }
+
+    options = strchr(opt_dtuart, ':');
+    if ( options != NULL )
+        *(options++) = '\0';
+    else
+        options = "";
+
+    printk("Looking for dtuart at \"%s\", options \"%s\"\n", devpath, options);
+    if ( *devpath == '/' )
+        dev = dt_find_node_by_path(devpath);
+    else
+        dev = dt_find_node_by_alias(devpath);
+
+    if ( !dev )
+    {
+        printk("Unable to find device \"%s\"\n", devpath);
+        return;
+    }
+
+    ret = device_init(dev, DEVICE_SERIAL, options);
+
+    if ( ret )
+        printk("Unable to initialize dtuart: %d\n", ret);
+}
+
+static void __init acpi_uart_init(void)
+{
+#ifdef CONFIG_ACPI
+    struct acpi_table_spcr *spcr=NULL;
+    int ret;
+
+    acpi_get_table(ACPI_SIG_SPCR, 0,(struct acpi_table_header **)&spcr);
+
+    if ( spcr == NULL )
+        printk("Unable to get spcr table\n");
+    else
+    {
+        ret = acpi_device_init(DEVICE_SERIAL, NULL, spcr->interface_type);
+
+        if ( ret )
+            printk("Unable to initialize acpi uart: %d\n", ret);
+    }
+#endif
+}
+
+void __init arm_uart_init(void)
+{
+    if ( acpi_disabled )
+        dt_uart_init();
+    else
+        acpi_uart_init();
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/xen/drivers/char/dt-uart.c b/xen/drivers/char/dt-uart.c
deleted file mode 100644
index d599322..0000000
--- a/xen/drivers/char/dt-uart.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * xen/drivers/char/dt-uart.c
- *
- * Generic uart retrieved via the device tree
- *
- * Julien Grall <julien.grall@linaro.org>
- * Copyright (c) 2013 Linaro Limited.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- */
-
-#include <asm/device.h>
-#include <asm/types.h>
-#include <xen/console.h>
-#include <xen/device_tree.h>
-#include <xen/serial.h>
-#include <xen/errno.h>
-
-/*
- * Configure UART port with a string:
- * path:options
- *
- * @path: full path used in the device tree for the UART. If the path
- * doesn't start with '/', we assuming that it's an alias.
- * @options: UART speficic options (see in each UART driver)
- */
-static char __initdata opt_dtuart[256] = "";
-string_param("dtuart", opt_dtuart);
-
-void __init dt_uart_init(void)
-{
-    struct dt_device_node *dev;
-    int ret;
-    const char *devpath = opt_dtuart;
-    char *options;
-
-    if ( !console_has("dtuart") )
-        return; /* Not for us */
-
-    if ( !strcmp(opt_dtuart, "") )
-    {
-        const struct dt_device_node *chosen = dt_find_node_by_path("/chosen");
-
-        if ( chosen )
-        {
-            const char *stdout;
-
-            ret = dt_property_read_string(chosen, "stdout-path", &stdout);
-            if ( ret >= 0 )
-            {
-                printk("Taking dtuart configuration from /chosen/stdout-path\n");
-                if ( strlcpy(opt_dtuart, stdout, sizeof(opt_dtuart))
-                     >= sizeof(opt_dtuart) )
-                    printk("WARNING: /chosen/stdout-path too long, truncated\n");
-            }
-            else if ( ret != -EINVAL /* Not present */ )
-                printk("Failed to read /chosen/stdout-path (%d)\n", ret);
-        }
-    }
-
-    if ( !strcmp(opt_dtuart, "") )
-    {
-        printk("No dtuart path configured\n");
-        return;
-    }
-
-    options = strchr(opt_dtuart, ':');
-    if ( options != NULL )
-        *(options++) = '\0';
-    else
-        options = "";
-
-    printk("Looking for dtuart at \"%s\", options \"%s\"\n", devpath, options);
-    if ( *devpath == '/' )
-        dev = dt_find_node_by_path(devpath);
-    else
-        dev = dt_find_node_by_alias(devpath);
-
-    if ( !dev )
-    {
-        printk("Unable to find device \"%s\"\n", devpath);
-        return;
-    }
-
-    ret = device_init(dev, DEVICE_SERIAL, options);
-
-    if ( ret )
-        printk("Unable to initialize dtuart: %d\n", ret);
-}
-
-/*
- * Local variables:
- * mode: C
- * c-file-style: "BSD"
- * c-basic-offset: 4
- * tab-width: 4
- * indent-tabs-mode: nil
- * End:
- */
diff --git a/xen/include/xen/serial.h b/xen/include/xen/serial.h
index 71e6ade..5e1a536 100644
--- a/xen/include/xen/serial.h
+++ b/xen/include/xen/serial.h
@@ -170,7 +170,7 @@ struct ns16550_defaults {
 void ns16550_init(int index, struct ns16550_defaults *defaults);
 void ehci_dbgp_init(void);
 
-void __init dt_uart_init(void);
+void __init arm_uart_init(void);
 
 struct physdev_dbgp_op;
 int dbgp_op(const struct physdev_dbgp_op *);
-- 
2.1.0

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

* [PATCH v3 33/62] arm/uart: Create generic uart initialization function
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

Rename dt-uart.c to arm-uart.c and create new generic uart init function.
Move dt_uart_init to arm_uart_init.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/setup.c        |   2 +-
 xen/drivers/char/Makefile   |   2 +-
 xen/drivers/char/arm-uart.c | 136 ++++++++++++++++++++++++++++++++++++++++++++
 xen/drivers/char/dt-uart.c  | 107 ----------------------------------
 xen/include/xen/serial.h    |   2 +-
 5 files changed, 139 insertions(+), 110 deletions(-)
 create mode 100644 xen/drivers/char/arm-uart.c
 delete mode 100644 xen/drivers/char/dt-uart.c

diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index c15a09d..63feadf 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -766,7 +766,7 @@ void __init start_xen(unsigned long boot_phys_offset,
 
     gic_preinit();
 
-    dt_uart_init();
+    arm_uart_init();
     console_init_preirq();
     console_init_ring();
 
diff --git a/xen/drivers/char/Makefile b/xen/drivers/char/Makefile
index 47fc3f9..a8f65c1 100644
--- a/xen/drivers/char/Makefile
+++ b/xen/drivers/char/Makefile
@@ -6,5 +6,5 @@ obj-$(HAS_EXYNOS4210) += exynos4210-uart.o
 obj-$(HAS_OMAP) += omap-uart.o
 obj-$(HAS_SCIF) += scif-uart.o
 obj-$(HAS_EHCI) += ehci-dbgp.o
-obj-$(CONFIG_ARM) += dt-uart.o
+obj-$(CONFIG_ARM) += arm-uart.o
 obj-y += serial.o
diff --git a/xen/drivers/char/arm-uart.c b/xen/drivers/char/arm-uart.c
new file mode 100644
index 0000000..2ddd744
--- /dev/null
+++ b/xen/drivers/char/arm-uart.c
@@ -0,0 +1,136 @@
+/*
+ * xen/drivers/char/arm-uart.c
+ *
+ * Generic uart retrieved via the device tree or acpi
+ *
+ * Julien Grall <julien.grall@linaro.org>
+ * Copyright (c) 2013 Linaro Limited.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <asm/device.h>
+#include <asm/types.h>
+#include <xen/console.h>
+#include <xen/device_tree.h>
+#include <xen/serial.h>
+#include <xen/errno.h>
+#include <xen/acpi.h>
+
+/*
+ * Configure UART port with a string:
+ * path:options
+ *
+ * @path: full path used in the device tree for the UART. If the path
+ * doesn't start with '/', we assuming that it's an alias.
+ * @options: UART speficic options (see in each UART driver)
+ */
+static char __initdata opt_dtuart[256] = "";
+string_param("dtuart", opt_dtuart);
+
+static void __init dt_uart_init(void)
+{
+    struct dt_device_node *dev;
+    int ret;
+    const char *devpath = opt_dtuart;
+    char *options;
+
+    if ( !console_has("dtuart") )
+        return; /* Not for us */
+
+    if ( !strcmp(opt_dtuart, "") )
+    {
+        const struct dt_device_node *chosen = dt_find_node_by_path("/chosen");
+
+        if ( chosen )
+        {
+            const char *stdout;
+
+            ret = dt_property_read_string(chosen, "stdout-path", &stdout);
+            if ( ret >= 0 )
+            {
+                printk("Taking dtuart configuration from /chosen/stdout-path\n");
+                if ( strlcpy(opt_dtuart, stdout, sizeof(opt_dtuart))
+                     >= sizeof(opt_dtuart) )
+                    printk("WARNING: /chosen/stdout-path too long, truncated\n");
+            }
+            else if ( ret != -EINVAL /* Not present */ )
+                printk("Failed to read /chosen/stdout-path (%d)\n", ret);
+        }
+    }
+
+    if ( !strcmp(opt_dtuart, "") )
+    {
+        printk("No dtuart path configured\n");
+        return;
+    }
+
+    options = strchr(opt_dtuart, ':');
+    if ( options != NULL )
+        *(options++) = '\0';
+    else
+        options = "";
+
+    printk("Looking for dtuart at \"%s\", options \"%s\"\n", devpath, options);
+    if ( *devpath == '/' )
+        dev = dt_find_node_by_path(devpath);
+    else
+        dev = dt_find_node_by_alias(devpath);
+
+    if ( !dev )
+    {
+        printk("Unable to find device \"%s\"\n", devpath);
+        return;
+    }
+
+    ret = device_init(dev, DEVICE_SERIAL, options);
+
+    if ( ret )
+        printk("Unable to initialize dtuart: %d\n", ret);
+}
+
+static void __init acpi_uart_init(void)
+{
+#ifdef CONFIG_ACPI
+    struct acpi_table_spcr *spcr=NULL;
+    int ret;
+
+    acpi_get_table(ACPI_SIG_SPCR, 0,(struct acpi_table_header **)&spcr);
+
+    if ( spcr == NULL )
+        printk("Unable to get spcr table\n");
+    else
+    {
+        ret = acpi_device_init(DEVICE_SERIAL, NULL, spcr->interface_type);
+
+        if ( ret )
+            printk("Unable to initialize acpi uart: %d\n", ret);
+    }
+#endif
+}
+
+void __init arm_uart_init(void)
+{
+    if ( acpi_disabled )
+        dt_uart_init();
+    else
+        acpi_uart_init();
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/xen/drivers/char/dt-uart.c b/xen/drivers/char/dt-uart.c
deleted file mode 100644
index d599322..0000000
--- a/xen/drivers/char/dt-uart.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * xen/drivers/char/dt-uart.c
- *
- * Generic uart retrieved via the device tree
- *
- * Julien Grall <julien.grall@linaro.org>
- * Copyright (c) 2013 Linaro Limited.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- */
-
-#include <asm/device.h>
-#include <asm/types.h>
-#include <xen/console.h>
-#include <xen/device_tree.h>
-#include <xen/serial.h>
-#include <xen/errno.h>
-
-/*
- * Configure UART port with a string:
- * path:options
- *
- * @path: full path used in the device tree for the UART. If the path
- * doesn't start with '/', we assuming that it's an alias.
- * @options: UART speficic options (see in each UART driver)
- */
-static char __initdata opt_dtuart[256] = "";
-string_param("dtuart", opt_dtuart);
-
-void __init dt_uart_init(void)
-{
-    struct dt_device_node *dev;
-    int ret;
-    const char *devpath = opt_dtuart;
-    char *options;
-
-    if ( !console_has("dtuart") )
-        return; /* Not for us */
-
-    if ( !strcmp(opt_dtuart, "") )
-    {
-        const struct dt_device_node *chosen = dt_find_node_by_path("/chosen");
-
-        if ( chosen )
-        {
-            const char *stdout;
-
-            ret = dt_property_read_string(chosen, "stdout-path", &stdout);
-            if ( ret >= 0 )
-            {
-                printk("Taking dtuart configuration from /chosen/stdout-path\n");
-                if ( strlcpy(opt_dtuart, stdout, sizeof(opt_dtuart))
-                     >= sizeof(opt_dtuart) )
-                    printk("WARNING: /chosen/stdout-path too long, truncated\n");
-            }
-            else if ( ret != -EINVAL /* Not present */ )
-                printk("Failed to read /chosen/stdout-path (%d)\n", ret);
-        }
-    }
-
-    if ( !strcmp(opt_dtuart, "") )
-    {
-        printk("No dtuart path configured\n");
-        return;
-    }
-
-    options = strchr(opt_dtuart, ':');
-    if ( options != NULL )
-        *(options++) = '\0';
-    else
-        options = "";
-
-    printk("Looking for dtuart at \"%s\", options \"%s\"\n", devpath, options);
-    if ( *devpath == '/' )
-        dev = dt_find_node_by_path(devpath);
-    else
-        dev = dt_find_node_by_alias(devpath);
-
-    if ( !dev )
-    {
-        printk("Unable to find device \"%s\"\n", devpath);
-        return;
-    }
-
-    ret = device_init(dev, DEVICE_SERIAL, options);
-
-    if ( ret )
-        printk("Unable to initialize dtuart: %d\n", ret);
-}
-
-/*
- * Local variables:
- * mode: C
- * c-file-style: "BSD"
- * c-basic-offset: 4
- * tab-width: 4
- * indent-tabs-mode: nil
- * End:
- */
diff --git a/xen/include/xen/serial.h b/xen/include/xen/serial.h
index 71e6ade..5e1a536 100644
--- a/xen/include/xen/serial.h
+++ b/xen/include/xen/serial.h
@@ -170,7 +170,7 @@ struct ns16550_defaults {
 void ns16550_init(int index, struct ns16550_defaults *defaults);
 void ehci_dbgp_init(void);
 
-void __init dt_uart_init(void);
+void __init arm_uart_init(void);
 
 struct physdev_dbgp_op;
 int dbgp_op(const struct physdev_dbgp_op *);
-- 
2.1.0

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

* [PATCH v3 34/62] pl011: Refactor pl011 driver to dt and common initialization parts
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

Refactor pl011 driver to dt and common initialization parts. This will
be useful later when acpi specific uart initialization function is
introduced.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/drivers/char/pl011.c | 64 ++++++++++++++++++++++++++++--------------------
 1 file changed, 38 insertions(+), 26 deletions(-)

diff --git a/xen/drivers/char/pl011.c b/xen/drivers/char/pl011.c
index 67e6df5..16abaa5 100644
--- a/xen/drivers/char/pl011.c
+++ b/xen/drivers/char/pl011.c
@@ -226,12 +226,42 @@ static struct uart_driver __read_mostly pl011_driver = {
     .vuart_info   = pl011_vuart,
 };
 
+static int __init pl011_uart_init(int irq, u64 addr, u64 size)
+{
+    struct pl011 *uart;
+
+    uart = &pl011_com;
+    uart->irq       = irq;
+    uart->clock_hz  = 0x16e3600;
+    uart->baud      = BAUD_AUTO;
+    uart->data_bits = 8;
+    uart->parity    = PARITY_NONE;
+    uart->stop_bits = 1;
+
+    uart->regs = ioremap_nocache(addr, size);
+    if ( !uart->regs )
+    {
+        printk("pl011: Unable to map the UART memory\n");
+        return -ENOMEM;
+    }
+
+    uart->vuart.base_addr = addr;
+    uart->vuart.size = size;
+    uart->vuart.data_off = DR;
+    uart->vuart.status_off = FR;
+    uart->vuart.status = 0;
+
+    /* Register with generic serial driver. */
+    serial_register_uart(SERHND_DTUART, &pl011_driver, uart);
+
+    return 0;
+}
+
 /* TODO: Parse UART config from the command line */
-static int __init pl011_uart_init(struct dt_device_node *dev,
-                                  const void *data)
+static int __init dt_pl011_uart_init(struct dt_device_node *dev,
+                                     const void *data)
 {
     const char *config = data;
-    struct pl011 *uart;
     int res;
     u64 addr, size;
 
@@ -240,14 +270,6 @@ static int __init pl011_uart_init(struct dt_device_node *dev,
         printk("WARNING: UART configuration is not supported\n");
     }
 
-    uart = &pl011_com;
-
-    uart->clock_hz  = 0x16e3600;
-    uart->baud      = BAUD_AUTO;
-    uart->data_bits = 8;
-    uart->parity    = PARITY_NONE;
-    uart->stop_bits = 1;
-
     res = dt_device_get_address(dev, 0, &addr, &size);
     if ( res )
     {
@@ -262,24 +284,14 @@ static int __init pl011_uart_init(struct dt_device_node *dev,
         printk("pl011: Unable to retrieve the IRQ\n");
         return -EINVAL;
     }
-    uart->irq = res;
 
-    uart->regs = ioremap_nocache(addr, size);
-    if ( !uart->regs )
+    res = pl011_uart_init(res, addr, size);
+    if ( res < 0 )
     {
-        printk("pl011: Unable to map the UART memory\n");
-        return -ENOMEM;
+        printk("pl011: Unable to initialize\n");
+        return res;
     }
 
-    uart->vuart.base_addr = addr;
-    uart->vuart.size = size;
-    uart->vuart.data_off = DR;
-    uart->vuart.status_off = FR;
-    uart->vuart.status = 0;
-
-    /* Register with generic serial driver. */
-    serial_register_uart(SERHND_DTUART, &pl011_driver, uart);
-
     dt_device_set_used_by(dev, DOMID_XEN);
 
     return 0;
@@ -293,7 +305,7 @@ static const struct dt_device_match pl011_dt_match[] __initconst =
 
 DT_DEVICE_START(pl011, "PL011 UART", DEVICE_SERIAL)
         .dt_match = pl011_dt_match,
-        .init = pl011_uart_init,
+        .init = dt_pl011_uart_init,
 DT_DEVICE_END
 
 /*
-- 
2.1.0

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

* [PATCH v3 34/62] pl011: Refactor pl011 driver to dt and common initialization parts
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

Refactor pl011 driver to dt and common initialization parts. This will
be useful later when acpi specific uart initialization function is
introduced.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/drivers/char/pl011.c | 64 ++++++++++++++++++++++++++++--------------------
 1 file changed, 38 insertions(+), 26 deletions(-)

diff --git a/xen/drivers/char/pl011.c b/xen/drivers/char/pl011.c
index 67e6df5..16abaa5 100644
--- a/xen/drivers/char/pl011.c
+++ b/xen/drivers/char/pl011.c
@@ -226,12 +226,42 @@ static struct uart_driver __read_mostly pl011_driver = {
     .vuart_info   = pl011_vuart,
 };
 
+static int __init pl011_uart_init(int irq, u64 addr, u64 size)
+{
+    struct pl011 *uart;
+
+    uart = &pl011_com;
+    uart->irq       = irq;
+    uart->clock_hz  = 0x16e3600;
+    uart->baud      = BAUD_AUTO;
+    uart->data_bits = 8;
+    uart->parity    = PARITY_NONE;
+    uart->stop_bits = 1;
+
+    uart->regs = ioremap_nocache(addr, size);
+    if ( !uart->regs )
+    {
+        printk("pl011: Unable to map the UART memory\n");
+        return -ENOMEM;
+    }
+
+    uart->vuart.base_addr = addr;
+    uart->vuart.size = size;
+    uart->vuart.data_off = DR;
+    uart->vuart.status_off = FR;
+    uart->vuart.status = 0;
+
+    /* Register with generic serial driver. */
+    serial_register_uart(SERHND_DTUART, &pl011_driver, uart);
+
+    return 0;
+}
+
 /* TODO: Parse UART config from the command line */
-static int __init pl011_uart_init(struct dt_device_node *dev,
-                                  const void *data)
+static int __init dt_pl011_uart_init(struct dt_device_node *dev,
+                                     const void *data)
 {
     const char *config = data;
-    struct pl011 *uart;
     int res;
     u64 addr, size;
 
@@ -240,14 +270,6 @@ static int __init pl011_uart_init(struct dt_device_node *dev,
         printk("WARNING: UART configuration is not supported\n");
     }
 
-    uart = &pl011_com;
-
-    uart->clock_hz  = 0x16e3600;
-    uart->baud      = BAUD_AUTO;
-    uart->data_bits = 8;
-    uart->parity    = PARITY_NONE;
-    uart->stop_bits = 1;
-
     res = dt_device_get_address(dev, 0, &addr, &size);
     if ( res )
     {
@@ -262,24 +284,14 @@ static int __init pl011_uart_init(struct dt_device_node *dev,
         printk("pl011: Unable to retrieve the IRQ\n");
         return -EINVAL;
     }
-    uart->irq = res;
 
-    uart->regs = ioremap_nocache(addr, size);
-    if ( !uart->regs )
+    res = pl011_uart_init(res, addr, size);
+    if ( res < 0 )
     {
-        printk("pl011: Unable to map the UART memory\n");
-        return -ENOMEM;
+        printk("pl011: Unable to initialize\n");
+        return res;
     }
 
-    uart->vuart.base_addr = addr;
-    uart->vuart.size = size;
-    uart->vuart.data_off = DR;
-    uart->vuart.status_off = FR;
-    uart->vuart.status = 0;
-
-    /* Register with generic serial driver. */
-    serial_register_uart(SERHND_DTUART, &pl011_driver, uart);
-
     dt_device_set_used_by(dev, DOMID_XEN);
 
     return 0;
@@ -293,7 +305,7 @@ static const struct dt_device_match pl011_dt_match[] __initconst =
 
 DT_DEVICE_START(pl011, "PL011 UART", DEVICE_SERIAL)
         .dt_match = pl011_dt_match,
-        .init = pl011_uart_init,
+        .init = dt_pl011_uart_init,
 DT_DEVICE_END
 
 /*
-- 
2.1.0

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

* [PATCH v3 35/62] serial: Rename SERHND_DTUART to SERHND_UART
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

Rename SERHND_DTUART to SERHND_UART in order to reuse it when booting
with ACPI.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/vuart.c               | 2 +-
 xen/drivers/char/cadence-uart.c    | 2 +-
 xen/drivers/char/exynos4210-uart.c | 2 +-
 xen/drivers/char/omap-uart.c       | 2 +-
 xen/drivers/char/pl011.c           | 2 +-
 xen/drivers/char/scif-uart.c       | 2 +-
 xen/drivers/char/serial.c          | 2 +-
 xen/include/xen/serial.h           | 2 +-
 8 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/xen/arch/arm/vuart.c b/xen/arch/arm/vuart.c
index b5c9288..6619b33 100644
--- a/xen/arch/arm/vuart.c
+++ b/xen/arch/arm/vuart.c
@@ -59,7 +59,7 @@ int domain_vuart_init(struct domain *d)
 {
     ASSERT( is_hardware_domain(d) );
 
-    d->arch.vuart.info = serial_vuart_info(SERHND_DTUART);
+    d->arch.vuart.info = serial_vuart_info(SERHND_UART);
     if ( !d->arch.vuart.info )
         return 0;
 
diff --git a/xen/drivers/char/cadence-uart.c b/xen/drivers/char/cadence-uart.c
index 933672f..ed65004 100644
--- a/xen/drivers/char/cadence-uart.c
+++ b/xen/drivers/char/cadence-uart.c
@@ -196,7 +196,7 @@ static int __init cuart_init(struct dt_device_node *dev, const void *data)
     uart->vuart.status = UART_SR_INTR_TEMPTY;
 
     /* Register with generic serial driver. */
-    serial_register_uart(SERHND_DTUART, &cuart_driver, uart);
+    serial_register_uart(SERHND_UART, &cuart_driver, uart);
 
     dt_device_set_used_by(dev, DOMID_XEN);
 
diff --git a/xen/drivers/char/exynos4210-uart.c b/xen/drivers/char/exynos4210-uart.c
index bac1c2b..43f5313 100644
--- a/xen/drivers/char/exynos4210-uart.c
+++ b/xen/drivers/char/exynos4210-uart.c
@@ -345,7 +345,7 @@ static int __init exynos4210_uart_init(struct dt_device_node *dev,
     uart->vuart.status = UTRSTAT_TXE | UTRSTAT_TXFE;
 
     /* Register with generic serial driver. */
-    serial_register_uart(SERHND_DTUART, &exynos4210_uart_driver, uart);
+    serial_register_uart(SERHND_UART, &exynos4210_uart_driver, uart);
 
     dt_device_set_used_by(dev, DOMID_XEN);
 
diff --git a/xen/drivers/char/omap-uart.c b/xen/drivers/char/omap-uart.c
index d8f64ea..98c3892 100644
--- a/xen/drivers/char/omap-uart.c
+++ b/xen/drivers/char/omap-uart.c
@@ -343,7 +343,7 @@ static int __init omap_uart_init(struct dt_device_node *dev,
     uart->vuart.status = UART_LSR_THRE;
 
     /* Register with generic serial driver */
-    serial_register_uart(SERHND_DTUART, &omap_uart_driver, uart);
+    serial_register_uart(SERHND_UART, &omap_uart_driver, uart);
 
     dt_device_set_used_by(dev, DOMID_XEN);
 
diff --git a/xen/drivers/char/pl011.c b/xen/drivers/char/pl011.c
index 16abaa5..1efb1cf 100644
--- a/xen/drivers/char/pl011.c
+++ b/xen/drivers/char/pl011.c
@@ -252,7 +252,7 @@ static int __init pl011_uart_init(int irq, u64 addr, u64 size)
     uart->vuart.status = 0;
 
     /* Register with generic serial driver. */
-    serial_register_uart(SERHND_DTUART, &pl011_driver, uart);
+    serial_register_uart(SERHND_UART, &pl011_driver, uart);
 
     return 0;
 }
diff --git a/xen/drivers/char/scif-uart.c b/xen/drivers/char/scif-uart.c
index 51a2233..739317c 100644
--- a/xen/drivers/char/scif-uart.c
+++ b/xen/drivers/char/scif-uart.c
@@ -339,7 +339,7 @@ static int __init scif_uart_init(struct dt_device_node *dev,
     uart->vuart.status     = SCFSR_TDFE;
 
     /* Register with generic serial driver */
-    serial_register_uart(SERHND_DTUART, &scif_uart_driver, uart);
+    serial_register_uart(SERHND_UART, &scif_uart_driver, uart);
 
     dt_device_set_used_by(dev, DOMID_XEN);
 
diff --git a/xen/drivers/char/serial.c b/xen/drivers/char/serial.c
index c583a48..659e10d 100644
--- a/xen/drivers/char/serial.c
+++ b/xen/drivers/char/serial.c
@@ -312,7 +312,7 @@ int __init serial_parse_handle(char *conf)
 
     if ( !strncmp(conf, "dtuart", 5) )
     {
-        handle = SERHND_DTUART;
+        handle = SERHND_UART;
         goto common;
     }
 
diff --git a/xen/include/xen/serial.h b/xen/include/xen/serial.h
index 5e1a536..a6e7c22 100644
--- a/xen/include/xen/serial.h
+++ b/xen/include/xen/serial.h
@@ -94,7 +94,7 @@ struct uart_driver {
 # define SERHND_COM1    (0<<0)
 # define SERHND_COM2    (1<<0)
 # define SERHND_DBGP    (2<<0)
-# define SERHND_DTUART  (0<<0) /* Steal SERHND_COM1 value */
+# define SERHND_UART    (0<<0) /* Steal SERHND_COM1 value */
 #define SERHND_HI       (1<<2) /* Mux/demux each transferred char by MSB. */
 #define SERHND_LO       (1<<3) /* Ditto, except that the MSB is cleared.  */
 #define SERHND_COOKED   (1<<4) /* Newline/carriage-return translation?    */
-- 
2.1.0

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

* [PATCH v3 35/62] serial: Rename SERHND_DTUART to SERHND_UART
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

Rename SERHND_DTUART to SERHND_UART in order to reuse it when booting
with ACPI.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/vuart.c               | 2 +-
 xen/drivers/char/cadence-uart.c    | 2 +-
 xen/drivers/char/exynos4210-uart.c | 2 +-
 xen/drivers/char/omap-uart.c       | 2 +-
 xen/drivers/char/pl011.c           | 2 +-
 xen/drivers/char/scif-uart.c       | 2 +-
 xen/drivers/char/serial.c          | 2 +-
 xen/include/xen/serial.h           | 2 +-
 8 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/xen/arch/arm/vuart.c b/xen/arch/arm/vuart.c
index b5c9288..6619b33 100644
--- a/xen/arch/arm/vuart.c
+++ b/xen/arch/arm/vuart.c
@@ -59,7 +59,7 @@ int domain_vuart_init(struct domain *d)
 {
     ASSERT( is_hardware_domain(d) );
 
-    d->arch.vuart.info = serial_vuart_info(SERHND_DTUART);
+    d->arch.vuart.info = serial_vuart_info(SERHND_UART);
     if ( !d->arch.vuart.info )
         return 0;
 
diff --git a/xen/drivers/char/cadence-uart.c b/xen/drivers/char/cadence-uart.c
index 933672f..ed65004 100644
--- a/xen/drivers/char/cadence-uart.c
+++ b/xen/drivers/char/cadence-uart.c
@@ -196,7 +196,7 @@ static int __init cuart_init(struct dt_device_node *dev, const void *data)
     uart->vuart.status = UART_SR_INTR_TEMPTY;
 
     /* Register with generic serial driver. */
-    serial_register_uart(SERHND_DTUART, &cuart_driver, uart);
+    serial_register_uart(SERHND_UART, &cuart_driver, uart);
 
     dt_device_set_used_by(dev, DOMID_XEN);
 
diff --git a/xen/drivers/char/exynos4210-uart.c b/xen/drivers/char/exynos4210-uart.c
index bac1c2b..43f5313 100644
--- a/xen/drivers/char/exynos4210-uart.c
+++ b/xen/drivers/char/exynos4210-uart.c
@@ -345,7 +345,7 @@ static int __init exynos4210_uart_init(struct dt_device_node *dev,
     uart->vuart.status = UTRSTAT_TXE | UTRSTAT_TXFE;
 
     /* Register with generic serial driver. */
-    serial_register_uart(SERHND_DTUART, &exynos4210_uart_driver, uart);
+    serial_register_uart(SERHND_UART, &exynos4210_uart_driver, uart);
 
     dt_device_set_used_by(dev, DOMID_XEN);
 
diff --git a/xen/drivers/char/omap-uart.c b/xen/drivers/char/omap-uart.c
index d8f64ea..98c3892 100644
--- a/xen/drivers/char/omap-uart.c
+++ b/xen/drivers/char/omap-uart.c
@@ -343,7 +343,7 @@ static int __init omap_uart_init(struct dt_device_node *dev,
     uart->vuart.status = UART_LSR_THRE;
 
     /* Register with generic serial driver */
-    serial_register_uart(SERHND_DTUART, &omap_uart_driver, uart);
+    serial_register_uart(SERHND_UART, &omap_uart_driver, uart);
 
     dt_device_set_used_by(dev, DOMID_XEN);
 
diff --git a/xen/drivers/char/pl011.c b/xen/drivers/char/pl011.c
index 16abaa5..1efb1cf 100644
--- a/xen/drivers/char/pl011.c
+++ b/xen/drivers/char/pl011.c
@@ -252,7 +252,7 @@ static int __init pl011_uart_init(int irq, u64 addr, u64 size)
     uart->vuart.status = 0;
 
     /* Register with generic serial driver. */
-    serial_register_uart(SERHND_DTUART, &pl011_driver, uart);
+    serial_register_uart(SERHND_UART, &pl011_driver, uart);
 
     return 0;
 }
diff --git a/xen/drivers/char/scif-uart.c b/xen/drivers/char/scif-uart.c
index 51a2233..739317c 100644
--- a/xen/drivers/char/scif-uart.c
+++ b/xen/drivers/char/scif-uart.c
@@ -339,7 +339,7 @@ static int __init scif_uart_init(struct dt_device_node *dev,
     uart->vuart.status     = SCFSR_TDFE;
 
     /* Register with generic serial driver */
-    serial_register_uart(SERHND_DTUART, &scif_uart_driver, uart);
+    serial_register_uart(SERHND_UART, &scif_uart_driver, uart);
 
     dt_device_set_used_by(dev, DOMID_XEN);
 
diff --git a/xen/drivers/char/serial.c b/xen/drivers/char/serial.c
index c583a48..659e10d 100644
--- a/xen/drivers/char/serial.c
+++ b/xen/drivers/char/serial.c
@@ -312,7 +312,7 @@ int __init serial_parse_handle(char *conf)
 
     if ( !strncmp(conf, "dtuart", 5) )
     {
-        handle = SERHND_DTUART;
+        handle = SERHND_UART;
         goto common;
     }
 
diff --git a/xen/include/xen/serial.h b/xen/include/xen/serial.h
index 5e1a536..a6e7c22 100644
--- a/xen/include/xen/serial.h
+++ b/xen/include/xen/serial.h
@@ -94,7 +94,7 @@ struct uart_driver {
 # define SERHND_COM1    (0<<0)
 # define SERHND_COM2    (1<<0)
 # define SERHND_DBGP    (2<<0)
-# define SERHND_DTUART  (0<<0) /* Steal SERHND_COM1 value */
+# define SERHND_UART    (0<<0) /* Steal SERHND_COM1 value */
 #define SERHND_HI       (1<<2) /* Mux/demux each transferred char by MSB. */
 #define SERHND_LO       (1<<3) /* Ditto, except that the MSB is cleared.  */
 #define SERHND_COOKED   (1<<4) /* Newline/carriage-return translation?    */
-- 
2.1.0

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

* [PATCH v3 36/62] arm/acpi: Initialize serial port from ACPI SPCR table
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

Parse ACPI SPCR (Serial Port Console Redirection table) table and
initialize the serial port pl011.

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>
---
 xen/drivers/char/pl011.c  | 37 +++++++++++++++++++++++++++++++++++++
 xen/include/acpi/actbl2.h |  5 +++++
 2 files changed, 42 insertions(+)

diff --git a/xen/drivers/char/pl011.c b/xen/drivers/char/pl011.c
index 1efb1cf..7106f1c 100644
--- a/xen/drivers/char/pl011.c
+++ b/xen/drivers/char/pl011.c
@@ -27,6 +27,7 @@
 #include <asm/device.h>
 #include <xen/mm.h>
 #include <xen/vmap.h>
+#include <xen/acpi.h>
 #include <asm/pl011-uart.h>
 #include <asm/io.h>
 
@@ -308,6 +309,42 @@ DT_DEVICE_START(pl011, "PL011 UART", DEVICE_SERIAL)
         .init = dt_pl011_uart_init,
 DT_DEVICE_END
 
+#ifdef CONFIG_ACPI
+static int __init acpi_pl011_uart_init(const void *data)
+{
+    acpi_status status;
+    struct acpi_table_spcr *spcr=NULL;
+    int res;
+
+    status = acpi_get_table(ACPI_SIG_SPCR, 0,
+                            (struct acpi_table_header **)&spcr);
+
+    if ( ACPI_FAILURE(status) )
+    {
+        printk("pl011: Failed to get SPCR table\n");
+        return -EINVAL;
+    }
+
+    /* trigger/polarity information is not available in spcr */
+    irq_set_type(spcr->interrupt, ACPI_IRQ_TYPE_EDGE_BOTH);
+
+    res = pl011_uart_init(spcr->interrupt, spcr->serial_port.address,
+                          PAGE_SIZE);
+    if ( res < 0 )
+    {
+        printk("pl011: Unable to initialize\n");
+        return res;
+    }
+
+    return 0;
+}
+
+ACPI_DEVICE_START(apl011, "PL011 UART", DEVICE_SERIAL)
+        .class_type = ACPI_SPCR_TYPE_PL011,
+        .init = acpi_pl011_uart_init,
+ACPI_DEVICE_END
+#endif
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/include/acpi/actbl2.h b/xen/include/acpi/actbl2.h
index 87bc6b3..25be429 100644
--- a/xen/include/acpi/actbl2.h
+++ b/xen/include/acpi/actbl2.h
@@ -815,6 +815,11 @@ struct acpi_table_spcr {
 
 #define ACPI_SPCR_DO_NOT_DISABLE    (1)
 
+/* UART Interface type */
+#define ACPI_SPCR_TYPE_16550 0
+#define ACPI_SPCR_TYPE_16550_SUB 1
+#define ACPI_SPCR_TYPE_PL011 3
+
 /*******************************************************************************
  *
  * SPMI - Server Platform Management Interface table
-- 
2.1.0

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

* [PATCH v3 36/62] arm/acpi: Initialize serial port from ACPI SPCR table
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

Parse ACPI SPCR (Serial Port Console Redirection table) table and
initialize the serial port pl011.

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>
---
 xen/drivers/char/pl011.c  | 37 +++++++++++++++++++++++++++++++++++++
 xen/include/acpi/actbl2.h |  5 +++++
 2 files changed, 42 insertions(+)

diff --git a/xen/drivers/char/pl011.c b/xen/drivers/char/pl011.c
index 1efb1cf..7106f1c 100644
--- a/xen/drivers/char/pl011.c
+++ b/xen/drivers/char/pl011.c
@@ -27,6 +27,7 @@
 #include <asm/device.h>
 #include <xen/mm.h>
 #include <xen/vmap.h>
+#include <xen/acpi.h>
 #include <asm/pl011-uart.h>
 #include <asm/io.h>
 
@@ -308,6 +309,42 @@ DT_DEVICE_START(pl011, "PL011 UART", DEVICE_SERIAL)
         .init = dt_pl011_uart_init,
 DT_DEVICE_END
 
+#ifdef CONFIG_ACPI
+static int __init acpi_pl011_uart_init(const void *data)
+{
+    acpi_status status;
+    struct acpi_table_spcr *spcr=NULL;
+    int res;
+
+    status = acpi_get_table(ACPI_SIG_SPCR, 0,
+                            (struct acpi_table_header **)&spcr);
+
+    if ( ACPI_FAILURE(status) )
+    {
+        printk("pl011: Failed to get SPCR table\n");
+        return -EINVAL;
+    }
+
+    /* trigger/polarity information is not available in spcr */
+    irq_set_type(spcr->interrupt, ACPI_IRQ_TYPE_EDGE_BOTH);
+
+    res = pl011_uart_init(spcr->interrupt, spcr->serial_port.address,
+                          PAGE_SIZE);
+    if ( res < 0 )
+    {
+        printk("pl011: Unable to initialize\n");
+        return res;
+    }
+
+    return 0;
+}
+
+ACPI_DEVICE_START(apl011, "PL011 UART", DEVICE_SERIAL)
+        .class_type = ACPI_SPCR_TYPE_PL011,
+        .init = acpi_pl011_uart_init,
+ACPI_DEVICE_END
+#endif
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/include/acpi/actbl2.h b/xen/include/acpi/actbl2.h
index 87bc6b3..25be429 100644
--- a/xen/include/acpi/actbl2.h
+++ b/xen/include/acpi/actbl2.h
@@ -815,6 +815,11 @@ struct acpi_table_spcr {
 
 #define ACPI_SPCR_DO_NOT_DISABLE    (1)
 
+/* UART Interface type */
+#define ACPI_SPCR_TYPE_16550 0
+#define ACPI_SPCR_TYPE_16550_SUB 1
+#define ACPI_SPCR_TYPE_PL011 3
+
 /*******************************************************************************
  *
  * SPMI - Server Platform Management Interface table
-- 
2.1.0

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

* [PATCH v3 37/62] arm/acpi: Define a enum for reserved tables
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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 214fc4e..f159d51 100644
--- a/xen/include/asm-arm/acpi.h
+++ b/xen/include/asm-arm/acpi.h
@@ -30,6 +30,18 @@
 
 extern bool_t acpi_disabled;
 
+/* 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;
+
 #ifdef CONFIG_ACPI
 bool_t __init acpi_psci_present(void);
 bool_t __init acpi_psci_hvc_present(void);
-- 
2.1.0

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

* [PATCH v3 37/62] arm/acpi: Define a enum for reserved tables
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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 214fc4e..f159d51 100644
--- a/xen/include/asm-arm/acpi.h
+++ b/xen/include/asm-arm/acpi.h
@@ -30,6 +30,18 @@
 
 extern bool_t acpi_disabled;
 
+/* 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;
+
 #ifdef CONFIG_ACPI
 bool_t __init acpi_psci_present(void);
 bool_t __init acpi_psci_hvc_present(void);
-- 
2.1.0

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

* [PATCH v3 38/62] arm/acpi: Add placeholder for efi and acpi load address
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

EFI table, memory description table and some of acpi tables will be
placed after DOM0 memory space. 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>
---
 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 1e61f30..91272e5 100644
--- a/xen/include/asm-arm/domain.h
+++ b/xen/include/asm-arm/domain.h
@@ -125,6 +125,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.1.0

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

* [PATCH v3 38/62] arm/acpi: Add placeholder for efi and acpi load address
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

EFI table, memory description table and some of acpi tables will be
placed after DOM0 memory space. 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>
---
 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 1e61f30..91272e5 100644
--- a/xen/include/asm-arm/domain.h
+++ b/xen/include/asm-arm/domain.h
@@ -125,6 +125,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.1.0

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

* [PATCH v3 39/62] arm/acpi: Read acpi memory info from uefi
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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>
---
 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..c58caca 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;
+#ifdef CONFIG_ACPI
+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;
         }
+#ifdef CONFIG_ACPI
+        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;
+#ifdef CONFIG_ACPI
+    acpi_mem.nr_banks = j;
+#endif
     return EFI_SUCCESS;
 }
 
-- 
2.1.0

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

* [PATCH v3 39/62] arm/acpi: Read acpi memory info from uefi
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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>
---
 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..c58caca 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;
+#ifdef CONFIG_ACPI
+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;
         }
+#ifdef CONFIG_ACPI
+        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;
+#ifdef CONFIG_ACPI
+    acpi_mem.nr_banks = j;
+#endif
     return EFI_SUCCESS;
 }
 
-- 
2.1.0

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

* [PATCH v3 40/62] arm/acpi: Estimate memory required for acpi/efi tables
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

Estimate the memory required for loading acpi/efi tables in Dom0. Alloc
the pages to store the new created EFI and ACPI tables and free these
pages when destroying domain.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/domain.c       |  4 +++
 xen/arch/arm/domain_build.c | 80 ++++++++++++++++++++++++++++++++++++++++++++-
 xen/common/efi/boot.c       | 21 ++++++++++++
 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 880d0a6..10c58c4 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -638,6 +638,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 0c3441a..b5ed44c 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,78 @@ 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 += PAGE_ALIGN(sizeof(struct acpi_table_fadt));
+    acpi_size += PAGE_ALIGN(sizeof(struct acpi_table_stao));
+
+    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 += PAGE_ALIGN(madt_size);
+
+    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));
+    acpi_size += PAGE_ALIGN(table->length + sizeof(u64));
+    acpi_os_unmap_memory(table, sizeof(struct acpi_table_header));
+    acpi_os_unmap_memory(rsdp_tbl, sizeof(struct acpi_table_rsdp));
+
+    acpi_size += PAGE_ALIGN(sizeof(struct acpi_table_rsdp));
+    d->arch.efi_acpi_len = PAGE_ALIGN(efi_size) + PAGE_ALIGN(acpi_size);
+
+    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 -1;
+    }
+    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 +1614,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..78d8ae9 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,26 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
     for( ; ; ); /* not reached */
 }
 
+#ifdef CONFIG_ACPI
+/* 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;
+    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 = PAGE_ALIGN(est_size + ect_size + fw_vendor_size)
+           + PAGE_ALIGN(emd_size *
+                        (mem_nr_banks + acpi_mem.nr_banks + TBL_MMAX));
+
+    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.1.0

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

* [PATCH v3 40/62] arm/acpi: Estimate memory required for acpi/efi tables
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

Estimate the memory required for loading acpi/efi tables in Dom0. Alloc
the pages to store the new created EFI and ACPI tables and free these
pages when destroying domain.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/domain.c       |  4 +++
 xen/arch/arm/domain_build.c | 80 ++++++++++++++++++++++++++++++++++++++++++++-
 xen/common/efi/boot.c       | 21 ++++++++++++
 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 880d0a6..10c58c4 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -638,6 +638,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 0c3441a..b5ed44c 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,78 @@ 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 += PAGE_ALIGN(sizeof(struct acpi_table_fadt));
+    acpi_size += PAGE_ALIGN(sizeof(struct acpi_table_stao));
+
+    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 += PAGE_ALIGN(madt_size);
+
+    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));
+    acpi_size += PAGE_ALIGN(table->length + sizeof(u64));
+    acpi_os_unmap_memory(table, sizeof(struct acpi_table_header));
+    acpi_os_unmap_memory(rsdp_tbl, sizeof(struct acpi_table_rsdp));
+
+    acpi_size += PAGE_ALIGN(sizeof(struct acpi_table_rsdp));
+    d->arch.efi_acpi_len = PAGE_ALIGN(efi_size) + PAGE_ALIGN(acpi_size);
+
+    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 -1;
+    }
+    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 +1614,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..78d8ae9 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,26 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
     for( ; ; ); /* not reached */
 }
 
+#ifdef CONFIG_ACPI
+/* 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;
+    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 = PAGE_ALIGN(est_size + ect_size + fw_vendor_size)
+           + PAGE_ALIGN(emd_size *
+                        (mem_nr_banks + acpi_mem.nr_banks + TBL_MMAX));
+
+    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.1.0

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

* [PATCH v3 41/62] arm/acpi: Add a helper function to get the acpi table offset
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/acpi/lib.c    | 13 +++++++++++++
 xen/include/asm-arm/acpi.h |  6 ++++++
 2 files changed, 19 insertions(+)

diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c
index 47f4c6a..d6044ef 100644
--- a/xen/arch/arm/acpi/lib.c
+++ b/xen/arch/arm/acpi/lib.c
@@ -70,3 +70,16 @@ unsigned int acpi_get_irq_type(u32 flags)
         return ACPI_IRQ_TYPE_NONE;
     }
 }
+
+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++ )
+    {
+        offset += PAGE_ALIGN(tbl_add[i].size);
+    }
+
+    return offset;
+}
diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
index f159d51..628f3c8 100644
--- a/xen/include/asm-arm/acpi.h
+++ b/xen/include/asm-arm/acpi.h
@@ -24,6 +24,7 @@
 #define _ASM_ARM_ACPI_H
 
 #include <xen/init.h>
+#include <asm/setup.h>
 
 #define COMPILER_DEPENDENT_INT64   long long
 #define COMPILER_DEPENDENT_UINT64  unsigned long long
@@ -47,11 +48,16 @@ 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_irq_type(u32 flags);
+unsigned int acpi_get_table_offset(struct membank tbl_add[], EFI_MEM_RES index);
 #else
 static inline bool_t acpi_psci_present(void) { return false; }
 static inline bool_t acpi_psci_hvc_present(void) {return false; }
 static inline void acpi_smp_init_cpus(void) { }
 static inline unsigned int acpi_get_irq_type(u32 flags) { return 0; }
+unsigned int acpi_get_table_offset(struct membank tbl_add[], EFI_MEM_RES index)
+{
+    return 0;
+}
 #endif /* CONFIG_ACPI */
 
 /* Basic configuration for ACPI */
-- 
2.1.0

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

* [PATCH v3 41/62] arm/acpi: Add a helper function to get the acpi table offset
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/acpi/lib.c    | 13 +++++++++++++
 xen/include/asm-arm/acpi.h |  6 ++++++
 2 files changed, 19 insertions(+)

diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c
index 47f4c6a..d6044ef 100644
--- a/xen/arch/arm/acpi/lib.c
+++ b/xen/arch/arm/acpi/lib.c
@@ -70,3 +70,16 @@ unsigned int acpi_get_irq_type(u32 flags)
         return ACPI_IRQ_TYPE_NONE;
     }
 }
+
+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++ )
+    {
+        offset += PAGE_ALIGN(tbl_add[i].size);
+    }
+
+    return offset;
+}
diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
index f159d51..628f3c8 100644
--- a/xen/include/asm-arm/acpi.h
+++ b/xen/include/asm-arm/acpi.h
@@ -24,6 +24,7 @@
 #define _ASM_ARM_ACPI_H
 
 #include <xen/init.h>
+#include <asm/setup.h>
 
 #define COMPILER_DEPENDENT_INT64   long long
 #define COMPILER_DEPENDENT_UINT64  unsigned long long
@@ -47,11 +48,16 @@ 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_irq_type(u32 flags);
+unsigned int acpi_get_table_offset(struct membank tbl_add[], EFI_MEM_RES index);
 #else
 static inline bool_t acpi_psci_present(void) { return false; }
 static inline bool_t acpi_psci_hvc_present(void) {return false; }
 static inline void acpi_smp_init_cpus(void) { }
 static inline unsigned int acpi_get_irq_type(u32 flags) { return 0; }
+unsigned int acpi_get_table_offset(struct membank tbl_add[], EFI_MEM_RES index)
+{
+    return 0;
+}
 #endif /* CONFIG_ACPI */
 
 /* Basic configuration for ACPI */
-- 
2.1.0

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

* [PATCH v3 42/62] arm/acpi: Prepare FADT table for Dom0
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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 | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index b5ed44c..5d03dc0 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1357,6 +1357,46 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
 }
 
 #ifdef CONFIG_ACPI
+#define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */
+
+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);
+    fadt->hypervisor_id = XEN_HYPERVISOR_ID;
+    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;
@@ -1400,6 +1440,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 )
@@ -1418,6 +1459,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.1.0

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

* [PATCH v3 42/62] arm/acpi: Prepare FADT table for Dom0
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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 | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index b5ed44c..5d03dc0 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1357,6 +1357,46 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
 }
 
 #ifdef CONFIG_ACPI
+#define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */
+
+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);
+    fadt->hypervisor_id = XEN_HYPERVISOR_ID;
+    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;
@@ -1400,6 +1440,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 )
@@ -1418,6 +1459,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.1.0

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

* [PATCH v3 43/62] arm/acpi: Prepare MADT table for Dom0
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

Copy and modify MADT table before passing it to Dom0. Copy
dom0_max_vcpus of GICCs and GICD as well.

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

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 5d03dc0..4591955 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1359,6 +1359,100 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
 #ifdef CONFIG_ACPI
 #define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */
 
+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_madt_generic_distributor gicd;
+    u64 table_size = sizeof(struct acpi_table_madt);
+    acpi_status status;
+    int i;
+    u8 *base_ptr;
+    u8 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
+               + acpi_get_table_offset(tbl_add, TBL_MADT);
+    ACPI_MEMCPY(base_ptr, table, table_size);
+
+    /* Add Generic Distributor */
+    memset(&gicd, 0, sizeof(gicd));
+    gicd.header.type = ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR;
+    gicd.header.length = sizeof(gicd);
+    gicd.base_address = d->arch.vgic.dbase;
+    if ( d->arch.vgic.version == GIC_V2 )
+        gicd.version = ACPI_MADT_GIC_VERSION_V2;
+    else if ( d->arch.vgic.version == GIC_V3 )
+        gicd.version = ACPI_MADT_GIC_VERSION_V3;
+    else
+        gicd.version = ACPI_MADT_GIC_VERSION_NONE;
+    ACPI_MEMCPY(base_ptr + table_size, &gicd, sizeof(gicd));
+    table_size += sizeof(gicd);
+
+    if ( d->arch.vgic.version == GIC_V3 ) {
+        /* Add Generic Redistributor */
+        for ( i = 0; i < d->arch.vgic.nr_regions; i++ ) {
+            struct acpi_madt_generic_redistributor gicr;
+
+            memset(&gicr, 0, sizeof(gicr));
+            gicr.header.type = ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR;
+            gicr.header.length = sizeof(gicr);
+            gicr.base_address = d->arch.vgic.rdist_regions[i].base;
+            gicr.length = d->arch.vgic.rdist_regions[i].size;
+            ACPI_MEMCPY(base_ptr + table_size, &gicr, sizeof(gicr));
+            table_size += sizeof(gicr);
+        }
+    } else {
+        /* Add Generic Interrupt */
+        for ( i = 0; i < d->max_vcpus; i++ )
+        {
+            struct acpi_madt_generic_interrupt gicc;
+            u64 mpidr = 0;
+            u32 id = i, j = 0;
+
+            memset(&gicc, 0, sizeof(gicc));
+            gicc.header.type = ACPI_MADT_TYPE_GENERIC_INTERRUPT;
+            gicc.header.length = sizeof(gicc);
+            gicc.cpu_interface_number = i;
+            gicc.uid = i;
+            gicc.flags = ACPI_MADT_ENABLED;
+            gicc.base_address = d->arch.vgic.cbase;
+
+            do {
+                mpidr |= (id % 4) << (8 * j);
+                j++;
+                if ( j ==3 )
+                    j++;
+                id = id / 4;
+            } while(id > 0);
+            gicc.arm_mpidr = mpidr;
+
+            ACPI_MEMCPY(base_ptr + table_size, &gicc, sizeof(gicc));
+            table_size += sizeof(gicc);
+        }
+    }
+
+    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
+                              + acpi_get_table_offset(tbl_add, TBL_MADT);
+    tbl_add[TBL_MADT].size = table_size;
+
+    return 0;
+}
+
 static int acpi_create_fadt(struct domain *d, struct membank tbl_add[])
 {
     struct acpi_table_header *table = NULL;
@@ -1463,6 +1557,10 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
     if ( rc != 0 )
         return rc;
 
+    rc = acpi_create_madt(d, tbl_add);
+    if ( rc != 0 )
+        return rc;
+
     return 0;
 }
 #else
-- 
2.1.0

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

* [PATCH v3 43/62] arm/acpi: Prepare MADT table for Dom0
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

Copy and modify MADT table before passing it to Dom0. Copy
dom0_max_vcpus of GICCs and GICD as well.

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

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 5d03dc0..4591955 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1359,6 +1359,100 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
 #ifdef CONFIG_ACPI
 #define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */
 
+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_madt_generic_distributor gicd;
+    u64 table_size = sizeof(struct acpi_table_madt);
+    acpi_status status;
+    int i;
+    u8 *base_ptr;
+    u8 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
+               + acpi_get_table_offset(tbl_add, TBL_MADT);
+    ACPI_MEMCPY(base_ptr, table, table_size);
+
+    /* Add Generic Distributor */
+    memset(&gicd, 0, sizeof(gicd));
+    gicd.header.type = ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR;
+    gicd.header.length = sizeof(gicd);
+    gicd.base_address = d->arch.vgic.dbase;
+    if ( d->arch.vgic.version == GIC_V2 )
+        gicd.version = ACPI_MADT_GIC_VERSION_V2;
+    else if ( d->arch.vgic.version == GIC_V3 )
+        gicd.version = ACPI_MADT_GIC_VERSION_V3;
+    else
+        gicd.version = ACPI_MADT_GIC_VERSION_NONE;
+    ACPI_MEMCPY(base_ptr + table_size, &gicd, sizeof(gicd));
+    table_size += sizeof(gicd);
+
+    if ( d->arch.vgic.version == GIC_V3 ) {
+        /* Add Generic Redistributor */
+        for ( i = 0; i < d->arch.vgic.nr_regions; i++ ) {
+            struct acpi_madt_generic_redistributor gicr;
+
+            memset(&gicr, 0, sizeof(gicr));
+            gicr.header.type = ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR;
+            gicr.header.length = sizeof(gicr);
+            gicr.base_address = d->arch.vgic.rdist_regions[i].base;
+            gicr.length = d->arch.vgic.rdist_regions[i].size;
+            ACPI_MEMCPY(base_ptr + table_size, &gicr, sizeof(gicr));
+            table_size += sizeof(gicr);
+        }
+    } else {
+        /* Add Generic Interrupt */
+        for ( i = 0; i < d->max_vcpus; i++ )
+        {
+            struct acpi_madt_generic_interrupt gicc;
+            u64 mpidr = 0;
+            u32 id = i, j = 0;
+
+            memset(&gicc, 0, sizeof(gicc));
+            gicc.header.type = ACPI_MADT_TYPE_GENERIC_INTERRUPT;
+            gicc.header.length = sizeof(gicc);
+            gicc.cpu_interface_number = i;
+            gicc.uid = i;
+            gicc.flags = ACPI_MADT_ENABLED;
+            gicc.base_address = d->arch.vgic.cbase;
+
+            do {
+                mpidr |= (id % 4) << (8 * j);
+                j++;
+                if ( j ==3 )
+                    j++;
+                id = id / 4;
+            } while(id > 0);
+            gicc.arm_mpidr = mpidr;
+
+            ACPI_MEMCPY(base_ptr + table_size, &gicc, sizeof(gicc));
+            table_size += sizeof(gicc);
+        }
+    }
+
+    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
+                              + acpi_get_table_offset(tbl_add, TBL_MADT);
+    tbl_add[TBL_MADT].size = table_size;
+
+    return 0;
+}
+
 static int acpi_create_fadt(struct domain *d, struct membank tbl_add[])
 {
     struct acpi_table_header *table = NULL;
@@ -1463,6 +1557,10 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
     if ( rc != 0 )
         return rc;
 
+    rc = acpi_create_madt(d, tbl_add);
+    if ( rc != 0 )
+        return rc;
+
     return 0;
 }
 #else
-- 
2.1.0

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

* [PATCH v3 44/62] ACPICA: ACPI 6.0: Add support for STAO table
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

From: Bob Moore <robert.moore@intel.com>

ACPICA commit 532bf402a503061afd9d80a23e1d3c8fd99b052c

_STA override table.

Link: https://github.com/acpica/acpica/commit/532bf402
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
[Linux commit 37e12657f8922ebc62f696494c56c81db509053e]
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/include/acpi/actbl3.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/xen/include/acpi/actbl3.h b/xen/include/acpi/actbl3.h
index fc96963..cb9e1c0 100644
--- a/xen/include/acpi/actbl3.h
+++ b/xen/include/acpi/actbl3.h
@@ -68,6 +68,7 @@
 #define ACPI_SIG_PCCT           "PCCT"	/* Platform Communications Channel Table */
 #define ACPI_SIG_PMTT           "PMTT"	/* Platform Memory Topology Table */
 #define ACPI_SIG_RASF           "RASF"	/* RAS Feature table */
+#define ACPI_SIG_STAO           "STAO" /* Status Override table */
 
 #define ACPI_SIG_S3PT           "S3PT"	/* S3 Performance (sub)Table */
 #define ACPI_SIG_PCCS           "PCC"	/* PCC Shared Memory Region */
@@ -618,6 +619,21 @@ enum acpi_rasf_status {
 #define ACPI_RASF_ERROR                 (1<<2)
 #define ACPI_RASF_STATUS                (0x1F<<3)
 
+/*******************************************************************************
+ *
+ * STAO - Status Override Table (_STA override) - ACPI 6.0
+ *        Version 1
+ *
+ * Conforms to "ACPI Specification for Status Override Table"
+ * 6 January 2015
+ *
+ ******************************************************************************/
+
+struct acpi_table_stao {
+	struct acpi_table_header header;	/* Common ACPI table header */
+	u8 ignore_uart;
+};
+
 /* Reset to default packing */
 
 #pragma pack()
-- 
2.1.0

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

* [PATCH v3 44/62] ACPICA: ACPI 6.0: Add support for STAO table
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

From: Bob Moore <robert.moore@intel.com>

ACPICA commit 532bf402a503061afd9d80a23e1d3c8fd99b052c

_STA override table.

Link: https://github.com/acpica/acpica/commit/532bf402
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
[Linux commit 37e12657f8922ebc62f696494c56c81db509053e]
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/include/acpi/actbl3.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/xen/include/acpi/actbl3.h b/xen/include/acpi/actbl3.h
index fc96963..cb9e1c0 100644
--- a/xen/include/acpi/actbl3.h
+++ b/xen/include/acpi/actbl3.h
@@ -68,6 +68,7 @@
 #define ACPI_SIG_PCCT           "PCCT"	/* Platform Communications Channel Table */
 #define ACPI_SIG_PMTT           "PMTT"	/* Platform Memory Topology Table */
 #define ACPI_SIG_RASF           "RASF"	/* RAS Feature table */
+#define ACPI_SIG_STAO           "STAO" /* Status Override table */
 
 #define ACPI_SIG_S3PT           "S3PT"	/* S3 Performance (sub)Table */
 #define ACPI_SIG_PCCS           "PCC"	/* PCC Shared Memory Region */
@@ -618,6 +619,21 @@ enum acpi_rasf_status {
 #define ACPI_RASF_ERROR                 (1<<2)
 #define ACPI_RASF_STATUS                (0x1F<<3)
 
+/*******************************************************************************
+ *
+ * STAO - Status Override Table (_STA override) - ACPI 6.0
+ *        Version 1
+ *
+ * Conforms to "ACPI Specification for Status Override Table"
+ * 6 January 2015
+ *
+ ******************************************************************************/
+
+struct acpi_table_stao {
+	struct acpi_table_header header;	/* Common ACPI table header */
+	u8 ignore_uart;
+};
+
 /* Reset to default packing */
 
 #pragma pack()
-- 
2.1.0

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

* [PATCH v3 45/62] arm/acpi: Prepare STAO table for Dom0
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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 | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 4591955..fb3f150 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1359,6 +1359,45 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
 #ifdef CONFIG_ACPI
 #define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */
 
+static int acpi_create_stao(struct domain *d, struct membank tbl_add[])
+{
+    struct acpi_table_header *table = NULL;
+    struct acpi_table_stao *stao = NULL;
+    u64 table_size = sizeof(struct acpi_table_stao);
+    acpi_status status;
+    u8 *base_ptr;
+    u8 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
+               + acpi_get_table_offset(tbl_add, TBL_STAO);
+    /* Copy header of one table, here use MADT */
+    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 = stao->header.checksum - checksum;
+
+    tbl_add[TBL_STAO].start = d->arch.efi_acpi_gpa
+                              + acpi_get_table_offset(tbl_add, TBL_STAO);
+    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;
@@ -1561,6 +1600,10 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
     if ( rc != 0 )
         return rc;
 
+    rc = acpi_create_stao(d, tbl_add);
+    if ( rc != 0 )
+        return rc;
+
     return 0;
 }
 #else
-- 
2.1.0

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

* [PATCH v3 45/62] arm/acpi: Prepare STAO table for Dom0
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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 | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 4591955..fb3f150 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1359,6 +1359,45 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
 #ifdef CONFIG_ACPI
 #define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */
 
+static int acpi_create_stao(struct domain *d, struct membank tbl_add[])
+{
+    struct acpi_table_header *table = NULL;
+    struct acpi_table_stao *stao = NULL;
+    u64 table_size = sizeof(struct acpi_table_stao);
+    acpi_status status;
+    u8 *base_ptr;
+    u8 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
+               + acpi_get_table_offset(tbl_add, TBL_STAO);
+    /* Copy header of one table, here use MADT */
+    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 = stao->header.checksum - checksum;
+
+    tbl_add[TBL_STAO].start = d->arch.efi_acpi_gpa
+                              + acpi_get_table_offset(tbl_add, TBL_STAO);
+    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;
@@ -1561,6 +1600,10 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
     if ( rc != 0 )
         return rc;
 
+    rc = acpi_create_stao(d, tbl_add);
+    if ( rc != 0 )
+        return rc;
+
     return 0;
 }
 #else
-- 
2.1.0

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

* [PATCH v3 46/62] arm/acpi: Prepare XSDT table for Dom0
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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>
---
 xen/arch/arm/domain_build.c | 71 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 71 insertions(+)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index fb3f150..894328f 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1359,6 +1359,73 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
 #ifdef CONFIG_ACPI
 #define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */
 
+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));
+
+    table_size = table->length + sizeof(u64); /* Add place for STAO table */
+    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;
@@ -1604,6 +1671,10 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
     if ( rc != 0 )
         return rc;
 
+    rc = acpi_create_xsdt(d, tbl_add);
+    if ( rc != 0 )
+        return rc;
+
     return 0;
 }
 #else
-- 
2.1.0

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

* [PATCH v3 46/62] arm/acpi: Prepare XSDT table for Dom0
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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>
---
 xen/arch/arm/domain_build.c | 71 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 71 insertions(+)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index fb3f150..894328f 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1359,6 +1359,73 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
 #ifdef CONFIG_ACPI
 #define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */
 
+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));
+
+    table_size = table->length + sizeof(u64); /* Add place for STAO table */
+    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;
@@ -1604,6 +1671,10 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
     if ( rc != 0 )
         return rc;
 
+    rc = acpi_create_xsdt(d, tbl_add);
+    if ( rc != 0 )
+        return rc;
+
     return 0;
 }
 #else
-- 
2.1.0

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

* [PATCH v3 47/62] arm/p2m: Add helper functions to map memory regions
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

Create a helper function for mapping with cached attributes.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 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 e396c40..7a108d8 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -1140,6 +1140,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,
+                             d->arch.p2m.default_access);
+}
+
+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,
+                             d->arch.p2m.default_access);
+}
+
 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 08bdce3..b6215f9 100644
--- a/xen/include/asm-arm/p2m.h
+++ b/xen/include/asm-arm/p2m.h
@@ -158,6 +158,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.1.0

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

* [PATCH v3 47/62] arm/p2m: Add helper functions to map memory regions
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

Create a helper function for mapping with cached attributes.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 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 e396c40..7a108d8 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -1140,6 +1140,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,
+                             d->arch.p2m.default_access);
+}
+
+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,
+                             d->arch.p2m.default_access);
+}
+
 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 08bdce3..b6215f9 100644
--- a/xen/include/asm-arm/p2m.h
+++ b/xen/include/asm-arm/p2m.h
@@ -158,6 +158,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.1.0

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

* [PATCH v3 48/62] arm/acpi: Prepare RSDP table for Dom0
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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>
---
 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 894328f..6ae5761 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1359,6 +1359,38 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
 #ifdef CONFIG_ACPI
 #define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */
 
+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)
 {
@@ -1675,6 +1707,10 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
     if ( rc != 0 )
         return rc;
 
+    rc = acpi_create_rsdp(d, tbl_add);
+    if ( rc != 0 )
+        return rc;
+
     return 0;
 }
 #else
-- 
2.1.0

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

* [PATCH v3 48/62] arm/acpi: Prepare RSDP table for Dom0
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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>
---
 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 894328f..6ae5761 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1359,6 +1359,38 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
 #ifdef CONFIG_ACPI
 #define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */
 
+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)
 {
@@ -1675,6 +1707,10 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
     if ( rc != 0 )
         return rc;
 
+    rc = acpi_create_rsdp(d, tbl_add);
+    if ( rc != 0 )
+        return rc;
+
     return 0;
 }
 #else
-- 
2.1.0

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

* [PATCH v3 49/62] arm/acpi: Map rest tables for Dom0
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

Map other reused tables for Dom0.

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

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 6ae5761..da4e271 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1359,6 +1359,29 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
 #ifdef CONFIG_ACPI
 #define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */
 
+static void acpi_map_rest_tables(struct domain *d)
+{
+    int i;
+    unsigned long res;
+    u64 addr, size;
+
+    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[])
 {
 
@@ -1711,6 +1734,8 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
     if ( rc != 0 )
         return rc;
 
+    acpi_map_rest_tables(d);
+
     return 0;
 }
 #else
-- 
2.1.0

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

* [PATCH v3 49/62] arm/acpi: Map rest tables for Dom0
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

Map other reused tables for Dom0.

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

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 6ae5761..da4e271 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1359,6 +1359,29 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
 #ifdef CONFIG_ACPI
 #define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */
 
+static void acpi_map_rest_tables(struct domain *d)
+{
+    int i;
+    unsigned long res;
+    u64 addr, size;
+
+    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[])
 {
 
@@ -1711,6 +1734,8 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
     if ( rc != 0 )
         return rc;
 
+    acpi_map_rest_tables(d);
+
     return 0;
 }
 #else
-- 
2.1.0

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

* [PATCH v3 50/62] xen/efi: store EFI system table in efi structure
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

When preparing EFI tables for Dom0, it needs the information of EFI
system table. Here store it in efi structure.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/common/efi/boot.c | 2 ++
 xen/include/xen/efi.h | 1 +
 2 files changed, 3 insertions(+)

diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
index 78d8ae9..6a48624 100644
--- a/xen/common/efi/boot.c
+++ b/xen/common/efi/boot.c
@@ -1155,6 +1155,8 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
 
     efi_tables();
 
+    efi.est = (long)SystemTable;
+
     /* Collect PCI ROM contents. */
     setup_efi_pci();
 
diff --git a/xen/include/xen/efi.h b/xen/include/xen/efi.h
index e74dad1..e112296 100644
--- a/xen/include/xen/efi.h
+++ b/xen/include/xen/efi.h
@@ -16,6 +16,7 @@ struct efi {
     unsigned long acpi20;       /* ACPI table (ACPI 2.0) */
     unsigned long smbios;       /* SM BIOS table */
     unsigned long smbios3;      /* SMBIOS v3 table */
+    unsigned long est;          /* EFI system table */
 };
 
 extern struct efi efi;
-- 
2.1.0

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

* [PATCH v3 50/62] xen/efi: store EFI system table in efi structure
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

When preparing EFI tables for Dom0, it needs the information of EFI
system table. Here store it in efi structure.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/common/efi/boot.c | 2 ++
 xen/include/xen/efi.h | 1 +
 2 files changed, 3 insertions(+)

diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
index 78d8ae9..6a48624 100644
--- a/xen/common/efi/boot.c
+++ b/xen/common/efi/boot.c
@@ -1155,6 +1155,8 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
 
     efi_tables();
 
+    efi.est = (long)SystemTable;
+
     /* Collect PCI ROM contents. */
     setup_efi_pci();
 
diff --git a/xen/include/xen/efi.h b/xen/include/xen/efi.h
index e74dad1..e112296 100644
--- a/xen/include/xen/efi.h
+++ b/xen/include/xen/efi.h
@@ -16,6 +16,7 @@ struct efi {
     unsigned long acpi20;       /* ACPI table (ACPI 2.0) */
     unsigned long smbios;       /* SM BIOS table */
     unsigned long smbios3;      /* SMBIOS v3 table */
+    unsigned long est;          /* EFI system table */
 };
 
 extern struct efi efi;
-- 
2.1.0

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

* [PATCH v3 51/62] arm/acpi: Prepare EFI system table for Dom0
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/domain_build.c |  2 ++
 xen/common/efi/boot.c       | 64 +++++++++++++++++++++++++++++++++++++++++++++
 xen/include/asm-arm/setup.h |  3 +++
 3 files changed, 69 insertions(+)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index da4e271..9d667ea 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1735,6 +1735,8 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
         return rc;
 
     acpi_map_rest_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 6a48624..75835ae 100644
--- a/xen/common/efi/boot.c
+++ b/xen/common/efi/boot.c
@@ -1192,6 +1192,70 @@ int __init estimate_efi_size(int mem_nr_banks)
 
     return size;
 }
+
+static uint32_t __init xz_crc32(uint8_t *buf, size_t size, uint32_t crc)
+{
+    uint32_t xz_crc32_table[256];
+    const uint32_t poly = 0xEDB88320;
+    uint32_t i;
+    uint32_t j;
+    uint32_t r;
+
+    for (i = 0; i < 256; ++i) {
+        r = i;
+        for (j = 0; j < 8; ++j)
+            r = (r >> 1) ^ (poly & ~((r & 1) - 1));
+
+        xz_crc32_table[i] = r;
+    }
+
+    crc = ~crc;
+    while (size != 0) {
+            crc = xz_crc32_table[*buf++ ^ (crc & 0xFF)] ^ (crc >> 8);
+            --size;
+    }
+
+    return ~crc;
+}
+
+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;
+    EFI_SYSTEM_TABLE *est = (EFI_SYSTEM_TABLE *)maddr_to_virt(efi.est);
+
+    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;
+
+    memcpy((EFI_TABLE_HEADER *)&(efi_sys_tbl->Hdr),
+           (EFI_TABLE_HEADER *)&(est->Hdr), sizeof(EFI_TABLE_HEADER));
+    efi_sys_tbl->Hdr.HeaderSize = table_size;
+
+    efi_sys_tbl->FirmwareRevision = est->FirmwareRevision;
+    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);
+    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.1.0

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

* [PATCH v3 51/62] arm/acpi: Prepare EFI system table for Dom0
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/domain_build.c |  2 ++
 xen/common/efi/boot.c       | 64 +++++++++++++++++++++++++++++++++++++++++++++
 xen/include/asm-arm/setup.h |  3 +++
 3 files changed, 69 insertions(+)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index da4e271..9d667ea 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1735,6 +1735,8 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
         return rc;
 
     acpi_map_rest_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 6a48624..75835ae 100644
--- a/xen/common/efi/boot.c
+++ b/xen/common/efi/boot.c
@@ -1192,6 +1192,70 @@ int __init estimate_efi_size(int mem_nr_banks)
 
     return size;
 }
+
+static uint32_t __init xz_crc32(uint8_t *buf, size_t size, uint32_t crc)
+{
+    uint32_t xz_crc32_table[256];
+    const uint32_t poly = 0xEDB88320;
+    uint32_t i;
+    uint32_t j;
+    uint32_t r;
+
+    for (i = 0; i < 256; ++i) {
+        r = i;
+        for (j = 0; j < 8; ++j)
+            r = (r >> 1) ^ (poly & ~((r & 1) - 1));
+
+        xz_crc32_table[i] = r;
+    }
+
+    crc = ~crc;
+    while (size != 0) {
+            crc = xz_crc32_table[*buf++ ^ (crc & 0xFF)] ^ (crc >> 8);
+            --size;
+    }
+
+    return ~crc;
+}
+
+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;
+    EFI_SYSTEM_TABLE *est = (EFI_SYSTEM_TABLE *)maddr_to_virt(efi.est);
+
+    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;
+
+    memcpy((EFI_TABLE_HEADER *)&(efi_sys_tbl->Hdr),
+           (EFI_TABLE_HEADER *)&(est->Hdr), sizeof(EFI_TABLE_HEADER));
+    efi_sys_tbl->Hdr.HeaderSize = table_size;
+
+    efi_sys_tbl->FirmwareRevision = est->FirmwareRevision;
+    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);
+    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.1.0

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

* [PATCH v3 52/62] arm/acpi: Prepare EFI memory descriptor for Dom0
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/domain_build.c |  2 ++
 xen/common/efi/boot.c       | 48 +++++++++++++++++++++++++++++++++++++++++++++
 xen/include/asm-arm/setup.h |  4 ++++
 3 files changed, 54 insertions(+)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 9d667ea..073c634 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1737,6 +1737,8 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
     acpi_map_rest_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_table,
+                               &kinfo->mem, tbl_add);
 
     return 0;
 }
diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
index 75835ae..ff2faed 100644
--- a/xen/common/efi/boot.c
+++ b/xen/common/efi/boot.c
@@ -1256,6 +1256,54 @@ 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, 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 + TBL_MMAX);
+    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 = mem->bank[i].size/PAGE_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 = acpi_mem.bank[i].size/PAGE_SIZE;
+        memory_map[offset].Attribute = EFI_MEMORY_WB;
+    }
+
+    for( i = 0; i < TBL_EFIT; i++, offset++ )
+    {
+        memory_map[offset].Type = EfiACPIReclaimMemory;
+        memory_map[offset].PhysicalStart = tbl_add[i].start;
+        memory_map[offset].NumberOfPages =tbl_add[i].size/PAGE_SIZE;
+        memory_map[offset].Attribute = EFI_MEMORY_WB;
+    }
+
+    for( i = TBL_EFIT; i < TBL_MMAX; i++, offset++ )
+    {
+        memory_map[offset].Type = EfiReservedMemoryType;
+        memory_map[offset].PhysicalStart = tbl_add[i].start;
+        memory_map[offset].NumberOfPages =tbl_add[i].size/PAGE_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..35447ee 100644
--- a/xen/include/asm-arm/setup.h
+++ b/xen/include/asm-arm/setup.h
@@ -56,6 +56,10 @@ 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, void *efi_acpi_table,
+                                const struct meminfo *mem,
+                                struct membank tbl_add[]);
+
 int construct_dom0(struct domain *d);
 
 void discard_initial_modules(void);
-- 
2.1.0

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

* [PATCH v3 52/62] arm/acpi: Prepare EFI memory descriptor for Dom0
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/domain_build.c |  2 ++
 xen/common/efi/boot.c       | 48 +++++++++++++++++++++++++++++++++++++++++++++
 xen/include/asm-arm/setup.h |  4 ++++
 3 files changed, 54 insertions(+)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 9d667ea..073c634 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1737,6 +1737,8 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
     acpi_map_rest_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_table,
+                               &kinfo->mem, tbl_add);
 
     return 0;
 }
diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
index 75835ae..ff2faed 100644
--- a/xen/common/efi/boot.c
+++ b/xen/common/efi/boot.c
@@ -1256,6 +1256,54 @@ 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, 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 + TBL_MMAX);
+    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 = mem->bank[i].size/PAGE_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 = acpi_mem.bank[i].size/PAGE_SIZE;
+        memory_map[offset].Attribute = EFI_MEMORY_WB;
+    }
+
+    for( i = 0; i < TBL_EFIT; i++, offset++ )
+    {
+        memory_map[offset].Type = EfiACPIReclaimMemory;
+        memory_map[offset].PhysicalStart = tbl_add[i].start;
+        memory_map[offset].NumberOfPages =tbl_add[i].size/PAGE_SIZE;
+        memory_map[offset].Attribute = EFI_MEMORY_WB;
+    }
+
+    for( i = TBL_EFIT; i < TBL_MMAX; i++, offset++ )
+    {
+        memory_map[offset].Type = EfiReservedMemoryType;
+        memory_map[offset].PhysicalStart = tbl_add[i].start;
+        memory_map[offset].NumberOfPages =tbl_add[i].size/PAGE_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..35447ee 100644
--- a/xen/include/asm-arm/setup.h
+++ b/xen/include/asm-arm/setup.h
@@ -56,6 +56,10 @@ 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, void *efi_acpi_table,
+                                const struct meminfo *mem,
+                                struct membank tbl_add[]);
+
 int construct_dom0(struct domain *d);
 
 void discard_initial_modules(void);
-- 
2.1.0

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

* [PATCH v3 53/62] arm/acpi: Map the new created EFI and ACPI tables to Dom0
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

Here we map these new created EFI and ACPI tables to the non-RAM space
of Dom0. Then Dom0 could visit them.

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 073c634..55f85b4 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1740,6 +1740,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_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),
+                     DIV_ROUND_UP(d->arch.efi_acpi_len, PAGE_SIZE),
+                     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.1.0

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

* [PATCH v3 53/62] arm/acpi: Map the new created EFI and ACPI tables to Dom0
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

Here we map these new created EFI and ACPI tables to the non-RAM space
of Dom0. Then Dom0 could visit them.

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 073c634..55f85b4 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1740,6 +1740,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_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),
+                     DIV_ROUND_UP(d->arch.efi_acpi_len, PAGE_SIZE),
+                     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.1.0

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

* [PATCH v3 54/62] arm/acpi: Create min DT stub for Dom0
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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.

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>
---
 xen/arch/arm/domain_build.c | 142 ++++++++++++++++++++++++++++++++++++++++++++
 xen/common/efi/boot.c       |  47 +++++++++++++++
 xen/include/asm-arm/setup.h |   2 +
 3 files changed, 191 insertions(+)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 55f85b4..6d8536b 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1358,6 +1358,144 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
 
 #ifdef CONFIG_ACPI
 #define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */
+#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_rest_tables(struct domain *d)
 {
@@ -1755,6 +1893,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 ff2faed..d233cef 100644
--- a/xen/common/efi/boot.c
+++ b/xen/common/efi/boot.c
@@ -1304,6 +1304,53 @@ void __init acpi_create_efi_mmap_table(paddr_t paddr, void *efi_acpi_table,
         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 35447ee..c4cf5ea 100644
--- a/xen/include/asm-arm/setup.h
+++ b/xen/include/asm-arm/setup.h
@@ -60,6 +60,8 @@ void acpi_create_efi_mmap_table(paddr_t paddr, void *efi_acpi_table,
                                 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.1.0

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

* [PATCH v3 54/62] arm/acpi: Create min DT stub for Dom0
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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.

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>
---
 xen/arch/arm/domain_build.c | 142 ++++++++++++++++++++++++++++++++++++++++++++
 xen/common/efi/boot.c       |  47 +++++++++++++++
 xen/include/asm-arm/setup.h |   2 +
 3 files changed, 191 insertions(+)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 55f85b4..6d8536b 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1358,6 +1358,144 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
 
 #ifdef CONFIG_ACPI
 #define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */
+#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_rest_tables(struct domain *d)
 {
@@ -1755,6 +1893,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 ff2faed..d233cef 100644
--- a/xen/common/efi/boot.c
+++ b/xen/common/efi/boot.c
@@ -1304,6 +1304,53 @@ void __init acpi_create_efi_mmap_table(paddr_t paddr, void *efi_acpi_table,
         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 35447ee..c4cf5ea 100644
--- a/xen/include/asm-arm/setup.h
+++ b/xen/include/asm-arm/setup.h
@@ -60,6 +60,8 @@ void acpi_create_efi_mmap_table(paddr_t paddr, void *efi_acpi_table,
                                 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.1.0

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

* [PATCH v3 55/62] arm/acpi: Route all Xen unused SPIs to Dom0
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

Route all SPIs to Dom0 except the interrupts that Xen uses. Since Xen
already uses the uart interrupt, the desc->action will not be NULL, so
it will skip it.

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

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 6d8536b..6945f89 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1360,6 +1360,35 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
 #define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */
 #define ACPI_DOM0_FDT_MIN_SIZE 4096
 
+static int acpi_route_spi(struct domain *d)
+{
+    int i, res;
+    struct irq_desc *desc;
+
+    /* Don't route Xen used interrupt to Dom0. Since Xen already uses the uart
+     * interrupt, the desc->action will not be NULL, so it will skip it.
+     */
+    for( i = NR_LOCAL_IRQS; i < vgic_num_irqs(d); i++ )
+    {
+        /* Don't route uart interrupt to Dom0 */
+        desc = irq_to_desc(i);
+        if( desc->action != NULL)
+            continue;
+
+        vgic_reserve_virq(d, i);
+        irq_set_type(i, ACPI_IRQ_TYPE_NONE);
+        res = route_irq_to_guest(d, i, i, NULL);
+        if ( res )
+        {
+            printk(XENLOG_ERR "Unable to route IRQ %u to domain %u\n",
+                   i, d->domain_id);
+            continue;
+        }
+    }
+
+    return 0;
+}
+
 static int make_chosen_node(const struct kernel_info *kinfo,
                             struct membank tbl_add[])
 {
@@ -1897,6 +1926,10 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
     if ( rc != 0 )
         return rc;
 
+    rc = acpi_route_spi(d);
+    if ( rc != 0 )
+        return rc;
+
     return 0;
 }
 #else
-- 
2.1.0

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

* [PATCH v3 55/62] arm/acpi: Route all Xen unused SPIs to Dom0
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

Route all SPIs to Dom0 except the interrupts that Xen uses. Since Xen
already uses the uart interrupt, the desc->action will not be NULL, so
it will skip it.

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

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 6d8536b..6945f89 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1360,6 +1360,35 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
 #define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */
 #define ACPI_DOM0_FDT_MIN_SIZE 4096
 
+static int acpi_route_spi(struct domain *d)
+{
+    int i, res;
+    struct irq_desc *desc;
+
+    /* Don't route Xen used interrupt to Dom0. Since Xen already uses the uart
+     * interrupt, the desc->action will not be NULL, so it will skip it.
+     */
+    for( i = NR_LOCAL_IRQS; i < vgic_num_irqs(d); i++ )
+    {
+        /* Don't route uart interrupt to Dom0 */
+        desc = irq_to_desc(i);
+        if( desc->action != NULL)
+            continue;
+
+        vgic_reserve_virq(d, i);
+        irq_set_type(i, ACPI_IRQ_TYPE_NONE);
+        res = route_irq_to_guest(d, i, i, NULL);
+        if ( res )
+        {
+            printk(XENLOG_ERR "Unable to route IRQ %u to domain %u\n",
+                   i, d->domain_id);
+            continue;
+        }
+    }
+
+    return 0;
+}
+
 static int make_chosen_node(const struct kernel_info *kinfo,
                             struct membank tbl_add[])
 {
@@ -1897,6 +1926,10 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
     if ( rc != 0 )
         return rc;
 
+    rc = acpi_route_spi(d);
+    if ( rc != 0 )
+        return rc;
+
     return 0;
 }
 #else
-- 
2.1.0

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

* [PATCH v3 56/62] arm/acpi: Deny MMIO access of UART
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

Firstly it permits full MMIO capabilities for Dom0. Then deny MMIO
access of UART device.

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

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 6945f89..9532807 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1360,6 +1360,32 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
 #define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */
 #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;
+
+    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_route_spi(struct domain *d)
 {
     int i, res;
@@ -1930,6 +1956,10 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
     if ( rc != 0 )
         return rc;
 
+    rc = acpi_iomem_deny_access(d);
+    if ( rc != 0 )
+        return rc;
+
     return 0;
 }
 #else
-- 
2.1.0

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

* [PATCH v3 56/62] arm/acpi: Deny MMIO access of UART
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

Firstly it permits full MMIO capabilities for Dom0. Then deny MMIO
access of UART device.

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

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 6945f89..9532807 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1360,6 +1360,32 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
 #define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */
 #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;
+
+    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_route_spi(struct domain *d)
 {
     int i, res;
@@ -1930,6 +1956,10 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
     if ( rc != 0 )
         return rc;
 
+    rc = acpi_iomem_deny_access(d);
+    if ( rc != 0 )
+        return rc;
+
     return 0;
 }
 #else
-- 
2.1.0

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

* [PATCH v3 57/62] hvm/params: Add a new dilivery type for event-channel in HVM_PARAM_CALLBACK_IRQ
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/include/public/hvm/params.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/xen/include/public/hvm/params.h b/xen/include/public/hvm/params.h
index 356dfd3..5aa2aba 100644
--- a/xen/include/public/hvm/params.h
+++ b/xen/include/public/hvm/params.h
@@ -38,6 +38,11 @@
  * val[63:56] == 2: val[7:0] is a vector number, check for
  *                  XENFEAT_hvm_callback_vector to know if this delivery
  *                  method is available.
+ * val[63:56] == 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.
  * If val == 0 then CPU0 event-channel notifications are not delivered.
  */
 #define HVM_PARAM_CALLBACK_IRQ 0
-- 
2.1.0

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

* [PATCH v3 57/62] hvm/params: Add a new dilivery type for event-channel in HVM_PARAM_CALLBACK_IRQ
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/include/public/hvm/params.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/xen/include/public/hvm/params.h b/xen/include/public/hvm/params.h
index 356dfd3..5aa2aba 100644
--- a/xen/include/public/hvm/params.h
+++ b/xen/include/public/hvm/params.h
@@ -38,6 +38,11 @@
  * val[63:56] == 2: val[7:0] is a vector number, check for
  *                  XENFEAT_hvm_callback_vector to know if this delivery
  *                  method is available.
+ * val[63:56] == 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.
  * If val == 0 then CPU0 event-channel notifications are not delivered.
  */
 #define HVM_PARAM_CALLBACK_IRQ 0
-- 
2.1.0

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

* [PATCH v3 58/62] xen/acpi: Fix event-channel interrupt when booting with ACPI
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

When booting with ACPI, 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>
---
 xen/arch/arm/domain_build.c | 45 ++++++++++++++++++++++++++++-----------------
 1 file changed, 28 insertions(+), 17 deletions(-)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 9532807..36917be 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -2067,23 +2067,34 @@ static void evtchn_fixup(struct domain *d, struct kernel_info *kinfo)
     printk("Allocating PPI %u for event channel interrupt\n",
            d->arch.evtchn_irq);
 
-    /* Fix up "interrupts" in /hypervisor node */
-    node = fdt_path_offset(kinfo->fdt, "/hypervisor");
-    if ( node < 0 )
-        panic("Cannot find the /hypervisor node");
-
-    /* Interrupt event channel upcall:
-     *  - Active-low level-sensitive
-     *  - All CPUs
-     *
-     *  TODO: Handle properly the cpumask
-     */
-    set_interrupt_ppi(intr, d->arch.evtchn_irq, 0xf,
-                      DT_IRQ_TYPE_LEVEL_LOW);
-    res = fdt_setprop_inplace(kinfo->fdt, node, "interrupts",
-                              &intr, sizeof(intr));
-    if ( res )
-        panic("Cannot fix up \"interrupts\" property of the hypervisor node");
+    if ( acpi_disabled )
+    {
+        /* Fix up "interrupts" in /hypervisor node */
+        node = fdt_path_offset(kinfo->fdt, "/hypervisor");
+        if ( node < 0 )
+            panic("Cannot find the /hypervisor node");
+
+        /* Interrupt event channel upcall:
+         *  - Active-low level-sensitive
+         *  - All CPUs
+         *
+         *  TODO: Handle properly the cpumask
+         */
+        set_interrupt_ppi(intr, d->arch.evtchn_irq, 0xf,
+                          DT_IRQ_TYPE_LEVEL_LOW);
+        res = fdt_setprop_inplace(kinfo->fdt, node, "interrupts",
+                                  &intr, sizeof(intr));
+        if ( res )
+            panic("Cannot fix up \"interrupts\" property of the hypervisor node");
+    }
+    else
+    {
+        int type = 3;
+        int flag = 2; /* Active-low level-sensitive  */
+        d->arch.hvm_domain.params[HVM_PARAM_CALLBACK_IRQ] = (u64)type << 56
+                                                            | flag << 8
+                                                            | d->arch.evtchn_irq;
+    }
 }
 
 static void __init find_gnttab_region(struct domain *d,
-- 
2.1.0

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

* [PATCH v3 58/62] xen/acpi: Fix event-channel interrupt when booting with ACPI
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

When booting with ACPI, 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>
---
 xen/arch/arm/domain_build.c | 45 ++++++++++++++++++++++++++++-----------------
 1 file changed, 28 insertions(+), 17 deletions(-)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 9532807..36917be 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -2067,23 +2067,34 @@ static void evtchn_fixup(struct domain *d, struct kernel_info *kinfo)
     printk("Allocating PPI %u for event channel interrupt\n",
            d->arch.evtchn_irq);
 
-    /* Fix up "interrupts" in /hypervisor node */
-    node = fdt_path_offset(kinfo->fdt, "/hypervisor");
-    if ( node < 0 )
-        panic("Cannot find the /hypervisor node");
-
-    /* Interrupt event channel upcall:
-     *  - Active-low level-sensitive
-     *  - All CPUs
-     *
-     *  TODO: Handle properly the cpumask
-     */
-    set_interrupt_ppi(intr, d->arch.evtchn_irq, 0xf,
-                      DT_IRQ_TYPE_LEVEL_LOW);
-    res = fdt_setprop_inplace(kinfo->fdt, node, "interrupts",
-                              &intr, sizeof(intr));
-    if ( res )
-        panic("Cannot fix up \"interrupts\" property of the hypervisor node");
+    if ( acpi_disabled )
+    {
+        /* Fix up "interrupts" in /hypervisor node */
+        node = fdt_path_offset(kinfo->fdt, "/hypervisor");
+        if ( node < 0 )
+            panic("Cannot find the /hypervisor node");
+
+        /* Interrupt event channel upcall:
+         *  - Active-low level-sensitive
+         *  - All CPUs
+         *
+         *  TODO: Handle properly the cpumask
+         */
+        set_interrupt_ppi(intr, d->arch.evtchn_irq, 0xf,
+                          DT_IRQ_TYPE_LEVEL_LOW);
+        res = fdt_setprop_inplace(kinfo->fdt, node, "interrupts",
+                                  &intr, sizeof(intr));
+        if ( res )
+            panic("Cannot fix up \"interrupts\" property of the hypervisor node");
+    }
+    else
+    {
+        int type = 3;
+        int flag = 2; /* Active-low level-sensitive  */
+        d->arch.hvm_domain.params[HVM_PARAM_CALLBACK_IRQ] = (u64)type << 56
+                                                            | flag << 8
+                                                            | d->arch.evtchn_irq;
+    }
 }
 
 static void __init find_gnttab_region(struct domain *d,
-- 
2.1.0

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

* [PATCH v3 59/62] xen/arm: Add a hypercall for device mmio mapping
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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>
---
 xen/arch/arm/mm.c           |  4 ++++
 xen/arch/arm/p2m.c          | 34 ++++++++++++++++++++++++++++++++++
 xen/include/asm-arm/p2m.h   |  5 +++++
 xen/include/public/memory.h |  1 +
 4 files changed, 44 insertions(+)

diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
index 8b6d915..fbe0406 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 7a108d8..b44ad76 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>
@@ -1192,6 +1193,39 @@ 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 = iomem_permit_access(d, start_gfn, (start_gfn + nr));
+    if ( res )
+    {
+        printk(XENLOG_ERR "Unable to permit to dom%d access to"
+               " 0x%"PRIx64" - 0x%"PRIx64"\n",
+               d->domain_id,
+               start_gfn << PAGE_SHIFT, (start_gfn + nr) << PAGE_SHIFT);
+        return res;
+    }
+
+    res = map_mmio_regions(d, start_gfn, nr, mfn);
+    if ( res < 0 )
+    {
+        printk(XENLOG_ERR "Unable to map 0x%"PRIx64
+               " - 0x%"PRIx64" 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/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h
index b6215f9..5e9d0a1 100644
--- a/xen/include/asm-arm/p2m.h
+++ b/xen/include/asm-arm/p2m.h
@@ -168,6 +168,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 4df38d6..c19da1a 100644
--- a/xen/include/public/memory.h
+++ b/xen/include/public/memory.h
@@ -220,6 +220,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_machphys_mapping_t);
 #define XENMAPSPACE_gmfn_range   3 /* GMFN range, XENMEM_add_to_physmap only. */
 #define XENMAPSPACE_gmfn_foreign 4 /* GMFN from another dom,
                                     * XENMEM_add_to_physmap_batch only. */
+#define XENMAPSPACE_dev_mmio     5 /* device mmio region */
 /* ` } */
 
 /*
-- 
2.1.0

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

* [PATCH v3 59/62] xen/arm: Add a hypercall for device mmio mapping
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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>
---
 xen/arch/arm/mm.c           |  4 ++++
 xen/arch/arm/p2m.c          | 34 ++++++++++++++++++++++++++++++++++
 xen/include/asm-arm/p2m.h   |  5 +++++
 xen/include/public/memory.h |  1 +
 4 files changed, 44 insertions(+)

diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
index 8b6d915..fbe0406 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 7a108d8..b44ad76 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>
@@ -1192,6 +1193,39 @@ 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 = iomem_permit_access(d, start_gfn, (start_gfn + nr));
+    if ( res )
+    {
+        printk(XENLOG_ERR "Unable to permit to dom%d access to"
+               " 0x%"PRIx64" - 0x%"PRIx64"\n",
+               d->domain_id,
+               start_gfn << PAGE_SHIFT, (start_gfn + nr) << PAGE_SHIFT);
+        return res;
+    }
+
+    res = map_mmio_regions(d, start_gfn, nr, mfn);
+    if ( res < 0 )
+    {
+        printk(XENLOG_ERR "Unable to map 0x%"PRIx64
+               " - 0x%"PRIx64" 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/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h
index b6215f9..5e9d0a1 100644
--- a/xen/include/asm-arm/p2m.h
+++ b/xen/include/asm-arm/p2m.h
@@ -168,6 +168,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 4df38d6..c19da1a 100644
--- a/xen/include/public/memory.h
+++ b/xen/include/public/memory.h
@@ -220,6 +220,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_machphys_mapping_t);
 #define XENMAPSPACE_gmfn_range   3 /* GMFN range, XENMEM_add_to_physmap only. */
 #define XENMAPSPACE_gmfn_foreign 4 /* GMFN from another dom,
                                     * XENMEM_add_to_physmap_batch only. */
+#define XENMAPSPACE_dev_mmio     5 /* device mmio region */
 /* ` } */
 
 /*
-- 
2.1.0

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

* [PATCH v3 60/62] arm/acpi: Configure interrupts dynamically
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:40   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:40 UTC (permalink / raw)
  To: linux-arm-kernel

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

Interrupt information is described in DSDT and is not available at
the time of booting. Configure the interrupts dynamically when requested
by Dom0

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/vgic.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c
index 7bb4570..d05abde 100644
--- a/xen/arch/arm/vgic.c
+++ b/xen/arch/arm/vgic.c
@@ -25,6 +25,7 @@
 #include <xen/irq.h>
 #include <xen/sched.h>
 #include <xen/perfc.h>
+#include <xen/acpi.h>
 
 #include <asm/current.h>
 
@@ -310,6 +311,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)
 {
     struct domain *d = v->domain;
@@ -321,7 +324,23 @@ void vgic_enable_irqs(struct vcpu *v, uint32_t r, int n)
     struct vcpu *v_target;
 
     while ( (i = find_next_bit(&mask, 32, i)) < 32 ) {
+#ifdef CONFIG_ACPI
+        struct vgic_irq_rank *vr = vgic_get_rank(v, n);
+        uint32_t tr;
+
         irq = i + (32 * n);
+        if( ( !acpi_disabled ) && ( n != 0 ) && is_hardware_domain(d) )
+        {
+            tr = vr->icfg[i >> 4] ;
+
+            if( ( tr & VGIC_ICFG_MASK(i) ) )
+                irq_set_type(irq, ACPI_IRQ_TYPE_EDGE_BOTH);
+            else
+                irq_set_type(irq, ACPI_IRQ_TYPE_LEVEL_MASK);
+        }
+#else
+        irq = i + (32 * n);
+#endif
         v_target = d->arch.vgic.handler->get_target_vcpu(v, irq);
         p = irq_to_pending(v_target, irq);
         set_bit(GIC_IRQ_GUEST_ENABLED, &p->status);
-- 
2.1.0

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

* [PATCH v3 60/62] arm/acpi: Configure interrupts dynamically
@ 2015-11-17  9:40   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:40 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

Interrupt information is described in DSDT and is not available at
the time of booting. Configure the interrupts dynamically when requested
by Dom0

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/vgic.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c
index 7bb4570..d05abde 100644
--- a/xen/arch/arm/vgic.c
+++ b/xen/arch/arm/vgic.c
@@ -25,6 +25,7 @@
 #include <xen/irq.h>
 #include <xen/sched.h>
 #include <xen/perfc.h>
+#include <xen/acpi.h>
 
 #include <asm/current.h>
 
@@ -310,6 +311,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)
 {
     struct domain *d = v->domain;
@@ -321,7 +324,23 @@ void vgic_enable_irqs(struct vcpu *v, uint32_t r, int n)
     struct vcpu *v_target;
 
     while ( (i = find_next_bit(&mask, 32, i)) < 32 ) {
+#ifdef CONFIG_ACPI
+        struct vgic_irq_rank *vr = vgic_get_rank(v, n);
+        uint32_t tr;
+
         irq = i + (32 * n);
+        if( ( !acpi_disabled ) && ( n != 0 ) && is_hardware_domain(d) )
+        {
+            tr = vr->icfg[i >> 4] ;
+
+            if( ( tr & VGIC_ICFG_MASK(i) ) )
+                irq_set_type(irq, ACPI_IRQ_TYPE_EDGE_BOTH);
+            else
+                irq_set_type(irq, ACPI_IRQ_TYPE_LEVEL_MASK);
+        }
+#else
+        irq = i + (32 * n);
+#endif
         v_target = d->arch.vgic.handler->get_target_vcpu(v, irq);
         p = irq_to_pending(v_target, irq);
         set_bit(GIC_IRQ_GUEST_ENABLED, &p->status);
-- 
2.1.0

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

* [PATCH v3 61/62] arm/acpi: Add acpi parameter to enable/disable acpi
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:41   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:41 UTC (permalink / raw)
  To: linux-arm-kernel

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

ACPI will be disabled by default. Define new command line parameter
"acpi" for enabling it.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/setup.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index 63feadf..1a40323 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -59,6 +59,10 @@ static unsigned long opt_xenheap_megabytes __initdata;
 integer_param("xenheap_megabytes", opt_xenheap_megabytes);
 #endif
 
+/* "acpi=force" : Enables acpi */
+static void parse_acpi_param(char *s);
+custom_param("acpi", parse_acpi_param);
+
 static __used void init_done(void)
 {
     free_init_memory();
@@ -84,6 +88,23 @@ static const char * __initdata processor_implementers[] = {
     ['i'] = "Intel Corporation",
 };
 
+static char __initdata acpi_param[10] = "";
+static void __init parse_acpi_param(char *s)
+{
+    /* Save the parameter so it can be propagated to domain0. */
+    safe_strcpy(acpi_param, s);
+
+    /* Interpret the parameter for use within Xen. */
+    if ( !parse_bool(s) )
+    {
+        disable_acpi();
+    }
+    else if ( !strcmp(s, "force") )
+    {
+        acpi_disabled = 0;
+    }
+}
+
 static void __init processor_id(void)
 {
     const char *implementer = "Unknown";
@@ -729,6 +750,7 @@ void __init start_xen(unsigned long boot_phys_offset,
         + (fdt_paddr & ((1 << SECOND_SHIFT) - 1));
     fdt_size = boot_fdt_info(device_tree_flattened, fdt_paddr);
 
+    disable_acpi();
     cmdline = boot_fdt_cmdline(device_tree_flattened);
     printk("Command line: %s\n", cmdline);
     cmdline_parse(cmdline);
-- 
2.1.0

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

* [PATCH v3 61/62] arm/acpi: Add acpi parameter to enable/disable acpi
@ 2015-11-17  9:41   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:41 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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

ACPI will be disabled by default. Define new command line parameter
"acpi" for enabling it.

Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/setup.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index 63feadf..1a40323 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -59,6 +59,10 @@ static unsigned long opt_xenheap_megabytes __initdata;
 integer_param("xenheap_megabytes", opt_xenheap_megabytes);
 #endif
 
+/* "acpi=force" : Enables acpi */
+static void parse_acpi_param(char *s);
+custom_param("acpi", parse_acpi_param);
+
 static __used void init_done(void)
 {
     free_init_memory();
@@ -84,6 +88,23 @@ static const char * __initdata processor_implementers[] = {
     ['i'] = "Intel Corporation",
 };
 
+static char __initdata acpi_param[10] = "";
+static void __init parse_acpi_param(char *s)
+{
+    /* Save the parameter so it can be propagated to domain0. */
+    safe_strcpy(acpi_param, s);
+
+    /* Interpret the parameter for use within Xen. */
+    if ( !parse_bool(s) )
+    {
+        disable_acpi();
+    }
+    else if ( !strcmp(s, "force") )
+    {
+        acpi_disabled = 0;
+    }
+}
+
 static void __init processor_id(void)
 {
     const char *implementer = "Unknown";
@@ -729,6 +750,7 @@ void __init start_xen(unsigned long boot_phys_offset,
         + (fdt_paddr & ((1 << SECOND_SHIFT) - 1));
     fdt_size = boot_fdt_info(device_tree_flattened, fdt_paddr);
 
+    disable_acpi();
     cmdline = boot_fdt_cmdline(device_tree_flattened);
     printk("Command line: %s\n", cmdline);
     cmdline_parse(cmdline);
-- 
2.1.0

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

* [PATCH v3 62/62] xen/arm64: Add ACPI support
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17  9:41   ` shannon.zhao
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao at linaro.org @ 2015-11-17  9:41 UTC (permalink / raw)
  To: linux-arm-kernel

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>
---
 config/arm64.mk              | 1 +
 xen/common/efi/runtime.c     | 2 +-
 xen/include/asm-arm/config.h | 5 +++++
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/config/arm64.mk b/config/arm64.mk
index c5deb4e..c6a040b 100644
--- a/config/arm64.mk
+++ b/config/arm64.mk
@@ -11,6 +11,7 @@ HAS_CADENCE_UART := y
 HAS_NS16550 := y
 HAS_MEM_ACCESS := y
 HAS_GICV3 := y
+HAS_ACPI := y
 
 # Use only if calling $(LD) directly.
 LDFLAGS_DIRECT += -EL
diff --git a/xen/common/efi/runtime.c b/xen/common/efi/runtime.c
index ae87557..7748056 100644
--- a/xen/common/efi/runtime.c
+++ b/xen/common/efi/runtime.c
@@ -11,7 +11,7 @@ DEFINE_XEN_GUEST_HANDLE(CHAR16);
 #ifndef COMPAT
 
 #ifdef CONFIG_ARM  /* Disabled until runtime services implemented */
-const bool_t efi_enabled = 0;
+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 817c216..e87fd27 100644
--- a/xen/include/asm-arm/config.h
+++ b/xen/include/asm-arm/config.h
@@ -33,6 +33,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.1.0

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

* [PATCH v3 62/62] xen/arm64: Add ACPI support
@ 2015-11-17  9:41   ` shannon.zhao
  0 siblings, 0 replies; 426+ messages in thread
From: shannon.zhao @ 2015-11-17  9:41 UTC (permalink / raw)
  To: ian.campbell, stefano.stabellini, keir, jbeulich, andrew.cooper3,
	julien.grall, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, shannon.zhao,
	christoffer.dall, peter.huangpeng, david.vrabel, zhaoshenglong,
	linux-arm-kernel, roger.pau

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>
---
 config/arm64.mk              | 1 +
 xen/common/efi/runtime.c     | 2 +-
 xen/include/asm-arm/config.h | 5 +++++
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/config/arm64.mk b/config/arm64.mk
index c5deb4e..c6a040b 100644
--- a/config/arm64.mk
+++ b/config/arm64.mk
@@ -11,6 +11,7 @@ HAS_CADENCE_UART := y
 HAS_NS16550 := y
 HAS_MEM_ACCESS := y
 HAS_GICV3 := y
+HAS_ACPI := y
 
 # Use only if calling $(LD) directly.
 LDFLAGS_DIRECT += -EL
diff --git a/xen/common/efi/runtime.c b/xen/common/efi/runtime.c
index ae87557..7748056 100644
--- a/xen/common/efi/runtime.c
+++ b/xen/common/efi/runtime.c
@@ -11,7 +11,7 @@ DEFINE_XEN_GUEST_HANDLE(CHAR16);
 #ifndef COMPAT
 
 #ifdef CONFIG_ARM  /* Disabled until runtime services implemented */
-const bool_t efi_enabled = 0;
+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 817c216..e87fd27 100644
--- a/xen/include/asm-arm/config.h
+++ b/xen/include/asm-arm/config.h
@@ -33,6 +33,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.1.0

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

* [PATCH v3 04/62] arm/acpi: Emulate io ports for arm
  2015-11-17  9:40   ` shannon.zhao
@ 2015-11-17  9:50     ` Arnd Bergmann
  -1 siblings, 0 replies; 426+ messages in thread
From: Arnd Bergmann @ 2015-11-17  9:50 UTC (permalink / raw)
  To: linux-arm-kernel

On Tuesday 17 November 2015 17:40:03 shannon.zhao at linaro.org wrote:
> +/*
> + * Emulate x86 io ports for arm.
> + */
> +#define __armio(addr) ( (void __iomem *)addr )
> +
> +#define inb(c) ( readb( __armio(c) ) )
> +#define inw(c) ( readw( __armio(c) ) )
> +#define inl(c) ( readl( __armio(c) ) )
> +
> +#define outb(v, c) ( writeb(v, __armio(c) ) )
> +#define outw(v, c) ( writew(v, __armio(c) ) )
> +#define outl(v, c) ( writel(v, __armio(c) ) )
> +

This is almost certainly wrong. There might be I/O port accesses, but they
won't be in the same place as normal pointers.

	Arnd

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

* Re: [PATCH v3 04/62] arm/acpi: Emulate io ports for arm
@ 2015-11-17  9:50     ` Arnd Bergmann
  0 siblings, 0 replies; 426+ messages in thread
From: Arnd Bergmann @ 2015-11-17  9:50 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, shannon.zhao, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, david.vrabel

On Tuesday 17 November 2015 17:40:03 shannon.zhao@linaro.org wrote:
> +/*
> + * Emulate x86 io ports for arm.
> + */
> +#define __armio(addr) ( (void __iomem *)addr )
> +
> +#define inb(c) ( readb( __armio(c) ) )
> +#define inw(c) ( readw( __armio(c) ) )
> +#define inl(c) ( readl( __armio(c) ) )
> +
> +#define outb(v, c) ( writeb(v, __armio(c) ) )
> +#define outw(v, c) ( writew(v, __armio(c) ) )
> +#define outl(v, c) ( writel(v, __armio(c) ) )
> +

This is almost certainly wrong. There might be I/O port accesses, but they
won't be in the same place as normal pointers.

	Arnd

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

* [PATCH v3 00/62] Add ACPI support for arm64 on Xen
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
@ 2015-11-17 10:59   ` Jan Beulich
  2015-11-17  9:40 ` shannon.zhao at linaro.org
                     ` (66 subsequent siblings)
  67 siblings, 0 replies; 426+ messages in thread
From: Jan Beulich @ 2015-11-17 10:59 UTC (permalink / raw)
  To: linux-arm-kernel

>>> On 17.11.15 at 10:39, <shannon.zhao@linaro.org> wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> This patch set adds ACPI support for arm64 on Xen. The design document
> could be found from [1].

Thank you very much for sending a 62-patch series to a set of people
without tailoring the distribution list for the individual patches. I'm
pretty sure I mentioned this to you before - please be mindful of the
workload you impose on other people by sending out patches. I'll
make limited effort of identifying the patches I actually need to look
at, but the risk of patches getting discarded is going to be there.

Jan

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

* Re: [PATCH v3 00/62] Add ACPI support for arm64 on Xen
@ 2015-11-17 10:59   ` Jan Beulich
  0 siblings, 0 replies; 426+ messages in thread
From: Jan Beulich @ 2015-11-17 10:59 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, linux-arm-kernel,
	ard.biesheuvel, andrew.cooper3, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, david.vrabel, zhaoshenglong,
	christoffer.dall, roger.pau

>>> On 17.11.15 at 10:39, <shannon.zhao@linaro.org> wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> This patch set adds ACPI support for arm64 on Xen. The design document
> could be found from [1].

Thank you very much for sending a 62-patch series to a set of people
without tailoring the distribution list for the individual patches. I'm
pretty sure I mentioned this to you before - please be mindful of the
workload you impose on other people by sending out patches. I'll
make limited effort of identifying the patches I actually need to look
at, but the risk of patches getting discarded is going to be there.

Jan

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

* [PATCH v3 59/62] xen/arm: Add a hypercall for device mmio mapping
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-17 11:04   ` Jan Beulich
  2016-01-07  6:58       ` Shannon Zhao
  -1 siblings, 1 reply; 426+ messages in thread
From: Jan Beulich @ 2015-11-17 11:04 UTC (permalink / raw)
  To: linux-arm-kernel

>>> On 17.11.15 at 10:40, <shannon.zhao@linaro.org> wrote:
> --- 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;

Blindly for any kind of domain? The XSM check in the
XENMEM_add_to_physmap_batch handler (in common code) doesn't
even know which map space is to be used...

Jan

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

* Re: [PATCH v3 59/62] xen/arm: Add a hypercall for device mmio mapping
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-17 11:04   ` Jan Beulich
  -1 siblings, 0 replies; 426+ messages in thread
From: Jan Beulich @ 2015-11-17 11:04 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, linux-arm-kernel,
	ard.biesheuvel, andrew.cooper3, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, david.vrabel, zhaoshenglong,
	christoffer.dall, roger.pau

>>> On 17.11.15 at 10:40, <shannon.zhao@linaro.org> wrote:
> --- 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;

Blindly for any kind of domain? The XSM check in the
XENMEM_add_to_physmap_batch handler (in common code) doesn't
even know which map space is to be used...

Jan

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

* [PATCH v3 50/62] xen/efi: store EFI system table in efi structure
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-17 11:07   ` Jan Beulich
  -1 siblings, 0 replies; 426+ messages in thread
From: Jan Beulich @ 2015-11-17 11:07 UTC (permalink / raw)
  To: linux-arm-kernel

>>> On 17.11.15 at 10:40, <shannon.zhao@linaro.org> wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> When preparing EFI tables for Dom0, it needs the information of EFI
> system table. Here store it in efi structure.

Again I'm pretty sure I had already pointed out that this not being
needed on x86 calls for either more than the brief description above
or this being done just for ARM or (preferably) the table pointer
- where _really_ needed - to be passed around as function
argument(s).

Jan

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

* Re: [PATCH v3 50/62] xen/efi: store EFI system table in efi structure
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-17 11:07   ` Jan Beulich
  -1 siblings, 0 replies; 426+ messages in thread
From: Jan Beulich @ 2015-11-17 11:07 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, linux-arm-kernel,
	ard.biesheuvel, andrew.cooper3, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, david.vrabel, zhaoshenglong,
	christoffer.dall, roger.pau

>>> On 17.11.15 at 10:40, <shannon.zhao@linaro.org> wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> When preparing EFI tables for Dom0, it needs the information of EFI
> system table. Here store it in efi structure.

Again I'm pretty sure I had already pointed out that this not being
needed on x86 calls for either more than the brief description above
or this being done just for ARM or (preferably) the table pointer
- where _really_ needed - to be passed around as function
argument(s).

Jan

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

* [PATCH v3 00/62] Add ACPI support for arm64 on Xen
  2015-11-17 10:59   ` Jan Beulich
  (?)
  (?)
@ 2015-11-17 11:10   ` David Vrabel
  2015-11-17 13:02     ` Shannon Zhao
  2015-11-17 13:02     ` Shannon Zhao
  -1 siblings, 2 replies; 426+ messages in thread
From: David Vrabel @ 2015-11-17 11:10 UTC (permalink / raw)
  To: linux-arm-kernel

On 17/11/15 10:59, Jan Beulich wrote:
>>>> On 17.11.15 at 10:39, <shannon.zhao@linaro.org> wrote:
>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>
>> This patch set adds ACPI support for arm64 on Xen. The design document
>> could be found from [1].
> 
> Thank you very much for sending a 62-patch series to a set of people
> without tailoring the distribution list for the individual patches. I'm
> pretty sure I mentioned this to you before - please be mindful of the
> workload you impose on other people by sending out patches. I'll
> make limited effort of identifying the patches I actually need to look
> at, but the risk of patches getting discarded is going to be there.

Yes, I skimmed the subjects and it doesn't look like I'm the maintainer
for any of the patches.

Please don't Cc me in the future.

David

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

* Re: [PATCH v3 00/62] Add ACPI support for arm64 on Xen
  2015-11-17 10:59   ` Jan Beulich
  (?)
@ 2015-11-17 11:10   ` David Vrabel
  -1 siblings, 0 replies; 426+ messages in thread
From: David Vrabel @ 2015-11-17 11:10 UTC (permalink / raw)
  To: Jan Beulich, shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, linux-arm-kernel, zhaoshenglong,
	christoffer.dall, roger.pau

On 17/11/15 10:59, Jan Beulich wrote:
>>>> On 17.11.15 at 10:39, <shannon.zhao@linaro.org> wrote:
>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>
>> This patch set adds ACPI support for arm64 on Xen. The design document
>> could be found from [1].
> 
> Thank you very much for sending a 62-patch series to a set of people
> without tailoring the distribution list for the individual patches. I'm
> pretty sure I mentioned this to you before - please be mindful of the
> workload you impose on other people by sending out patches. I'll
> make limited effort of identifying the patches I actually need to look
> at, but the risk of patches getting discarded is going to be there.

Yes, I skimmed the subjects and it doesn't look like I'm the maintainer
for any of the patches.

Please don't Cc me in the future.

David

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

* [PATCH v3 01/62] Revert "xen/arm: vgic-v2: Drop cbase from arch_domain"
  2015-11-17  9:40 ` shannon.zhao at linaro.org
@ 2015-11-17 11:27     ` Julien Grall
  0 siblings, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-17 11:27 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Shannon,

Why do you want to revert this patch?

Regards,

On 17/11/15 09:40, shannon.zhao at linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> This reverts commit 810a50db69703f715d199d6b3a5f08193155d48b.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Conflicts:
> 	xen/arch/arm/vgic-v2.c
> ---
>  xen/arch/arm/vgic-v2.c       | 10 +++++-----
>  xen/include/asm-arm/domain.h |  1 +
>  2 files changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/xen/arch/arm/vgic-v2.c b/xen/arch/arm/vgic-v2.c
> index f7d784b..ba7ddac 100644
> --- a/xen/arch/arm/vgic-v2.c
> +++ b/xen/arch/arm/vgic-v2.c
> @@ -531,7 +531,7 @@ static int vgic_v2_vcpu_init(struct vcpu *v)
>  static int vgic_v2_domain_init(struct domain *d)
>  {
>      int i, ret;
> -    paddr_t cbase, csize;
> +    paddr_t csize;
>      paddr_t vbase;
>  
>      /*
> @@ -541,6 +541,7 @@ static int vgic_v2_domain_init(struct domain *d)
>      if ( is_hardware_domain(d) )
>      {
>          d->arch.vgic.dbase = vgic_v2_hw.dbase;
> +        d->arch.vgic.cbase = vgic_v2_hw.cbase;
>          /*
>           * For the hardware domain, we always map the whole HW CPU
>           * interface region in order to match the device tree (the "reg"
> @@ -548,13 +549,13 @@ static int vgic_v2_domain_init(struct domain *d)
>           * Note that we assume the size of the CPU interface is always
>           * aligned to PAGE_SIZE.
>           */
> -        cbase = vgic_v2_hw.cbase;
>          csize = vgic_v2_hw.csize;
>          vbase = vgic_v2_hw.vbase;
>      }
>      else
>      {
>          d->arch.vgic.dbase = GUEST_GICD_BASE;
> +        d->arch.vgic.cbase = GUEST_GICC_BASE;
>          /*
>           * The CPU interface exposed to the guest is always 8kB. We may
>           * need to add an offset to the virtual CPU interface base
> @@ -562,7 +563,6 @@ static int vgic_v2_domain_init(struct domain *d)
>           * region.
>           */
>          BUILD_BUG_ON(GUEST_GICC_SIZE != SZ_8K);
> -        cbase = GUEST_GICC_BASE;
>          csize = GUEST_GICC_SIZE;
>          vbase = vgic_v2_hw.vbase + vgic_v2_hw.aliased_offset;
>      }
> @@ -571,8 +571,8 @@ static int vgic_v2_domain_init(struct domain *d)
>       * Map the gic virtual cpu interface in the gic cpu interface
>       * region of the guest.
>       */
> -    ret = map_mmio_regions(d, paddr_to_pfn(cbase), csize / PAGE_SIZE,
> -                           paddr_to_pfn(vbase));
> +    ret = map_mmio_regions(d, paddr_to_pfn(d->arch.vgic.cbase),
> +                           csize / PAGE_SIZE, paddr_to_pfn(vbase));
>      if ( ret )
>          return ret;
>  
> diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h
> index e7e40da..1e61f30 100644
> --- a/xen/include/asm-arm/domain.h
> +++ b/xen/include/asm-arm/domain.h
> @@ -102,6 +102,7 @@ struct arch_domain
>          struct pending_irq *pending_irqs;
>          /* Base address for guest GIC */
>          paddr_t dbase; /* Distributor base address */
> +        paddr_t cbase; /* CPU base address */
>  #ifdef HAS_GICV3
>          /* GIC V3 addressing */
>          /* List of contiguous occupied by the redistributors */
> 


-- 
Julien Grall

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

* Re: [PATCH v3 01/62] Revert "xen/arm: vgic-v2: Drop cbase from arch_domain"
@ 2015-11-17 11:27     ` Julien Grall
  0 siblings, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-17 11:27 UTC (permalink / raw)
  To: shannon.zhao, ian.campbell, stefano.stabellini, keir, jbeulich,
	andrew.cooper3, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, christoffer.dall,
	peter.huangpeng, david.vrabel, zhaoshenglong, linux-arm-kernel,
	roger.pau

Hi Shannon,

Why do you want to revert this patch?

Regards,

On 17/11/15 09:40, shannon.zhao@linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> This reverts commit 810a50db69703f715d199d6b3a5f08193155d48b.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Conflicts:
> 	xen/arch/arm/vgic-v2.c
> ---
>  xen/arch/arm/vgic-v2.c       | 10 +++++-----
>  xen/include/asm-arm/domain.h |  1 +
>  2 files changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/xen/arch/arm/vgic-v2.c b/xen/arch/arm/vgic-v2.c
> index f7d784b..ba7ddac 100644
> --- a/xen/arch/arm/vgic-v2.c
> +++ b/xen/arch/arm/vgic-v2.c
> @@ -531,7 +531,7 @@ static int vgic_v2_vcpu_init(struct vcpu *v)
>  static int vgic_v2_domain_init(struct domain *d)
>  {
>      int i, ret;
> -    paddr_t cbase, csize;
> +    paddr_t csize;
>      paddr_t vbase;
>  
>      /*
> @@ -541,6 +541,7 @@ static int vgic_v2_domain_init(struct domain *d)
>      if ( is_hardware_domain(d) )
>      {
>          d->arch.vgic.dbase = vgic_v2_hw.dbase;
> +        d->arch.vgic.cbase = vgic_v2_hw.cbase;
>          /*
>           * For the hardware domain, we always map the whole HW CPU
>           * interface region in order to match the device tree (the "reg"
> @@ -548,13 +549,13 @@ static int vgic_v2_domain_init(struct domain *d)
>           * Note that we assume the size of the CPU interface is always
>           * aligned to PAGE_SIZE.
>           */
> -        cbase = vgic_v2_hw.cbase;
>          csize = vgic_v2_hw.csize;
>          vbase = vgic_v2_hw.vbase;
>      }
>      else
>      {
>          d->arch.vgic.dbase = GUEST_GICD_BASE;
> +        d->arch.vgic.cbase = GUEST_GICC_BASE;
>          /*
>           * The CPU interface exposed to the guest is always 8kB. We may
>           * need to add an offset to the virtual CPU interface base
> @@ -562,7 +563,6 @@ static int vgic_v2_domain_init(struct domain *d)
>           * region.
>           */
>          BUILD_BUG_ON(GUEST_GICC_SIZE != SZ_8K);
> -        cbase = GUEST_GICC_BASE;
>          csize = GUEST_GICC_SIZE;
>          vbase = vgic_v2_hw.vbase + vgic_v2_hw.aliased_offset;
>      }
> @@ -571,8 +571,8 @@ static int vgic_v2_domain_init(struct domain *d)
>       * Map the gic virtual cpu interface in the gic cpu interface
>       * region of the guest.
>       */
> -    ret = map_mmio_regions(d, paddr_to_pfn(cbase), csize / PAGE_SIZE,
> -                           paddr_to_pfn(vbase));
> +    ret = map_mmio_regions(d, paddr_to_pfn(d->arch.vgic.cbase),
> +                           csize / PAGE_SIZE, paddr_to_pfn(vbase));
>      if ( ret )
>          return ret;
>  
> diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h
> index e7e40da..1e61f30 100644
> --- a/xen/include/asm-arm/domain.h
> +++ b/xen/include/asm-arm/domain.h
> @@ -102,6 +102,7 @@ struct arch_domain
>          struct pending_irq *pending_irqs;
>          /* Base address for guest GIC */
>          paddr_t dbase; /* Distributor base address */
> +        paddr_t cbase; /* CPU base address */
>  #ifdef HAS_GICV3
>          /* GIC V3 addressing */
>          /* List of contiguous occupied by the redistributors */
> 


-- 
Julien Grall

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

* [PATCH v3 33/62] arm/uart: Create generic uart initialization function
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-17 11:49   ` Julien Grall
  2015-11-17 12:34     ` Shannon Zhao
  2015-11-17 12:34     ` Shannon Zhao
  -1 siblings, 2 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-17 11:49 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Shannon,

On 17/11/15 09:40, shannon.zhao at linaro.org wrote:
> From: Parth Dixit <parth.dixit@linaro.org>
> 
> Rename dt-uart.c to arm-uart.c and create new generic uart init function.
> Move dt_uart_init to arm_uart_init.

It's very hard to review a patch to move existing code and add new one.
Please split it in 2.

Regards,

-- 
Julien Grall

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

* Re: [PATCH v3 33/62] arm/uart: Create generic uart initialization function
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-17 11:49   ` Julien Grall
  -1 siblings, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-17 11:49 UTC (permalink / raw)
  To: shannon.zhao, ian.campbell, stefano.stabellini, keir, jbeulich,
	andrew.cooper3, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, christoffer.dall,
	peter.huangpeng, david.vrabel, zhaoshenglong, linux-arm-kernel,
	roger.pau

Hi Shannon,

On 17/11/15 09:40, shannon.zhao@linaro.org wrote:
> From: Parth Dixit <parth.dixit@linaro.org>
> 
> Rename dt-uart.c to arm-uart.c and create new generic uart init function.
> Move dt_uart_init to arm_uart_init.

It's very hard to review a patch to move existing code and add new one.
Please split it in 2.

Regards,

-- 
Julien Grall

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

* [PATCH v3 00/62] Add ACPI support for arm64 on Xen
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
                   ` (65 preceding siblings ...)
  2015-11-17 10:59   ` Jan Beulich
@ 2015-11-17 11:52 ` Julien Grall
  2015-11-18  8:03   ` Shannon Zhao
  2015-11-18  8:03   ` Shannon Zhao
  2015-11-17 11:52 ` Julien Grall
  67 siblings, 2 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-17 11:52 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Shannon,

On 17/11/15 09:39, shannon.zhao at linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> This patch set adds ACPI support for arm64 on Xen. The design document
> could be found from [1].

Thank you for your work on it. I think this series would benefits to be
split in smaller series.

I would do a first series which split DT code from common code. So we
can get this code as soon as possible in Xen, avoid you to spend less
time rebasing your us to be spammed with 62 patches for each new version.

Regards,

-- 
Julien Grall

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

* Re: [PATCH v3 00/62] Add ACPI support for arm64 on Xen
  2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
                   ` (66 preceding siblings ...)
  2015-11-17 11:52 ` Julien Grall
@ 2015-11-17 11:52 ` Julien Grall
  67 siblings, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-17 11:52 UTC (permalink / raw)
  To: shannon.zhao, ian.campbell, stefano.stabellini, keir, jbeulich,
	andrew.cooper3, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, christoffer.dall,
	peter.huangpeng, david.vrabel, zhaoshenglong, linux-arm-kernel,
	roger.pau

Hi Shannon,

On 17/11/15 09:39, shannon.zhao@linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> This patch set adds ACPI support for arm64 on Xen. The design document
> could be found from [1].

Thank you for your work on it. I think this series would benefits to be
split in smaller series.

I would do a first series which split DT code from common code. So we
can get this code as soon as possible in Xen, avoid you to spend less
time rebasing your us to be spammed with 62 patches for each new version.

Regards,

-- 
Julien Grall

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

* [PATCH v3 50/62] xen/efi: store EFI system table in efi structure
  2015-11-17  9:40   ` shannon.zhao
                     ` (3 preceding siblings ...)
  (?)
@ 2015-11-17 11:57   ` Julien Grall
  2015-11-18  3:17     ` Shannon Zhao
  2015-11-18  3:17     ` Shannon Zhao
  -1 siblings, 2 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-17 11:57 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Shannon,

On 17/11/15 09:40, shannon.zhao at linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> When preparing EFI tables for Dom0, it needs the information of EFI
> system table. Here store it in efi structure.

On ARM64 the EFI stub is completely independent and therefore it's not
possible to share variable between Xen and the stub.

If it's working today is only by luck as we zero the BSS after the stub
jumped to Xen entry point.

Regards,

> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/common/efi/boot.c | 2 ++
>  xen/include/xen/efi.h | 1 +
>  2 files changed, 3 insertions(+)
> 
> diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
> index 78d8ae9..6a48624 100644
> --- a/xen/common/efi/boot.c
> +++ b/xen/common/efi/boot.c
> @@ -1155,6 +1155,8 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
>  
>      efi_tables();
>  
> +    efi.est = (long)SystemTable;
> +
>      /* Collect PCI ROM contents. */
>      setup_efi_pci();
>  
> diff --git a/xen/include/xen/efi.h b/xen/include/xen/efi.h
> index e74dad1..e112296 100644
> --- a/xen/include/xen/efi.h
> +++ b/xen/include/xen/efi.h
> @@ -16,6 +16,7 @@ struct efi {
>      unsigned long acpi20;       /* ACPI table (ACPI 2.0) */
>      unsigned long smbios;       /* SM BIOS table */
>      unsigned long smbios3;      /* SMBIOS v3 table */
> +    unsigned long est;          /* EFI system table */
>  };
>  
>  extern struct efi efi;
> 


-- 
Julien Grall

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

* Re: [PATCH v3 50/62] xen/efi: store EFI system table in efi structure
  2015-11-17  9:40   ` shannon.zhao
                     ` (2 preceding siblings ...)
  (?)
@ 2015-11-17 11:57   ` Julien Grall
  -1 siblings, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-17 11:57 UTC (permalink / raw)
  To: shannon.zhao, ian.campbell, stefano.stabellini, keir, jbeulich,
	andrew.cooper3, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, christoffer.dall,
	peter.huangpeng, david.vrabel, zhaoshenglong, linux-arm-kernel,
	roger.pau

Hi Shannon,

On 17/11/15 09:40, shannon.zhao@linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> When preparing EFI tables for Dom0, it needs the information of EFI
> system table. Here store it in efi structure.

On ARM64 the EFI stub is completely independent and therefore it's not
possible to share variable between Xen and the stub.

If it's working today is only by luck as we zero the BSS after the stub
jumped to Xen entry point.

Regards,

> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/common/efi/boot.c | 2 ++
>  xen/include/xen/efi.h | 1 +
>  2 files changed, 3 insertions(+)
> 
> diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
> index 78d8ae9..6a48624 100644
> --- a/xen/common/efi/boot.c
> +++ b/xen/common/efi/boot.c
> @@ -1155,6 +1155,8 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
>  
>      efi_tables();
>  
> +    efi.est = (long)SystemTable;
> +
>      /* Collect PCI ROM contents. */
>      setup_efi_pci();
>  
> diff --git a/xen/include/xen/efi.h b/xen/include/xen/efi.h
> index e74dad1..e112296 100644
> --- a/xen/include/xen/efi.h
> +++ b/xen/include/xen/efi.h
> @@ -16,6 +16,7 @@ struct efi {
>      unsigned long acpi20;       /* ACPI table (ACPI 2.0) */
>      unsigned long smbios;       /* SM BIOS table */
>      unsigned long smbios3;      /* SMBIOS v3 table */
> +    unsigned long est;          /* EFI system table */
>  };
>  
>  extern struct efi efi;
> 


-- 
Julien Grall

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

* [PATCH v3 38/62] arm/acpi: Add placeholder for efi and acpi load address
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-17 11:58   ` Julien Grall
  2015-11-17 12:45     ` Shannon Zhao
  2015-11-17 12:45     ` Shannon Zhao
  -1 siblings, 2 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-17 11:58 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Shannon,

On 17/11/15 09:40, shannon.zhao at linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> EFI table, memory description table and some of acpi tables will be
> placed after DOM0 memory space. 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>
> ---
>  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 1e61f30..91272e5 100644
> --- a/xen/include/asm-arm/domain.h
> +++ b/xen/include/asm-arm/domain.h
> @@ -125,6 +125,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

Why do you need this in the arch_domain? AFAICT those 3 variables should
only be used while building DOM0, so a better place would be in struct
kernel_info (see xen/arch/arm/kernel.h).

>  }  __cacheline_aligned;
>  
>  struct arch_vcpu
> 


Regards,


-- 
Julien Grall

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

* Re: [PATCH v3 38/62] arm/acpi: Add placeholder for efi and acpi load address
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-17 11:58   ` Julien Grall
  -1 siblings, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-17 11:58 UTC (permalink / raw)
  To: shannon.zhao, ian.campbell, stefano.stabellini, keir, jbeulich,
	andrew.cooper3, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, christoffer.dall,
	peter.huangpeng, david.vrabel, zhaoshenglong, linux-arm-kernel,
	roger.pau

Hi Shannon,

On 17/11/15 09:40, shannon.zhao@linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> EFI table, memory description table and some of acpi tables will be
> placed after DOM0 memory space. 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>
> ---
>  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 1e61f30..91272e5 100644
> --- a/xen/include/asm-arm/domain.h
> +++ b/xen/include/asm-arm/domain.h
> @@ -125,6 +125,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

Why do you need this in the arch_domain? AFAICT those 3 variables should
only be used while building DOM0, so a better place would be in struct
kernel_info (see xen/arch/arm/kernel.h).

>  }  __cacheline_aligned;
>  
>  struct arch_vcpu
> 


Regards,


-- 
Julien Grall

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

* [PATCH v3 51/62] arm/acpi: Prepare EFI system table for Dom0
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-17 12:02   ` Julien Grall
  2015-11-18  3:34     ` Shannon Zhao
  -1 siblings, 1 reply; 426+ messages in thread
From: Julien Grall @ 2015-11-17 12:02 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Shannon,

On 17/11/15 09:40, shannon.zhao at linaro.org wrote:
> diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
> index 6a48624..75835ae 100644
> --- a/xen/common/efi/boot.c
> +++ b/xen/common/efi/boot.c
> @@ -1192,6 +1192,70 @@ int __init estimate_efi_size(int mem_nr_banks)
>  
>      return size;
>  }
> +
> +static uint32_t __init xz_crc32(uint8_t *buf, size_t size, uint32_t crc)
> +{
> +    uint32_t xz_crc32_table[256];
> +    const uint32_t poly = 0xEDB88320;
> +    uint32_t i;
> +    uint32_t j;
> +    uint32_t r;
> +
> +    for (i = 0; i < 256; ++i) {
> +        r = i;
> +        for (j = 0; j < 8; ++j)
> +            r = (r >> 1) ^ (poly & ~((r & 1) - 1));
> +
> +        xz_crc32_table[i] = r;
> +    }
> +
> +    crc = ~crc;
> +    while (size != 0) {
> +            crc = xz_crc32_table[*buf++ ^ (crc & 0xFF)] ^ (crc >> 8);
> +            --size;
> +    }
> +
> +    return ~crc;
> +}

I'm nearly sure I already said it, this code already exists in the tree.
Why do you need to implement a new version?

Regards,

-- 
Julien Grall

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

* Re: [PATCH v3 51/62] arm/acpi: Prepare EFI system table for Dom0
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-17 12:02   ` Julien Grall
  -1 siblings, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-17 12:02 UTC (permalink / raw)
  To: shannon.zhao, ian.campbell, stefano.stabellini, keir, jbeulich,
	andrew.cooper3, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, christoffer.dall,
	peter.huangpeng, david.vrabel, zhaoshenglong, linux-arm-kernel,
	roger.pau

Hi Shannon,

On 17/11/15 09:40, shannon.zhao@linaro.org wrote:
> diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
> index 6a48624..75835ae 100644
> --- a/xen/common/efi/boot.c
> +++ b/xen/common/efi/boot.c
> @@ -1192,6 +1192,70 @@ int __init estimate_efi_size(int mem_nr_banks)
>  
>      return size;
>  }
> +
> +static uint32_t __init xz_crc32(uint8_t *buf, size_t size, uint32_t crc)
> +{
> +    uint32_t xz_crc32_table[256];
> +    const uint32_t poly = 0xEDB88320;
> +    uint32_t i;
> +    uint32_t j;
> +    uint32_t r;
> +
> +    for (i = 0; i < 256; ++i) {
> +        r = i;
> +        for (j = 0; j < 8; ++j)
> +            r = (r >> 1) ^ (poly & ~((r & 1) - 1));
> +
> +        xz_crc32_table[i] = r;
> +    }
> +
> +    crc = ~crc;
> +    while (size != 0) {
> +            crc = xz_crc32_table[*buf++ ^ (crc & 0xFF)] ^ (crc >> 8);
> +            --size;
> +    }
> +
> +    return ~crc;
> +}

I'm nearly sure I already said it, this code already exists in the tree.
Why do you need to implement a new version?

Regards,

-- 
Julien Grall

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

* [PATCH v3 56/62] arm/acpi: Deny MMIO access of UART
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-17 12:04   ` Julien Grall
  2015-11-17 13:10     ` Shannon Zhao
  2015-11-17 13:10     ` Shannon Zhao
  -1 siblings, 2 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-17 12:04 UTC (permalink / raw)
  To: linux-arm-kernel

On 17/11/15 09:40, shannon.zhao at linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Firstly it permits full MMIO capabilities for Dom0. Then deny MMIO
> access of UART device.

I'm nearly sure we want to deny other MMIO such as the GIC regions and SMMU.

Regards,

-- 
Julien Grall

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

* Re: [PATCH v3 56/62] arm/acpi: Deny MMIO access of UART
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-17 12:04   ` Julien Grall
  -1 siblings, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-17 12:04 UTC (permalink / raw)
  To: shannon.zhao, ian.campbell, stefano.stabellini, keir, jbeulich,
	andrew.cooper3, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, christoffer.dall,
	peter.huangpeng, david.vrabel, zhaoshenglong, linux-arm-kernel,
	roger.pau

On 17/11/15 09:40, shannon.zhao@linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Firstly it permits full MMIO capabilities for Dom0. Then deny MMIO
> access of UART device.

I'm nearly sure we want to deny other MMIO such as the GIC regions and SMMU.

Regards,

-- 
Julien Grall

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

* [PATCH v3 61/62] arm/acpi: Add acpi parameter to enable/disable acpi
  2015-11-17  9:41   ` shannon.zhao
  (?)
  (?)
@ 2015-11-17 12:26   ` Julien Grall
  2015-11-17 12:57     ` Shannon Zhao
  2015-11-17 12:57     ` Shannon Zhao
  -1 siblings, 2 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-17 12:26 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Shannon,

I would have appreciate if you I had looked on comments made on the
series sent by Parth.

On 17/11/15 09:41, shannon.zhao at linaro.org wrote:
> From: Parth Dixit <parth.dixit@linaro.org>
> 
> ACPI will be disabled by default. Define new command line parameter
> "acpi" for enabling it.

I don't think this is right. We have to be able to boot platform where
there is only ACPI provided without adding a command line option.

Overall, it would be better if we follow the same behavior as Linux i.e
ACPI is enabled instead of DT unless:
        - ACPI has been disabled (acpi=off)
        - the DT is not empty (it has more than just a /chosen node) and
ACPI has not been forced to be enabled (acpi=force).

> 
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/setup.c | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
> index 63feadf..1a40323 100644
> --- a/xen/arch/arm/setup.c
> +++ b/xen/arch/arm/setup.c
> @@ -59,6 +59,10 @@ static unsigned long opt_xenheap_megabytes __initdata;
>  integer_param("xenheap_megabytes", opt_xenheap_megabytes);
>  #endif
>  
> +/* "acpi=force" : Enables acpi */
> +static void parse_acpi_param(char *s);
> +custom_param("acpi", parse_acpi_param);
> +
>  static __used void init_done(void)
>  {
>      free_init_memory();
> @@ -84,6 +88,23 @@ static const char * __initdata processor_implementers[] = {
>      ['i'] = "Intel Corporation",
>  };
>  
> +static char __initdata acpi_param[10] = "";
> +static void __init parse_acpi_param(char *s)
> +{
> +    /* Save the parameter so it can be propagated to domain0. */
> +    safe_strcpy(acpi_param, s);

This acpi_param is never used within this series. Please drop it or
either implement what the comment claim.

> +
> +    /* Interpret the parameter for use within Xen. */
> +    if ( !parse_bool(s) )
> +    {
> +        disable_acpi();
> +    }
> +    else if ( !strcmp(s, "force") )
> +    {
> +        acpi_disabled = 0;
> +    }
> +}
> +
>  static void __init processor_id(void)
>  {
>      const char *implementer = "Unknown";
> @@ -729,6 +750,7 @@ void __init start_xen(unsigned long boot_phys_offset,
>          + (fdt_paddr & ((1 << SECOND_SHIFT) - 1));
>      fdt_size = boot_fdt_info(device_tree_flattened, fdt_paddr);
>  
> +    disable_acpi();
>      cmdline = boot_fdt_cmdline(device_tree_flattened);
>      printk("Command line: %s\n", cmdline);
>      cmdline_parse(cmdline);
> 

Regards,

-- 
Julien Grall

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

* Re: [PATCH v3 61/62] arm/acpi: Add acpi parameter to enable/disable acpi
  2015-11-17  9:41   ` shannon.zhao
  (?)
@ 2015-11-17 12:26   ` Julien Grall
  -1 siblings, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-17 12:26 UTC (permalink / raw)
  To: shannon.zhao, ian.campbell, stefano.stabellini, keir, jbeulich,
	andrew.cooper3, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, christoffer.dall,
	peter.huangpeng, david.vrabel, zhaoshenglong, linux-arm-kernel,
	roger.pau

Hi Shannon,

I would have appreciate if you I had looked on comments made on the
series sent by Parth.

On 17/11/15 09:41, shannon.zhao@linaro.org wrote:
> From: Parth Dixit <parth.dixit@linaro.org>
> 
> ACPI will be disabled by default. Define new command line parameter
> "acpi" for enabling it.

I don't think this is right. We have to be able to boot platform where
there is only ACPI provided without adding a command line option.

Overall, it would be better if we follow the same behavior as Linux i.e
ACPI is enabled instead of DT unless:
        - ACPI has been disabled (acpi=off)
        - the DT is not empty (it has more than just a /chosen node) and
ACPI has not been forced to be enabled (acpi=force).

> 
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/setup.c | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
> index 63feadf..1a40323 100644
> --- a/xen/arch/arm/setup.c
> +++ b/xen/arch/arm/setup.c
> @@ -59,6 +59,10 @@ static unsigned long opt_xenheap_megabytes __initdata;
>  integer_param("xenheap_megabytes", opt_xenheap_megabytes);
>  #endif
>  
> +/* "acpi=force" : Enables acpi */
> +static void parse_acpi_param(char *s);
> +custom_param("acpi", parse_acpi_param);
> +
>  static __used void init_done(void)
>  {
>      free_init_memory();
> @@ -84,6 +88,23 @@ static const char * __initdata processor_implementers[] = {
>      ['i'] = "Intel Corporation",
>  };
>  
> +static char __initdata acpi_param[10] = "";
> +static void __init parse_acpi_param(char *s)
> +{
> +    /* Save the parameter so it can be propagated to domain0. */
> +    safe_strcpy(acpi_param, s);

This acpi_param is never used within this series. Please drop it or
either implement what the comment claim.

> +
> +    /* Interpret the parameter for use within Xen. */
> +    if ( !parse_bool(s) )
> +    {
> +        disable_acpi();
> +    }
> +    else if ( !strcmp(s, "force") )
> +    {
> +        acpi_disabled = 0;
> +    }
> +}
> +
>  static void __init processor_id(void)
>  {
>      const char *implementer = "Unknown";
> @@ -729,6 +750,7 @@ void __init start_xen(unsigned long boot_phys_offset,
>          + (fdt_paddr & ((1 << SECOND_SHIFT) - 1));
>      fdt_size = boot_fdt_info(device_tree_flattened, fdt_paddr);
>  
> +    disable_acpi();
>      cmdline = boot_fdt_cmdline(device_tree_flattened);
>      printk("Command line: %s\n", cmdline);
>      cmdline_parse(cmdline);
> 

Regards,

-- 
Julien Grall

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

* [PATCH v3 01/62] Revert "xen/arm: vgic-v2: Drop cbase from arch_domain"
  2015-11-17 11:27     ` Julien Grall
  (?)
  (?)
@ 2015-11-17 12:32     ` Shannon Zhao
  2015-11-17 13:57       ` Julien Grall
  2015-11-17 13:57       ` Julien Grall
  -1 siblings, 2 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-11-17 12:32 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Julien,

On 2015/11/17 19:27, Julien Grall wrote:
> Hi Shannon,
> 
> Why do you want to revert this patch?
> 
Because d->arch.vgic.cbase will be used by creating Dom0 MADT table
later. See [PATCH v3 43/62].
+            gicc.base_address = d->arch.vgic.cbase;

My previous way is get this from ACPI table but someone suggest get it
from struct domain and I think this way is better too since it uses the
value after being parsed.

And sorry that I didn't notice this patch before when you send it out to
list.

-- 
Shannon

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

* Re: [PATCH v3 01/62] Revert "xen/arm: vgic-v2: Drop cbase from arch_domain"
  2015-11-17 11:27     ` Julien Grall
  (?)
@ 2015-11-17 12:32     ` Shannon Zhao
  -1 siblings, 0 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-11-17 12:32 UTC (permalink / raw)
  To: Julien Grall, shannon.zhao, ian.campbell, stefano.stabellini,
	keir, jbeulich, andrew.cooper3, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, christoffer.dall,
	peter.huangpeng, david.vrabel, linux-arm-kernel, roger.pau

Hi Julien,

On 2015/11/17 19:27, Julien Grall wrote:
> Hi Shannon,
> 
> Why do you want to revert this patch?
> 
Because d->arch.vgic.cbase will be used by creating Dom0 MADT table
later. See [PATCH v3 43/62].
+            gicc.base_address = d->arch.vgic.cbase;

My previous way is get this from ACPI table but someone suggest get it
from struct domain and I think this way is better too since it uses the
value after being parsed.

And sorry that I didn't notice this patch before when you send it out to
list.

-- 
Shannon

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

* [PATCH v3 55/62] arm/acpi: Route all Xen unused SPIs to Dom0
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-17 12:33   ` Julien Grall
  -1 siblings, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-17 12:33 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Shannon,

On 17/11/15 09:40, shannon.zhao at linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Route all SPIs to Dom0 except the interrupts that Xen uses. Since Xen
> already uses the uart interrupt, the desc->action will not be NULL, so
> it will skip it.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/domain_build.c | 33 +++++++++++++++++++++++++++++++++
>  1 file changed, 33 insertions(+)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index 6d8536b..6945f89 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -1360,6 +1360,35 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
>  #define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */
>  #define ACPI_DOM0_FDT_MIN_SIZE 4096
>  
> +static int acpi_route_spi(struct domain *d)
> +{
> +    int i, res;
> +    struct irq_desc *desc;
> +
> +    /* Don't route Xen used interrupt to Dom0. Since Xen already uses the uart
> +     * interrupt, the desc->action will not be NULL, so it will skip it.
> +     */
> +    for( i = NR_LOCAL_IRQS; i < vgic_num_irqs(d); i++ )
> +    {
> +        /* Don't route uart interrupt to Dom0 */

Your comments are wrong. desc->action != NULL means Xen is using the
interrupt. It could be for the SMMU, the UART...

> +        desc = irq_to_desc(i);
> +        if( desc->action != NULL)

Coding style.

> +            continue;
> +
> +        vgic_reserve_virq(d, i);
> +        irq_set_type(i, ACPI_IRQ_TYPE_NONE);
> +        res = route_irq_to_guest(d, i, i, NULL);
> +        if ( res )
> +        {
> +            printk(XENLOG_ERR "Unable to route IRQ %u to domain %u\n",
> +                   i, d->domain_id);
> +            continue;
> +        }
> +    }
> +
> +    return 0;
> +}
> +

Regards,

-- 
Julien Grall

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

* Re: [PATCH v3 55/62] arm/acpi: Route all Xen unused SPIs to Dom0
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-17 12:33   ` Julien Grall
  -1 siblings, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-17 12:33 UTC (permalink / raw)
  To: shannon.zhao, ian.campbell, stefano.stabellini, keir, jbeulich,
	andrew.cooper3, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, christoffer.dall,
	peter.huangpeng, david.vrabel, zhaoshenglong, linux-arm-kernel,
	roger.pau

Hi Shannon,

On 17/11/15 09:40, shannon.zhao@linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Route all SPIs to Dom0 except the interrupts that Xen uses. Since Xen
> already uses the uart interrupt, the desc->action will not be NULL, so
> it will skip it.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/domain_build.c | 33 +++++++++++++++++++++++++++++++++
>  1 file changed, 33 insertions(+)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index 6d8536b..6945f89 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -1360,6 +1360,35 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
>  #define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */
>  #define ACPI_DOM0_FDT_MIN_SIZE 4096
>  
> +static int acpi_route_spi(struct domain *d)
> +{
> +    int i, res;
> +    struct irq_desc *desc;
> +
> +    /* Don't route Xen used interrupt to Dom0. Since Xen already uses the uart
> +     * interrupt, the desc->action will not be NULL, so it will skip it.
> +     */
> +    for( i = NR_LOCAL_IRQS; i < vgic_num_irqs(d); i++ )
> +    {
> +        /* Don't route uart interrupt to Dom0 */

Your comments are wrong. desc->action != NULL means Xen is using the
interrupt. It could be for the SMMU, the UART...

> +        desc = irq_to_desc(i);
> +        if( desc->action != NULL)

Coding style.

> +            continue;
> +
> +        vgic_reserve_virq(d, i);
> +        irq_set_type(i, ACPI_IRQ_TYPE_NONE);
> +        res = route_irq_to_guest(d, i, i, NULL);
> +        if ( res )
> +        {
> +            printk(XENLOG_ERR "Unable to route IRQ %u to domain %u\n",
> +                   i, d->domain_id);
> +            continue;
> +        }
> +    }
> +
> +    return 0;
> +}
> +

Regards,

-- 
Julien Grall

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

* [PATCH v3 33/62] arm/uart: Create generic uart initialization function
  2015-11-17 11:49   ` Julien Grall
  2015-11-17 12:34     ` Shannon Zhao
@ 2015-11-17 12:34     ` Shannon Zhao
  1 sibling, 0 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-11-17 12:34 UTC (permalink / raw)
  To: linux-arm-kernel



On 2015/11/17 19:49, Julien Grall wrote:
> Hi Shannon,
> 
> On 17/11/15 09:40, shannon.zhao at linaro.org wrote:
>> From: Parth Dixit <parth.dixit@linaro.org>
>>
>> Rename dt-uart.c to arm-uart.c and create new generic uart init function.
>> Move dt_uart_init to arm_uart_init.
> 
> It's very hard to review a patch to move existing code and add new one.
> Please split it in 2.
> 
Ok, thanks.

-- 
Shannon

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

* Re: [PATCH v3 33/62] arm/uart: Create generic uart initialization function
  2015-11-17 11:49   ` Julien Grall
@ 2015-11-17 12:34     ` Shannon Zhao
  2015-11-17 12:34     ` Shannon Zhao
  1 sibling, 0 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-11-17 12:34 UTC (permalink / raw)
  To: Julien Grall, shannon.zhao, ian.campbell, stefano.stabellini,
	keir, jbeulich, andrew.cooper3, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, christoffer.dall,
	peter.huangpeng, david.vrabel, linux-arm-kernel, roger.pau



On 2015/11/17 19:49, Julien Grall wrote:
> Hi Shannon,
> 
> On 17/11/15 09:40, shannon.zhao@linaro.org wrote:
>> From: Parth Dixit <parth.dixit@linaro.org>
>>
>> Rename dt-uart.c to arm-uart.c and create new generic uart init function.
>> Move dt_uart_init to arm_uart_init.
> 
> It's very hard to review a patch to move existing code and add new one.
> Please split it in 2.
> 
Ok, thanks.

-- 
Shannon

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

* [PATCH v3 24/62] arm: Introduce a generic way to use a device from acpi
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-17 12:40   ` Julien Grall
  2015-11-17 13:21     ` Shannon Zhao
  2015-11-17 13:21     ` Shannon Zhao
  -1 siblings, 2 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-17 12:40 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Shannon,

On 17/11/15 09:40, shannon.zhao at linaro.org wrote:
> From: Parth Dixit <parth.dixit@linaro.org>
> 
> Add generic way to use device from acpi similar to the way it is
> supported in device tree.
> 
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/device.c        | 19 +++++++++++++++++++
>  xen/arch/arm/xen.lds.S       |  7 +++++++
>  xen/include/asm-arm/device.h | 30 ++++++++++++++++++++++++++++++
>  3 files changed, 56 insertions(+)
> 
> diff --git a/xen/arch/arm/device.c b/xen/arch/arm/device.c
> index 0b53f6a..5494de0 100644
> --- a/xen/arch/arm/device.c
> +++ b/xen/arch/arm/device.c
> @@ -22,6 +22,7 @@
>  #include <xen/lib.h>
>  
>  extern const struct device_desc _sdevice[], _edevice[];
> +extern const struct acpi_device_desc _asdevice[], _aedevice[];
>  
>  int __init device_init(struct dt_device_node *dev, enum device_class class,
>                         const void *data)
> @@ -50,6 +51,24 @@ int __init device_init(struct dt_device_node *dev, enum device_class class,
>      return -EBADF;
>  }
>  
> +int __init acpi_device_init(enum device_class class, const void *data, int class_type)

As said on a previous version, please explain what means class_type and
how this will fit with every
ACPI device tables.

AFAICT, it does only works for SPCR table used for UART device. For the
GIC you've hardcoded the value and I can't find any version number in
the table.

You may need to introduce another way to find the device such as a
callback taking the table in parameter.

Regards,

-- 
Julien Grall

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

* Re: [PATCH v3 24/62] arm: Introduce a generic way to use a device from acpi
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-17 12:40   ` Julien Grall
  -1 siblings, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-17 12:40 UTC (permalink / raw)
  To: shannon.zhao, ian.campbell, stefano.stabellini, keir, jbeulich,
	andrew.cooper3, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, christoffer.dall,
	peter.huangpeng, david.vrabel, zhaoshenglong, linux-arm-kernel,
	roger.pau

Hi Shannon,

On 17/11/15 09:40, shannon.zhao@linaro.org wrote:
> From: Parth Dixit <parth.dixit@linaro.org>
> 
> Add generic way to use device from acpi similar to the way it is
> supported in device tree.
> 
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/device.c        | 19 +++++++++++++++++++
>  xen/arch/arm/xen.lds.S       |  7 +++++++
>  xen/include/asm-arm/device.h | 30 ++++++++++++++++++++++++++++++
>  3 files changed, 56 insertions(+)
> 
> diff --git a/xen/arch/arm/device.c b/xen/arch/arm/device.c
> index 0b53f6a..5494de0 100644
> --- a/xen/arch/arm/device.c
> +++ b/xen/arch/arm/device.c
> @@ -22,6 +22,7 @@
>  #include <xen/lib.h>
>  
>  extern const struct device_desc _sdevice[], _edevice[];
> +extern const struct acpi_device_desc _asdevice[], _aedevice[];
>  
>  int __init device_init(struct dt_device_node *dev, enum device_class class,
>                         const void *data)
> @@ -50,6 +51,24 @@ int __init device_init(struct dt_device_node *dev, enum device_class class,
>      return -EBADF;
>  }
>  
> +int __init acpi_device_init(enum device_class class, const void *data, int class_type)

As said on a previous version, please explain what means class_type and
how this will fit with every
ACPI device tables.

AFAICT, it does only works for SPCR table used for UART device. For the
GIC you've hardcoded the value and I can't find any version number in
the table.

You may need to introduce another way to find the device such as a
callback taking the table in parameter.

Regards,

-- 
Julien Grall

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

* [PATCH v3 38/62] arm/acpi: Add placeholder for efi and acpi load address
  2015-11-17 11:58   ` Julien Grall
  2015-11-17 12:45     ` Shannon Zhao
@ 2015-11-17 12:45     ` Shannon Zhao
  2015-11-17 14:23       ` Julien Grall
                         ` (3 more replies)
  1 sibling, 4 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-11-17 12:45 UTC (permalink / raw)
  To: linux-arm-kernel



On 2015/11/17 19:58, Julien Grall wrote:
> Hi Shannon,
> 
> On 17/11/15 09:40, shannon.zhao at linaro.org wrote:
>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>
>> EFI table, memory description table and some of acpi tables will be
>> placed after DOM0 memory space. 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>
>> ---
>>  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 1e61f30..91272e5 100644
>> --- a/xen/include/asm-arm/domain.h
>> +++ b/xen/include/asm-arm/domain.h
>> @@ -125,6 +125,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
> 
> Why do you need this in the arch_domain? AFAICT those 3 variables should
> only be used while building DOM0, so a better place would be in struct
> kernel_info (see xen/arch/arm/kernel.h).
> 

Since I use efi_acpi_table to store the allocated pages pointer which
are used to store newly created ACPI and EFI tables.
See [PATCH v3 40/62]:
+    order = get_order_from_bytes(d->arch.efi_acpi_len);
+    d->arch.efi_acpi_table = alloc_xenheap_pages(order, 0);

And it free these pages when destroying this domain:
+#ifdef CONFIG_ACPI
+    free_xenheap_pages(d->arch.efi_acpi_table,
+                       get_order_from_bytes(d->arch.efi_acpi_len));
+#endif

efi_acpi_gpa might not need.

Thanks,
-- 
Shannon

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

* Re: [PATCH v3 38/62] arm/acpi: Add placeholder for efi and acpi load address
  2015-11-17 11:58   ` Julien Grall
@ 2015-11-17 12:45     ` Shannon Zhao
  2015-11-17 12:45     ` Shannon Zhao
  1 sibling, 0 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-11-17 12:45 UTC (permalink / raw)
  To: Julien Grall, shannon.zhao, ian.campbell, stefano.stabellini,
	keir, jbeulich, andrew.cooper3, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, christoffer.dall,
	peter.huangpeng, david.vrabel, linux-arm-kernel, roger.pau



On 2015/11/17 19:58, Julien Grall wrote:
> Hi Shannon,
> 
> On 17/11/15 09:40, shannon.zhao@linaro.org wrote:
>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>
>> EFI table, memory description table and some of acpi tables will be
>> placed after DOM0 memory space. 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>
>> ---
>>  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 1e61f30..91272e5 100644
>> --- a/xen/include/asm-arm/domain.h
>> +++ b/xen/include/asm-arm/domain.h
>> @@ -125,6 +125,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
> 
> Why do you need this in the arch_domain? AFAICT those 3 variables should
> only be used while building DOM0, so a better place would be in struct
> kernel_info (see xen/arch/arm/kernel.h).
> 

Since I use efi_acpi_table to store the allocated pages pointer which
are used to store newly created ACPI and EFI tables.
See [PATCH v3 40/62]:
+    order = get_order_from_bytes(d->arch.efi_acpi_len);
+    d->arch.efi_acpi_table = alloc_xenheap_pages(order, 0);

And it free these pages when destroying this domain:
+#ifdef CONFIG_ACPI
+    free_xenheap_pages(d->arch.efi_acpi_table,
+                       get_order_from_bytes(d->arch.efi_acpi_len));
+#endif

efi_acpi_gpa might not need.

Thanks,
-- 
Shannon

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

* [PATCH v3 61/62] arm/acpi: Add acpi parameter to enable/disable acpi
  2015-11-17 12:26   ` Julien Grall
  2015-11-17 12:57     ` Shannon Zhao
@ 2015-11-17 12:57     ` Shannon Zhao
  2015-11-17 14:32       ` Julien Grall
  2015-11-17 14:32       ` Julien Grall
  1 sibling, 2 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-11-17 12:57 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

On 2015/11/17 20:26, Julien Grall wrote:
> Hi Shannon,
> 
> I would have appreciate if you I had looked on comments made on the
> series sent by Parth.
> 
I do look. But I didn't find "Follow-Ups" ones at [1]. And among the
mails which Parth forwarded to me there is no [PATCH v2 37/41]. This is
werid.

[1]http://lists.xenproject.org/archives/html/xen-devel/2015-05/msg02227.html

> On 17/11/15 09:41, shannon.zhao at linaro.org wrote:
>> From: Parth Dixit <parth.dixit@linaro.org>
>>
>> ACPI will be disabled by default. Define new command line parameter
>> "acpi" for enabling it.
> 
> I don't think this is right. We have to be able to boot platform where
> there is only ACPI provided without adding a command line option.
> 
> Overall, it would be better if we follow the same behavior as Linux i.e
> ACPI is enabled instead of DT unless:
>         - ACPI has been disabled (acpi=off)
>         - the DT is not empty (it has more than just a /chosen node) and
> ACPI has not been forced to be enabled (acpi=force).
> 
Ok, will add this.

>>
>> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> ---
>>  xen/arch/arm/setup.c | 22 ++++++++++++++++++++++
>>  1 file changed, 22 insertions(+)
>>
>> diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
>> index 63feadf..1a40323 100644
>> --- a/xen/arch/arm/setup.c
>> +++ b/xen/arch/arm/setup.c
>> @@ -59,6 +59,10 @@ static unsigned long opt_xenheap_megabytes __initdata;
>>  integer_param("xenheap_megabytes", opt_xenheap_megabytes);
>>  #endif
>>  
>> +/* "acpi=force" : Enables acpi */
>> +static void parse_acpi_param(char *s);
>> +custom_param("acpi", parse_acpi_param);
>> +
>>  static __used void init_done(void)
>>  {
>>      free_init_memory();
>> @@ -84,6 +88,23 @@ static const char * __initdata processor_implementers[] = {
>>      ['i'] = "Intel Corporation",
>>  };
>>  
>> +static char __initdata acpi_param[10] = "";
>> +static void __init parse_acpi_param(char *s)
>> +{
>> +    /* Save the parameter so it can be propagated to domain0. */
>> +    safe_strcpy(acpi_param, s);
> 
> This acpi_param is never used within this series. Please drop it or
> either implement what the comment claim.
> 
>> +
>> +    /* Interpret the parameter for use within Xen. */
>> +    if ( !parse_bool(s) )
>> +    {
>> +        disable_acpi();
>> +    }
>> +    else if ( !strcmp(s, "force") )
>> +    {
>> +        acpi_disabled = 0;
>> +    }
>> +}
>> +
>>  static void __init processor_id(void)
>>  {
>>      const char *implementer = "Unknown";
>> @@ -729,6 +750,7 @@ void __init start_xen(unsigned long boot_phys_offset,
>>          + (fdt_paddr & ((1 << SECOND_SHIFT) - 1));
>>      fdt_size = boot_fdt_info(device_tree_flattened, fdt_paddr);
>>  
>> +    disable_acpi();
>>      cmdline = boot_fdt_cmdline(device_tree_flattened);
>>      printk("Command line: %s\n", cmdline);
>>      cmdline_parse(cmdline);
>>
> 
> Regards,
> 

-- 
Shannon

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

* Re: [PATCH v3 61/62] arm/acpi: Add acpi parameter to enable/disable acpi
  2015-11-17 12:26   ` Julien Grall
@ 2015-11-17 12:57     ` Shannon Zhao
  2015-11-17 12:57     ` Shannon Zhao
  1 sibling, 0 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-11-17 12:57 UTC (permalink / raw)
  To: Julien Grall, shannon.zhao, ian.campbell, stefano.stabellini,
	keir, jbeulich, andrew.cooper3, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, christoffer.dall,
	peter.huangpeng, david.vrabel, linux-arm-kernel, roger.pau

Hi,

On 2015/11/17 20:26, Julien Grall wrote:
> Hi Shannon,
> 
> I would have appreciate if you I had looked on comments made on the
> series sent by Parth.
> 
I do look. But I didn't find "Follow-Ups" ones at [1]. And among the
mails which Parth forwarded to me there is no [PATCH v2 37/41]. This is
werid.

[1]http://lists.xenproject.org/archives/html/xen-devel/2015-05/msg02227.html

> On 17/11/15 09:41, shannon.zhao@linaro.org wrote:
>> From: Parth Dixit <parth.dixit@linaro.org>
>>
>> ACPI will be disabled by default. Define new command line parameter
>> "acpi" for enabling it.
> 
> I don't think this is right. We have to be able to boot platform where
> there is only ACPI provided without adding a command line option.
> 
> Overall, it would be better if we follow the same behavior as Linux i.e
> ACPI is enabled instead of DT unless:
>         - ACPI has been disabled (acpi=off)
>         - the DT is not empty (it has more than just a /chosen node) and
> ACPI has not been forced to be enabled (acpi=force).
> 
Ok, will add this.

>>
>> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> ---
>>  xen/arch/arm/setup.c | 22 ++++++++++++++++++++++
>>  1 file changed, 22 insertions(+)
>>
>> diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
>> index 63feadf..1a40323 100644
>> --- a/xen/arch/arm/setup.c
>> +++ b/xen/arch/arm/setup.c
>> @@ -59,6 +59,10 @@ static unsigned long opt_xenheap_megabytes __initdata;
>>  integer_param("xenheap_megabytes", opt_xenheap_megabytes);
>>  #endif
>>  
>> +/* "acpi=force" : Enables acpi */
>> +static void parse_acpi_param(char *s);
>> +custom_param("acpi", parse_acpi_param);
>> +
>>  static __used void init_done(void)
>>  {
>>      free_init_memory();
>> @@ -84,6 +88,23 @@ static const char * __initdata processor_implementers[] = {
>>      ['i'] = "Intel Corporation",
>>  };
>>  
>> +static char __initdata acpi_param[10] = "";
>> +static void __init parse_acpi_param(char *s)
>> +{
>> +    /* Save the parameter so it can be propagated to domain0. */
>> +    safe_strcpy(acpi_param, s);
> 
> This acpi_param is never used within this series. Please drop it or
> either implement what the comment claim.
> 
>> +
>> +    /* Interpret the parameter for use within Xen. */
>> +    if ( !parse_bool(s) )
>> +    {
>> +        disable_acpi();
>> +    }
>> +    else if ( !strcmp(s, "force") )
>> +    {
>> +        acpi_disabled = 0;
>> +    }
>> +}
>> +
>>  static void __init processor_id(void)
>>  {
>>      const char *implementer = "Unknown";
>> @@ -729,6 +750,7 @@ void __init start_xen(unsigned long boot_phys_offset,
>>          + (fdt_paddr & ((1 << SECOND_SHIFT) - 1));
>>      fdt_size = boot_fdt_info(device_tree_flattened, fdt_paddr);
>>  
>> +    disable_acpi();
>>      cmdline = boot_fdt_cmdline(device_tree_flattened);
>>      printk("Command line: %s\n", cmdline);
>>      cmdline_parse(cmdline);
>>
> 
> Regards,
> 

-- 
Shannon

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

* [PATCH v3 00/62] Add ACPI support for arm64 on Xen
  2015-11-17 11:10   ` David Vrabel
  2015-11-17 13:02     ` Shannon Zhao
@ 2015-11-17 13:02     ` Shannon Zhao
  1 sibling, 0 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-11-17 13:02 UTC (permalink / raw)
  To: linux-arm-kernel



On 2015/11/17 19:10, David Vrabel wrote:
> On 17/11/15 10:59, Jan Beulich wrote:
>>>>> On 17.11.15 at 10:39, <shannon.zhao@linaro.org> wrote:
>>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>>
>>> This patch set adds ACPI support for arm64 on Xen. The design document
>>> could be found from [1].
>>
>> Thank you very much for sending a 62-patch series to a set of people
>> without tailoring the distribution list for the individual patches. I'm
>> pretty sure I mentioned this to you before - please be mindful of the
>> workload you impose on other people by sending out patches. I'll
>> make limited effort of identifying the patches I actually need to look
>> at, but the risk of patches getting discarded is going to be there.
> 
> Yes, I skimmed the subjects and it doesn't look like I'm the maintainer
> for any of the patches.
> 
The reason that I Cc to you is you gave some comments on the design
document before. Thanks.

> Please don't Cc me in the future.
> 
Will do.

-- 
Shannon

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

* Re: [PATCH v3 00/62] Add ACPI support for arm64 on Xen
  2015-11-17 11:10   ` David Vrabel
@ 2015-11-17 13:02     ` Shannon Zhao
  2015-11-17 13:02     ` Shannon Zhao
  1 sibling, 0 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-11-17 13:02 UTC (permalink / raw)
  To: David Vrabel, Jan Beulich, shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, linux-arm-kernel, christoffer.dall,
	roger.pau



On 2015/11/17 19:10, David Vrabel wrote:
> On 17/11/15 10:59, Jan Beulich wrote:
>>>>> On 17.11.15 at 10:39, <shannon.zhao@linaro.org> wrote:
>>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>>
>>> This patch set adds ACPI support for arm64 on Xen. The design document
>>> could be found from [1].
>>
>> Thank you very much for sending a 62-patch series to a set of people
>> without tailoring the distribution list for the individual patches. I'm
>> pretty sure I mentioned this to you before - please be mindful of the
>> workload you impose on other people by sending out patches. I'll
>> make limited effort of identifying the patches I actually need to look
>> at, but the risk of patches getting discarded is going to be there.
> 
> Yes, I skimmed the subjects and it doesn't look like I'm the maintainer
> for any of the patches.
> 
The reason that I Cc to you is you gave some comments on the design
document before. Thanks.

> Please don't Cc me in the future.
> 
Will do.

-- 
Shannon

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

* [PATCH v3 56/62] arm/acpi: Deny MMIO access of UART
  2015-11-17 12:04   ` Julien Grall
  2015-11-17 13:10     ` Shannon Zhao
@ 2015-11-17 13:10     ` Shannon Zhao
  2015-11-27 14:50       ` Stefano Stabellini
                         ` (3 more replies)
  1 sibling, 4 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-11-17 13:10 UTC (permalink / raw)
  To: linux-arm-kernel



On 2015/11/17 20:04, Julien Grall wrote:
> On 17/11/15 09:40, shannon.zhao at linaro.org wrote:
>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>
>> Firstly it permits full MMIO capabilities for Dom0. Then deny MMIO
>> access of UART device.
> 
> I'm nearly sure we want to deny other MMIO such as the GIC regions and SMMU.
> 
But Dom0 will not know the real GIC hardware MMIO space, how would it
map these regions? In case of wrong use?
Regarding SMMU, since it doesn't support now, so I didn't add it but it
could be added later.

-- 
Shannon

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

* Re: [PATCH v3 56/62] arm/acpi: Deny MMIO access of UART
  2015-11-17 12:04   ` Julien Grall
@ 2015-11-17 13:10     ` Shannon Zhao
  2015-11-17 13:10     ` Shannon Zhao
  1 sibling, 0 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-11-17 13:10 UTC (permalink / raw)
  To: Julien Grall, shannon.zhao, ian.campbell, stefano.stabellini,
	keir, jbeulich, andrew.cooper3, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, christoffer.dall,
	peter.huangpeng, david.vrabel, linux-arm-kernel, roger.pau



On 2015/11/17 20:04, Julien Grall wrote:
> On 17/11/15 09:40, shannon.zhao@linaro.org wrote:
>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>
>> Firstly it permits full MMIO capabilities for Dom0. Then deny MMIO
>> access of UART device.
> 
> I'm nearly sure we want to deny other MMIO such as the GIC regions and SMMU.
> 
But Dom0 will not know the real GIC hardware MMIO space, how would it
map these regions? In case of wrong use?
Regarding SMMU, since it doesn't support now, so I didn't add it but it
could be added later.

-- 
Shannon

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

* [PATCH v3 24/62] arm: Introduce a generic way to use a device from acpi
  2015-11-17 12:40   ` Julien Grall
  2015-11-17 13:21     ` Shannon Zhao
@ 2015-11-17 13:21     ` Shannon Zhao
  2015-11-17 14:25       ` Julien Grall
  2015-11-17 14:25       ` Julien Grall
  1 sibling, 2 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-11-17 13:21 UTC (permalink / raw)
  To: linux-arm-kernel



On 2015/11/17 20:40, Julien Grall wrote:
> Hi Shannon,
> 
> On 17/11/15 09:40, shannon.zhao at linaro.org wrote:
>> From: Parth Dixit <parth.dixit@linaro.org>
>>
>> Add generic way to use device from acpi similar to the way it is
>> supported in device tree.
>>
>> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> ---
>>  xen/arch/arm/device.c        | 19 +++++++++++++++++++
>>  xen/arch/arm/xen.lds.S       |  7 +++++++
>>  xen/include/asm-arm/device.h | 30 ++++++++++++++++++++++++++++++
>>  3 files changed, 56 insertions(+)
>>
>> diff --git a/xen/arch/arm/device.c b/xen/arch/arm/device.c
>> index 0b53f6a..5494de0 100644
>> --- a/xen/arch/arm/device.c
>> +++ b/xen/arch/arm/device.c
>> @@ -22,6 +22,7 @@
>>  #include <xen/lib.h>
>>  
>>  extern const struct device_desc _sdevice[], _edevice[];
>> +extern const struct acpi_device_desc _asdevice[], _aedevice[];
>>  
>>  int __init device_init(struct dt_device_node *dev, enum device_class class,
>>                         const void *data)
>> @@ -50,6 +51,24 @@ int __init device_init(struct dt_device_node *dev, enum device_class class,
>>      return -EBADF;
>>  }
>>  
>> +int __init acpi_device_init(enum device_class class, const void *data, int class_type)
> 
> As said on a previous version, please explain what means class_type and
> how this will fit with every
> ACPI device tables.
> 
> AFAICT, it does only works for SPCR table used for UART device. For the
> GIC you've hardcoded the value and I can't find any version number in
> the table.
> 
No, I didn't hardcode the GIC version. Since ACPI 6.0 introduces GIC
version in generic distributor table, it could get the version from
that. Please see [PATCH v3 28/62].

> You may need to introduce another way to find the device such as a
> callback taking the table in parameter.
> 

-- 
Shannon

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

* Re: [PATCH v3 24/62] arm: Introduce a generic way to use a device from acpi
  2015-11-17 12:40   ` Julien Grall
@ 2015-11-17 13:21     ` Shannon Zhao
  2015-11-17 13:21     ` Shannon Zhao
  1 sibling, 0 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-11-17 13:21 UTC (permalink / raw)
  To: Julien Grall, shannon.zhao, ian.campbell, stefano.stabellini,
	keir, jbeulich, andrew.cooper3, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, christoffer.dall,
	peter.huangpeng, david.vrabel, linux-arm-kernel, roger.pau



On 2015/11/17 20:40, Julien Grall wrote:
> Hi Shannon,
> 
> On 17/11/15 09:40, shannon.zhao@linaro.org wrote:
>> From: Parth Dixit <parth.dixit@linaro.org>
>>
>> Add generic way to use device from acpi similar to the way it is
>> supported in device tree.
>>
>> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> ---
>>  xen/arch/arm/device.c        | 19 +++++++++++++++++++
>>  xen/arch/arm/xen.lds.S       |  7 +++++++
>>  xen/include/asm-arm/device.h | 30 ++++++++++++++++++++++++++++++
>>  3 files changed, 56 insertions(+)
>>
>> diff --git a/xen/arch/arm/device.c b/xen/arch/arm/device.c
>> index 0b53f6a..5494de0 100644
>> --- a/xen/arch/arm/device.c
>> +++ b/xen/arch/arm/device.c
>> @@ -22,6 +22,7 @@
>>  #include <xen/lib.h>
>>  
>>  extern const struct device_desc _sdevice[], _edevice[];
>> +extern const struct acpi_device_desc _asdevice[], _aedevice[];
>>  
>>  int __init device_init(struct dt_device_node *dev, enum device_class class,
>>                         const void *data)
>> @@ -50,6 +51,24 @@ int __init device_init(struct dt_device_node *dev, enum device_class class,
>>      return -EBADF;
>>  }
>>  
>> +int __init acpi_device_init(enum device_class class, const void *data, int class_type)
> 
> As said on a previous version, please explain what means class_type and
> how this will fit with every
> ACPI device tables.
> 
> AFAICT, it does only works for SPCR table used for UART device. For the
> GIC you've hardcoded the value and I can't find any version number in
> the table.
> 
No, I didn't hardcode the GIC version. Since ACPI 6.0 introduces GIC
version in generic distributor table, it could get the version from
that. Please see [PATCH v3 28/62].

> You may need to introduce another way to find the device such as a
> callback taking the table in parameter.
> 

-- 
Shannon

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

* [PATCH v3 01/62] Revert "xen/arm: vgic-v2: Drop cbase from arch_domain"
  2015-11-17 12:32     ` Shannon Zhao
@ 2015-11-17 13:57       ` Julien Grall
  2015-11-18  2:28         ` Shannon Zhao
  2015-11-18  2:28         ` Shannon Zhao
  2015-11-17 13:57       ` Julien Grall
  1 sibling, 2 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-17 13:57 UTC (permalink / raw)
  To: linux-arm-kernel

On 17/11/15 12:32, Shannon Zhao wrote:
> Hi Julien,
> 
> On 2015/11/17 19:27, Julien Grall wrote:
>> Hi Shannon,
>>
>> Why do you want to revert this patch?
>>
> Because d->arch.vgic.cbase will be used by creating Dom0 MADT table
> later. See [PATCH v3 43/62].
> +            gicc.base_address = d->arch.vgic.cbase;
> 
> My previous way is get this from ACPI table but someone suggest get it
> from struct domain and I think this way is better too since it uses the
> value after being parsed.

It's pointless to store the value in arch_domain for something that it's
only use during building...

We have struct kernel_info which store any information related to the
DOM0 during the building.

> And sorry that I didn't notice this patch before when you send it out to
> list.

In any case you have to explain in the commit message why you want to
revert the patch.

Regards,

-- 
Julien Grall

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

* Re: [PATCH v3 01/62] Revert "xen/arm: vgic-v2: Drop cbase from arch_domain"
  2015-11-17 12:32     ` Shannon Zhao
  2015-11-17 13:57       ` Julien Grall
@ 2015-11-17 13:57       ` Julien Grall
  1 sibling, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-17 13:57 UTC (permalink / raw)
  To: Shannon Zhao, shannon.zhao, ian.campbell, stefano.stabellini,
	keir, jbeulich, andrew.cooper3, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, christoffer.dall,
	peter.huangpeng, david.vrabel, linux-arm-kernel, roger.pau

On 17/11/15 12:32, Shannon Zhao wrote:
> Hi Julien,
> 
> On 2015/11/17 19:27, Julien Grall wrote:
>> Hi Shannon,
>>
>> Why do you want to revert this patch?
>>
> Because d->arch.vgic.cbase will be used by creating Dom0 MADT table
> later. See [PATCH v3 43/62].
> +            gicc.base_address = d->arch.vgic.cbase;
> 
> My previous way is get this from ACPI table but someone suggest get it
> from struct domain and I think this way is better too since it uses the
> value after being parsed.

It's pointless to store the value in arch_domain for something that it's
only use during building...

We have struct kernel_info which store any information related to the
DOM0 during the building.

> And sorry that I didn't notice this patch before when you send it out to
> list.

In any case you have to explain in the commit message why you want to
revert the patch.

Regards,

-- 
Julien Grall

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

* [PATCH v3 38/62] arm/acpi: Add placeholder for efi and acpi load address
  2015-11-17 12:45     ` Shannon Zhao
@ 2015-11-17 14:23       ` Julien Grall
  2015-11-18  3:01         ` Shannon Zhao
  2015-11-18  3:01         ` Shannon Zhao
  2015-11-17 14:23       ` Julien Grall
                         ` (2 subsequent siblings)
  3 siblings, 2 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-17 14:23 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Shannon,

On 17/11/15 12:45, Shannon Zhao wrote:
> 
> 
> On 2015/11/17 19:58, Julien Grall wrote:
>> Hi Shannon,
>>
>> On 17/11/15 09:40, shannon.zhao at linaro.org wrote:
>>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>>
>>> EFI table, memory description table and some of acpi tables will be
>>> placed after DOM0 memory space. 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>
>>> ---
>>>  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 1e61f30..91272e5 100644
>>> --- a/xen/include/asm-arm/domain.h
>>> +++ b/xen/include/asm-arm/domain.h
>>> @@ -125,6 +125,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
>>
>> Why do you need this in the arch_domain? AFAICT those 3 variables should
>> only be used while building DOM0, so a better place would be in struct
>> kernel_info (see xen/arch/arm/kernel.h).
>>
> 
> Since I use efi_acpi_table to store the allocated pages pointer which
> are used to store newly created ACPI and EFI tables.
> See [PATCH v3 40/62]:
> +    order = get_order_from_bytes(d->arch.efi_acpi_len);
> +    d->arch.efi_acpi_table = alloc_xenheap_pages(order, 0);
> 
> And it free these pages when destroying this domain:
> +#ifdef CONFIG_ACPI
> +    free_xenheap_pages(d->arch.efi_acpi_table,
> +                       get_order_from_bytes(d->arch.efi_acpi_len));
> +#endif

But this is wrong. You are assuming that DOM0 memory is direct mapped
which may not be true in the future.

You should have at least mentioned that in the commit message.

Regards,

-- 
Julien Grall

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

* Re: [PATCH v3 38/62] arm/acpi: Add placeholder for efi and acpi load address
  2015-11-17 12:45     ` Shannon Zhao
  2015-11-17 14:23       ` Julien Grall
@ 2015-11-17 14:23       ` Julien Grall
  2015-11-26 16:02       ` Stefano Stabellini
  2015-11-26 16:02       ` Stefano Stabellini
  3 siblings, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-17 14:23 UTC (permalink / raw)
  To: Shannon Zhao, shannon.zhao, ian.campbell, stefano.stabellini,
	keir, jbeulich, andrew.cooper3, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, christoffer.dall,
	peter.huangpeng, david.vrabel, linux-arm-kernel, roger.pau

Hi Shannon,

On 17/11/15 12:45, Shannon Zhao wrote:
> 
> 
> On 2015/11/17 19:58, Julien Grall wrote:
>> Hi Shannon,
>>
>> On 17/11/15 09:40, shannon.zhao@linaro.org wrote:
>>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>>
>>> EFI table, memory description table and some of acpi tables will be
>>> placed after DOM0 memory space. 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>
>>> ---
>>>  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 1e61f30..91272e5 100644
>>> --- a/xen/include/asm-arm/domain.h
>>> +++ b/xen/include/asm-arm/domain.h
>>> @@ -125,6 +125,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
>>
>> Why do you need this in the arch_domain? AFAICT those 3 variables should
>> only be used while building DOM0, so a better place would be in struct
>> kernel_info (see xen/arch/arm/kernel.h).
>>
> 
> Since I use efi_acpi_table to store the allocated pages pointer which
> are used to store newly created ACPI and EFI tables.
> See [PATCH v3 40/62]:
> +    order = get_order_from_bytes(d->arch.efi_acpi_len);
> +    d->arch.efi_acpi_table = alloc_xenheap_pages(order, 0);
> 
> And it free these pages when destroying this domain:
> +#ifdef CONFIG_ACPI
> +    free_xenheap_pages(d->arch.efi_acpi_table,
> +                       get_order_from_bytes(d->arch.efi_acpi_len));
> +#endif

But this is wrong. You are assuming that DOM0 memory is direct mapped
which may not be true in the future.

You should have at least mentioned that in the commit message.

Regards,

-- 
Julien Grall

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

* [PATCH v3 24/62] arm: Introduce a generic way to use a device from acpi
  2015-11-17 13:21     ` Shannon Zhao
@ 2015-11-17 14:25       ` Julien Grall
  2015-11-18  2:37         ` Shannon Zhao
  2015-11-18  2:37         ` Shannon Zhao
  2015-11-17 14:25       ` Julien Grall
  1 sibling, 2 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-17 14:25 UTC (permalink / raw)
  To: linux-arm-kernel

On 17/11/15 13:21, Shannon Zhao wrote:
>> AFAICT, it does only works for SPCR table used for UART device. For the
>> GIC you've hardcoded the value and I can't find any version number in
>> the table.
>>
> No, I didn't hardcode the GIC version. Since ACPI 6.0 introduces GIC
> version in generic distributor table, it could get the version from
> that. Please see [PATCH v3 28/62].

+    if ( dist->version == ACPI_MADT_GIC_VERSION_V2 )
+        rc = acpi_device_init(DEVICE_GIC, NULL, GIC_V2);
+    else if ( dist->version == ACPI_MADT_GIC_VERSION_V3 )
+        rc = acpi_device_init(DEVICE_GIC, NULL, GIC_V3);

Every single time a new GIC version will be added, we will had to add
another else if. I'm sorry but it's what I call hardcoding.

Regards,

-- 
Julien Grall

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

* Re: [PATCH v3 24/62] arm: Introduce a generic way to use a device from acpi
  2015-11-17 13:21     ` Shannon Zhao
  2015-11-17 14:25       ` Julien Grall
@ 2015-11-17 14:25       ` Julien Grall
  1 sibling, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-17 14:25 UTC (permalink / raw)
  To: Shannon Zhao, shannon.zhao, ian.campbell, stefano.stabellini,
	keir, jbeulich, andrew.cooper3, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, christoffer.dall,
	peter.huangpeng, david.vrabel, linux-arm-kernel, roger.pau

On 17/11/15 13:21, Shannon Zhao wrote:
>> AFAICT, it does only works for SPCR table used for UART device. For the
>> GIC you've hardcoded the value and I can't find any version number in
>> the table.
>>
> No, I didn't hardcode the GIC version. Since ACPI 6.0 introduces GIC
> version in generic distributor table, it could get the version from
> that. Please see [PATCH v3 28/62].

+    if ( dist->version == ACPI_MADT_GIC_VERSION_V2 )
+        rc = acpi_device_init(DEVICE_GIC, NULL, GIC_V2);
+    else if ( dist->version == ACPI_MADT_GIC_VERSION_V3 )
+        rc = acpi_device_init(DEVICE_GIC, NULL, GIC_V3);

Every single time a new GIC version will be added, we will had to add
another else if. I'm sorry but it's what I call hardcoding.

Regards,

-- 
Julien Grall

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

* [PATCH v3 61/62] arm/acpi: Add acpi parameter to enable/disable acpi
  2015-11-17 12:57     ` Shannon Zhao
  2015-11-17 14:32       ` Julien Grall
@ 2015-11-17 14:32       ` Julien Grall
  1 sibling, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-17 14:32 UTC (permalink / raw)
  To: linux-arm-kernel

On 17/11/15 12:57, Shannon Zhao wrote:
> Hi,
> 
> On 2015/11/17 20:26, Julien Grall wrote:
>> Hi Shannon,
>>
>> I would have appreciate if you I had looked on comments made on the
>> series sent by Parth.
>>
> I do look. But I didn't find "Follow-Ups" ones at [1]. And among the
> mails which Parth forwarded to me there is no [PATCH v2 37/41]. This is
> werid.

Sorry, it looks like the xen-devel archive didn't record it. I know that
some mails are missing time to time.

Give a look to:

http://www.gossamer-threads.com/lists/xen/devel/406613

-- 
Julien Grall

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

* Re: [PATCH v3 61/62] arm/acpi: Add acpi parameter to enable/disable acpi
  2015-11-17 12:57     ` Shannon Zhao
@ 2015-11-17 14:32       ` Julien Grall
  2015-11-17 14:32       ` Julien Grall
  1 sibling, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-17 14:32 UTC (permalink / raw)
  To: Shannon Zhao, shannon.zhao, ian.campbell, stefano.stabellini,
	keir, jbeulich, andrew.cooper3, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, christoffer.dall,
	peter.huangpeng, david.vrabel, linux-arm-kernel, roger.pau

On 17/11/15 12:57, Shannon Zhao wrote:
> Hi,
> 
> On 2015/11/17 20:26, Julien Grall wrote:
>> Hi Shannon,
>>
>> I would have appreciate if you I had looked on comments made on the
>> series sent by Parth.
>>
> I do look. But I didn't find "Follow-Ups" ones at [1]. And among the
> mails which Parth forwarded to me there is no [PATCH v2 37/41]. This is
> werid.

Sorry, it looks like the xen-devel archive didn't record it. I know that
some mails are missing time to time.

Give a look to:

http://www.gossamer-threads.com/lists/xen/devel/406613

-- 
Julien Grall

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

* [PATCH v3 01/62] Revert "xen/arm: vgic-v2: Drop cbase from arch_domain"
  2015-11-17 13:57       ` Julien Grall
  2015-11-18  2:28         ` Shannon Zhao
@ 2015-11-18  2:28         ` Shannon Zhao
  2015-11-18 11:41           ` Julien Grall
  2015-11-18 11:41           ` Julien Grall
  1 sibling, 2 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-11-18  2:28 UTC (permalink / raw)
  To: linux-arm-kernel



On 2015/11/17 21:57, Julien Grall wrote:
> On 17/11/15 12:32, Shannon Zhao wrote:
>> > Hi Julien,
>> > 
>> > On 2015/11/17 19:27, Julien Grall wrote:
>>> >> Hi Shannon,
>>> >>
>>> >> Why do you want to revert this patch?
>>> >>
>> > Because d->arch.vgic.cbase will be used by creating Dom0 MADT table
>> > later. See [PATCH v3 43/62].
>> > +            gicc.base_address = d->arch.vgic.cbase;
>> > 
>> > My previous way is get this from ACPI table but someone suggest get it
>> > from struct domain and I think this way is better too since it uses the
>> > value after being parsed.
> It's pointless to store the value in arch_domain for something that it's
> only use during building...
> 
> We have struct kernel_info which store any information related to the
> DOM0 during the building.
> 

Yeah, that would be better if it could use kernel_info. But the problem
is that kernel_info is firstly used in construct_dom0(), while it needs
to store the cbase in domain_create() which is called before
construct_dom0(). And if we pass kernel_info as parameter to
domain_create(), this would introduce more changes to common codes.

Do you have any better idea to handle this?

Thanks,
-- 
Shannon

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

* Re: [PATCH v3 01/62] Revert "xen/arm: vgic-v2: Drop cbase from arch_domain"
  2015-11-17 13:57       ` Julien Grall
@ 2015-11-18  2:28         ` Shannon Zhao
  2015-11-18  2:28         ` Shannon Zhao
  1 sibling, 0 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-11-18  2:28 UTC (permalink / raw)
  To: Julien Grall, shannon.zhao
  Cc: hangaohuai, ian.campbell, peter.huangpeng, xen-devel,
	stefano.stabellini, linux-arm-kernel



On 2015/11/17 21:57, Julien Grall wrote:
> On 17/11/15 12:32, Shannon Zhao wrote:
>> > Hi Julien,
>> > 
>> > On 2015/11/17 19:27, Julien Grall wrote:
>>> >> Hi Shannon,
>>> >>
>>> >> Why do you want to revert this patch?
>>> >>
>> > Because d->arch.vgic.cbase will be used by creating Dom0 MADT table
>> > later. See [PATCH v3 43/62].
>> > +            gicc.base_address = d->arch.vgic.cbase;
>> > 
>> > My previous way is get this from ACPI table but someone suggest get it
>> > from struct domain and I think this way is better too since it uses the
>> > value after being parsed.
> It's pointless to store the value in arch_domain for something that it's
> only use during building...
> 
> We have struct kernel_info which store any information related to the
> DOM0 during the building.
> 

Yeah, that would be better if it could use kernel_info. But the problem
is that kernel_info is firstly used in construct_dom0(), while it needs
to store the cbase in domain_create() which is called before
construct_dom0(). And if we pass kernel_info as parameter to
domain_create(), this would introduce more changes to common codes.

Do you have any better idea to handle this?

Thanks,
-- 
Shannon

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

* [PATCH v3 24/62] arm: Introduce a generic way to use a device from acpi
  2015-11-17 14:25       ` Julien Grall
  2015-11-18  2:37         ` Shannon Zhao
@ 2015-11-18  2:37         ` Shannon Zhao
  2015-11-18 11:46           ` Julien Grall
  2015-11-18 11:46           ` Julien Grall
  1 sibling, 2 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-11-18  2:37 UTC (permalink / raw)
  To: linux-arm-kernel



On 2015/11/17 22:25, Julien Grall wrote:
> On 17/11/15 13:21, Shannon Zhao wrote:
>>> AFAICT, it does only works for SPCR table used for UART device. For the
>>> GIC you've hardcoded the value and I can't find any version number in
>>> the table.
>>>
>> No, I didn't hardcode the GIC version. Since ACPI 6.0 introduces GIC
>> version in generic distributor table, it could get the version from
>> that. Please see [PATCH v3 28/62].
> 
> +    if ( dist->version == ACPI_MADT_GIC_VERSION_V2 )
> +        rc = acpi_device_init(DEVICE_GIC, NULL, GIC_V2);
> +    else if ( dist->version == ACPI_MADT_GIC_VERSION_V3 )
> +        rc = acpi_device_init(DEVICE_GIC, NULL, GIC_V3);
> 
> Every single time a new GIC version will be added, we will had to add
> another else if. I'm sorry but it's what I call hardcoding.
> 

Oh, I see. If it uses the enum acpi_madt_gic_version for ACPI GIC not
the enum gic_version, it could match 1:1. Something like below:

It uses ACPI_MADT_GIC_VERSION_V2 for GICv2.

ACPI_DEVICE_START(agicv2, "GICv2", DEVICE_GIC)
        .class_type = ACPI_MADT_GIC_VERSION_V2,
        .init = acpi_gicv2_preinit,
ACPI_DEVICE_END

Then get the GIC version from MADT table and call

acpi_device_init(DEVICE_GIC, NULL, dist->version);

How about this way?

Thanks,
-- 
Shannon

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

* Re: [PATCH v3 24/62] arm: Introduce a generic way to use a device from acpi
  2015-11-17 14:25       ` Julien Grall
@ 2015-11-18  2:37         ` Shannon Zhao
  2015-11-18  2:37         ` Shannon Zhao
  1 sibling, 0 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-11-18  2:37 UTC (permalink / raw)
  To: Julien Grall, shannon.zhao, xen-devel
  Cc: hangaohuai, stefano.stabellini, ian.campbell, linux-arm-kernel,
	peter.huangpeng



On 2015/11/17 22:25, Julien Grall wrote:
> On 17/11/15 13:21, Shannon Zhao wrote:
>>> AFAICT, it does only works for SPCR table used for UART device. For the
>>> GIC you've hardcoded the value and I can't find any version number in
>>> the table.
>>>
>> No, I didn't hardcode the GIC version. Since ACPI 6.0 introduces GIC
>> version in generic distributor table, it could get the version from
>> that. Please see [PATCH v3 28/62].
> 
> +    if ( dist->version == ACPI_MADT_GIC_VERSION_V2 )
> +        rc = acpi_device_init(DEVICE_GIC, NULL, GIC_V2);
> +    else if ( dist->version == ACPI_MADT_GIC_VERSION_V3 )
> +        rc = acpi_device_init(DEVICE_GIC, NULL, GIC_V3);
> 
> Every single time a new GIC version will be added, we will had to add
> another else if. I'm sorry but it's what I call hardcoding.
> 

Oh, I see. If it uses the enum acpi_madt_gic_version for ACPI GIC not
the enum gic_version, it could match 1:1. Something like below:

It uses ACPI_MADT_GIC_VERSION_V2 for GICv2.

ACPI_DEVICE_START(agicv2, "GICv2", DEVICE_GIC)
        .class_type = ACPI_MADT_GIC_VERSION_V2,
        .init = acpi_gicv2_preinit,
ACPI_DEVICE_END

Then get the GIC version from MADT table and call

acpi_device_init(DEVICE_GIC, NULL, dist->version);

How about this way?

Thanks,
-- 
Shannon

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

* [PATCH v3 38/62] arm/acpi: Add placeholder for efi and acpi load address
  2015-11-17 14:23       ` Julien Grall
@ 2015-11-18  3:01         ` Shannon Zhao
  2015-11-18 11:56           ` Julien Grall
  2015-11-18 11:56           ` Julien Grall
  2015-11-18  3:01         ` Shannon Zhao
  1 sibling, 2 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-11-18  3:01 UTC (permalink / raw)
  To: linux-arm-kernel

On 2015/11/17 22:23, Julien Grall wrote:
> Hi Shannon,
> 
> On 17/11/15 12:45, Shannon Zhao wrote:
>>
>>
>> On 2015/11/17 19:58, Julien Grall wrote:
>>> Hi Shannon,
>>>
>>> On 17/11/15 09:40, shannon.zhao at linaro.org wrote:
>>>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>>>
>>>> EFI table, memory description table and some of acpi tables will be
>>>> placed after DOM0 memory space. 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>
>>>> ---
>>>>  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 1e61f30..91272e5 100644
>>>> --- a/xen/include/asm-arm/domain.h
>>>> +++ b/xen/include/asm-arm/domain.h
>>>> @@ -125,6 +125,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
>>>
>>> Why do you need this in the arch_domain? AFAICT those 3 variables should
>>> only be used while building DOM0, so a better place would be in struct
>>> kernel_info (see xen/arch/arm/kernel.h).
>>>
>>
>> Since I use efi_acpi_table to store the allocated pages pointer which
>> are used to store newly created ACPI and EFI tables.
>> See [PATCH v3 40/62]:
>> +    order = get_order_from_bytes(d->arch.efi_acpi_len);
>> +    d->arch.efi_acpi_table = alloc_xenheap_pages(order, 0);
>>
>> And it free these pages when destroying this domain:
>> +#ifdef CONFIG_ACPI
>> +    free_xenheap_pages(d->arch.efi_acpi_table,
>> +                       get_order_from_bytes(d->arch.efi_acpi_len));
>> +#endif
> 
> But this is wrong. You are assuming that DOM0 memory is direct mapped
> which may not be true in the future.
> 
I think we have discussed this when we discussed the design doc.

"All above tables will be mapped to Dom0 non-RAM space. Since when
booting through ACPI it doesn't need the grant table region(see below
section 3), it could use this region to store the tables or use the same
way to find one memory region to store them."

Firstly, as Jan suggested, these tables should not be in RAM space, so
we drop the previous way that copying these tables to Dom0 RAM.
Then I suggested map these tables to the space after the Dom0 RAM space,
but this not right because Dom0 RAM region might be at the edge of
physical RAM space and there might be device MMIO regions.
Then you suggest it could map these tables to the region which is used
for grant table(or the region found by the same way) while it's not used
when it boots with ACPI. These regions are not used by Xen and will not
be used by Dom0 either currently. But as you say, it will be wrong if
Dom0 memory is not 1:1 mapped.

So how about below idea:
We still copy these tables to Dom0 RAM space but when we create
EFI_MMAP_TABLE, we remove the space occupied by these tables from the
EfiConventionalMemory descriptor.

Thanks,
--
Shannon

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

* Re: [PATCH v3 38/62] arm/acpi: Add placeholder for efi and acpi load address
  2015-11-17 14:23       ` Julien Grall
  2015-11-18  3:01         ` Shannon Zhao
@ 2015-11-18  3:01         ` Shannon Zhao
  1 sibling, 0 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-11-18  3:01 UTC (permalink / raw)
  To: Julien Grall, shannon.zhao
  Cc: hangaohuai, ian.campbell, peter.huangpeng, xen-devel,
	stefano.stabellini, Jan Beulich, linux-arm-kernel

On 2015/11/17 22:23, Julien Grall wrote:
> Hi Shannon,
> 
> On 17/11/15 12:45, Shannon Zhao wrote:
>>
>>
>> On 2015/11/17 19:58, Julien Grall wrote:
>>> Hi Shannon,
>>>
>>> On 17/11/15 09:40, shannon.zhao@linaro.org wrote:
>>>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>>>
>>>> EFI table, memory description table and some of acpi tables will be
>>>> placed after DOM0 memory space. 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>
>>>> ---
>>>>  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 1e61f30..91272e5 100644
>>>> --- a/xen/include/asm-arm/domain.h
>>>> +++ b/xen/include/asm-arm/domain.h
>>>> @@ -125,6 +125,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
>>>
>>> Why do you need this in the arch_domain? AFAICT those 3 variables should
>>> only be used while building DOM0, so a better place would be in struct
>>> kernel_info (see xen/arch/arm/kernel.h).
>>>
>>
>> Since I use efi_acpi_table to store the allocated pages pointer which
>> are used to store newly created ACPI and EFI tables.
>> See [PATCH v3 40/62]:
>> +    order = get_order_from_bytes(d->arch.efi_acpi_len);
>> +    d->arch.efi_acpi_table = alloc_xenheap_pages(order, 0);
>>
>> And it free these pages when destroying this domain:
>> +#ifdef CONFIG_ACPI
>> +    free_xenheap_pages(d->arch.efi_acpi_table,
>> +                       get_order_from_bytes(d->arch.efi_acpi_len));
>> +#endif
> 
> But this is wrong. You are assuming that DOM0 memory is direct mapped
> which may not be true in the future.
> 
I think we have discussed this when we discussed the design doc.

"All above tables will be mapped to Dom0 non-RAM space. Since when
booting through ACPI it doesn't need the grant table region(see below
section 3), it could use this region to store the tables or use the same
way to find one memory region to store them."

Firstly, as Jan suggested, these tables should not be in RAM space, so
we drop the previous way that copying these tables to Dom0 RAM.
Then I suggested map these tables to the space after the Dom0 RAM space,
but this not right because Dom0 RAM region might be at the edge of
physical RAM space and there might be device MMIO regions.
Then you suggest it could map these tables to the region which is used
for grant table(or the region found by the same way) while it's not used
when it boots with ACPI. These regions are not used by Xen and will not
be used by Dom0 either currently. But as you say, it will be wrong if
Dom0 memory is not 1:1 mapped.

So how about below idea:
We still copy these tables to Dom0 RAM space but when we create
EFI_MMAP_TABLE, we remove the space occupied by these tables from the
EfiConventionalMemory descriptor.

Thanks,
--
Shannon

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

* [PATCH v3 50/62] xen/efi: store EFI system table in efi structure
  2015-11-17 11:57   ` Julien Grall
  2015-11-18  3:17     ` Shannon Zhao
@ 2015-11-18  3:17     ` Shannon Zhao
  1 sibling, 0 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-11-18  3:17 UTC (permalink / raw)
  To: linux-arm-kernel

On 2015/11/17 19:57, Julien Grall wrote:
> Hi Shannon,
> 
> On 17/11/15 09:40, shannon.zhao at linaro.org wrote:
>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>
>> When preparing EFI tables for Dom0, it needs the information of EFI
>> system table. Here store it in efi structure.
> 
> On ARM64 the EFI stub is completely independent and therefore it's not
> possible to share variable between Xen and the stub.
> 
> If it's working today is only by luck as we zero the BSS after the stub
> jumped to Xen entry point.
> 
Yes, that's right. Sorry, I didn't investigate this deeply while just
getting this patch of Parth version.

I re-think about it. The reason why we need that variable is that when
we create EFI System table for Dom0 it copies the table header from
that. Since it supplies Dom0 a Xen specific UEFI and it could get the
information from other way, this change is not necessary. I'll drop this
at next version.

Thanks,
-- 
Shannon

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

* Re: [PATCH v3 50/62] xen/efi: store EFI system table in efi structure
  2015-11-17 11:57   ` Julien Grall
@ 2015-11-18  3:17     ` Shannon Zhao
  2015-11-18  3:17     ` Shannon Zhao
  1 sibling, 0 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-11-18  3:17 UTC (permalink / raw)
  To: Julien Grall, shannon.zhao
  Cc: hangaohuai, ian.campbell, peter.huangpeng, xen-devel,
	stefano.stabellini, jbeulich, linux-arm-kernel

On 2015/11/17 19:57, Julien Grall wrote:
> Hi Shannon,
> 
> On 17/11/15 09:40, shannon.zhao@linaro.org wrote:
>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>
>> When preparing EFI tables for Dom0, it needs the information of EFI
>> system table. Here store it in efi structure.
> 
> On ARM64 the EFI stub is completely independent and therefore it's not
> possible to share variable between Xen and the stub.
> 
> If it's working today is only by luck as we zero the BSS after the stub
> jumped to Xen entry point.
> 
Yes, that's right. Sorry, I didn't investigate this deeply while just
getting this patch of Parth version.

I re-think about it. The reason why we need that variable is that when
we create EFI System table for Dom0 it copies the table header from
that. Since it supplies Dom0 a Xen specific UEFI and it could get the
information from other way, this change is not necessary. I'll drop this
at next version.

Thanks,
-- 
Shannon

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

* Re: [PATCH v3 51/62] arm/acpi: Prepare EFI system table for Dom0
  2015-11-17 12:02   ` Julien Grall
@ 2015-11-18  3:34     ` Shannon Zhao
  2015-11-18 12:06       ` Julien Grall
  0 siblings, 1 reply; 426+ messages in thread
From: Shannon Zhao @ 2015-11-18  3:34 UTC (permalink / raw)
  To: Julien Grall, shannon.zhao, xen-devel
  Cc: hangaohuai, stefano.stabellini, ian.campbell, peter.huangpeng

On 2015/11/17 20:02, Julien Grall wrote:
> I'm nearly sure I already said it, this code already exists in the tree.
> Why do you need to implement a new version?
Ok, it needs to move the functions to the public place, right? So they
can be called from other places.

Thanks,
-- 
Shannon

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

* [PATCH v3 04/62] arm/acpi: Emulate io ports for arm
  2015-11-17  9:50     ` Arnd Bergmann
  (?)
  (?)
@ 2015-11-18  7:01     ` Shannon Zhao
  2015-11-18  8:24       ` Arnd Bergmann
  2015-11-18  8:24       ` Arnd Bergmann
  -1 siblings, 2 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-11-18  7:01 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Arnd,

On 2015/11/17 17:50, Arnd Bergmann wrote:
> On Tuesday 17 November 2015 17:40:03 shannon.zhao at linaro.org wrote:
>> +/*
>> + * Emulate x86 io ports for arm.
>> + */
>> +#define __armio(addr) ( (void __iomem *)addr )
>> +
>> +#define inb(c) ( readb( __armio(c) ) )
>> +#define inw(c) ( readw( __armio(c) ) )
>> +#define inl(c) ( readl( __armio(c) ) )
>> +
>> +#define outb(v, c) ( writeb(v, __armio(c) ) )
>> +#define outw(v, c) ( writew(v, __armio(c) ) )
>> +#define outl(v, c) ( writel(v, __armio(c) ) )
>> +
> 
> This is almost certainly wrong. There might be I/O port accesses, but they
> won't be in the same place as normal pointers.
> 
Sorry, maybe I didn't get what you mean. Here it just wants emulate the
in(b,w,l) and out(b,w,l) which exist on x86 while not on ARM. So it
could introduce less change to the common ACPI codes, for example
acpi_os_write_port().

I see there is the same thing in Linux arch/arm/include/asm/io.h

Thanks,
-- 
Shannon

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

* Re: [PATCH v3 04/62] arm/acpi: Emulate io ports for arm
  2015-11-17  9:50     ` Arnd Bergmann
  (?)
@ 2015-11-18  7:01     ` Shannon Zhao
  -1 siblings, 0 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-11-18  7:01 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: hangaohuai, ian.campbell, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, shannon.zhao, linux-arm-kernel

Hi Arnd,

On 2015/11/17 17:50, Arnd Bergmann wrote:
> On Tuesday 17 November 2015 17:40:03 shannon.zhao@linaro.org wrote:
>> +/*
>> + * Emulate x86 io ports for arm.
>> + */
>> +#define __armio(addr) ( (void __iomem *)addr )
>> +
>> +#define inb(c) ( readb( __armio(c) ) )
>> +#define inw(c) ( readw( __armio(c) ) )
>> +#define inl(c) ( readl( __armio(c) ) )
>> +
>> +#define outb(v, c) ( writeb(v, __armio(c) ) )
>> +#define outw(v, c) ( writew(v, __armio(c) ) )
>> +#define outl(v, c) ( writel(v, __armio(c) ) )
>> +
> 
> This is almost certainly wrong. There might be I/O port accesses, but they
> won't be in the same place as normal pointers.
> 
Sorry, maybe I didn't get what you mean. Here it just wants emulate the
in(b,w,l) and out(b,w,l) which exist on x86 while not on ARM. So it
could introduce less change to the common ACPI codes, for example
acpi_os_write_port().

I see there is the same thing in Linux arch/arm/include/asm/io.h

Thanks,
-- 
Shannon

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

* [PATCH v3 00/62] Add ACPI support for arm64 on Xen
  2015-11-17 11:52 ` Julien Grall
@ 2015-11-18  8:03   ` Shannon Zhao
  2015-11-18 12:18     ` Julien Grall
  2015-11-18 12:18     ` Julien Grall
  2015-11-18  8:03   ` Shannon Zhao
  1 sibling, 2 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-11-18  8:03 UTC (permalink / raw)
  To: linux-arm-kernel

On 2015/11/17 19:52, Julien Grall wrote:
> Hi Shannon,
> 
> On 17/11/15 09:39, shannon.zhao at linaro.org wrote:
>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>
>> This patch set adds ACPI support for arm64 on Xen. The design document
>> could be found from [1].
> 
> Thank you for your work on it. I think this series would benefits to be
> split in smaller series.
> 
> I would do a first series which split DT code from common code. So we
> can get this code as soon as possible in Xen, avoid you to spend less
> time rebasing your us to be spammed with 62 patches for each new version.
> 

Sure, I think I can split this patch set in three parts.

First one would be porting the necessary Linux changes of ACPI 5.0~6.0.
It includes:

ACPI 5.0: Add new/changed tables to headers (only changes of Generic
Interrupt and Generic Distributor and some changes already exist)
ACPICA/ARM: ACPI 5.1: Update for MADT changes.
ACPICA: ACPI 6.0: Add changes for MADT table.
ACPICA: ACPI 6.0: Add values for MADT GIC version field
ACPICA/ARM: ACPI 5.1: Update for FADT changes.
ACPICA: ACPI 6.0: Add changes for FADT table
ACPICA/ARM: ACPI 5.1: Update for GTDT table changes.
ACPICA: Headers: Add GTDT flag definitions for the timer subtable.
ACPICA: ACPI 6.0: Add support for STAO table

Second one as you suggest would be the series which split DT codes from
common code.

And the last one would be the series which add ACPI support for Xen on
ARM and prepare the necessary things for Dom0.

How about this way? The order of the first and second can be changed if
you like.

Thanks,
-- 
Shannon

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

* Re: [PATCH v3 00/62] Add ACPI support for arm64 on Xen
  2015-11-17 11:52 ` Julien Grall
  2015-11-18  8:03   ` Shannon Zhao
@ 2015-11-18  8:03   ` Shannon Zhao
  1 sibling, 0 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-11-18  8:03 UTC (permalink / raw)
  Cc: hangaohuai, ian.campbell, peter.huangpeng, xen-devel,
	Julien Grall, stefano.stabellini, shannon.zhao, jbeulich,
	linux-arm-kernel

On 2015/11/17 19:52, Julien Grall wrote:
> Hi Shannon,
> 
> On 17/11/15 09:39, shannon.zhao@linaro.org wrote:
>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>
>> This patch set adds ACPI support for arm64 on Xen. The design document
>> could be found from [1].
> 
> Thank you for your work on it. I think this series would benefits to be
> split in smaller series.
> 
> I would do a first series which split DT code from common code. So we
> can get this code as soon as possible in Xen, avoid you to spend less
> time rebasing your us to be spammed with 62 patches for each new version.
> 

Sure, I think I can split this patch set in three parts.

First one would be porting the necessary Linux changes of ACPI 5.0~6.0.
It includes:

ACPI 5.0: Add new/changed tables to headers (only changes of Generic
Interrupt and Generic Distributor and some changes already exist)
ACPICA/ARM: ACPI 5.1: Update for MADT changes.
ACPICA: ACPI 6.0: Add changes for MADT table.
ACPICA: ACPI 6.0: Add values for MADT GIC version field
ACPICA/ARM: ACPI 5.1: Update for FADT changes.
ACPICA: ACPI 6.0: Add changes for FADT table
ACPICA/ARM: ACPI 5.1: Update for GTDT table changes.
ACPICA: Headers: Add GTDT flag definitions for the timer subtable.
ACPICA: ACPI 6.0: Add support for STAO table

Second one as you suggest would be the series which split DT codes from
common code.

And the last one would be the series which add ACPI support for Xen on
ARM and prepare the necessary things for Dom0.

How about this way? The order of the first and second can be changed if
you like.

Thanks,
-- 
Shannon

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

* [PATCH v3 04/62] arm/acpi: Emulate io ports for arm
  2015-11-18  7:01     ` Shannon Zhao
  2015-11-18  8:24       ` Arnd Bergmann
@ 2015-11-18  8:24       ` Arnd Bergmann
  1 sibling, 0 replies; 426+ messages in thread
From: Arnd Bergmann @ 2015-11-18  8:24 UTC (permalink / raw)
  To: linux-arm-kernel

On Wednesday 18 November 2015 15:01:26 Shannon Zhao wrote:
> Hi Arnd,
> 
> On 2015/11/17 17:50, Arnd Bergmann wrote:
> > On Tuesday 17 November 2015 17:40:03 shannon.zhao at linaro.org wrote:
> >> +/*
> >> + * Emulate x86 io ports for arm.
> >> + */
> >> +#define __armio(addr) ( (void __iomem *)addr )
> >> +
> >> +#define inb(c) ( readb( __armio(c) ) )
> >> +#define inw(c) ( readw( __armio(c) ) )
> >> +#define inl(c) ( readl( __armio(c) ) )
> >> +
> >> +#define outb(v, c) ( writeb(v, __armio(c) ) )
> >> +#define outw(v, c) ( writew(v, __armio(c) ) )
> >> +#define outl(v, c) ( writel(v, __armio(c) ) )
> >> +
> > 
> > This is almost certainly wrong. There might be I/O port accesses, but they
> > won't be in the same place as normal pointers.
> > 
> Sorry, maybe I didn't get what you mean. Here it just wants emulate the
> in(b,w,l) and out(b,w,l) which exist on x86 while not on ARM. So it
> could introduce less change to the common ACPI codes, for example
> acpi_os_write_port().
> 
> I see there is the same thing in Linux arch/arm/include/asm/io.h

The problem is that your definition of __armio() is wrong. If you want to
do it right, you need to first find the PCI I/O port ranges and map them
into a virtual address, and then define __armio() in a way to add
the virtual address you have mapped them to.

Alternatively, define the functions so they don't try to access the
pointers but instead just print a warning.

	Arnd

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

* Re: [PATCH v3 04/62] arm/acpi: Emulate io ports for arm
  2015-11-18  7:01     ` Shannon Zhao
@ 2015-11-18  8:24       ` Arnd Bergmann
  2015-11-18  8:24       ` Arnd Bergmann
  1 sibling, 0 replies; 426+ messages in thread
From: Arnd Bergmann @ 2015-11-18  8:24 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: hangaohuai, ian.campbell, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, shannon.zhao, linux-arm-kernel

On Wednesday 18 November 2015 15:01:26 Shannon Zhao wrote:
> Hi Arnd,
> 
> On 2015/11/17 17:50, Arnd Bergmann wrote:
> > On Tuesday 17 November 2015 17:40:03 shannon.zhao@linaro.org wrote:
> >> +/*
> >> + * Emulate x86 io ports for arm.
> >> + */
> >> +#define __armio(addr) ( (void __iomem *)addr )
> >> +
> >> +#define inb(c) ( readb( __armio(c) ) )
> >> +#define inw(c) ( readw( __armio(c) ) )
> >> +#define inl(c) ( readl( __armio(c) ) )
> >> +
> >> +#define outb(v, c) ( writeb(v, __armio(c) ) )
> >> +#define outw(v, c) ( writew(v, __armio(c) ) )
> >> +#define outl(v, c) ( writel(v, __armio(c) ) )
> >> +
> > 
> > This is almost certainly wrong. There might be I/O port accesses, but they
> > won't be in the same place as normal pointers.
> > 
> Sorry, maybe I didn't get what you mean. Here it just wants emulate the
> in(b,w,l) and out(b,w,l) which exist on x86 while not on ARM. So it
> could introduce less change to the common ACPI codes, for example
> acpi_os_write_port().
> 
> I see there is the same thing in Linux arch/arm/include/asm/io.h

The problem is that your definition of __armio() is wrong. If you want to
do it right, you need to first find the PCI I/O port ranges and map them
into a virtual address, and then define __armio() in a way to add
the virtual address you have mapped them to.

Alternatively, define the functions so they don't try to access the
pointers but instead just print a warning.

	Arnd

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

* [PATCH v3 01/62] Revert "xen/arm: vgic-v2: Drop cbase from arch_domain"
  2015-11-18  2:28         ` Shannon Zhao
@ 2015-11-18 11:41           ` Julien Grall
  2015-11-18 13:09             ` Shannon Zhao
  2015-11-18 13:09             ` Shannon Zhao
  2015-11-18 11:41           ` Julien Grall
  1 sibling, 2 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-18 11:41 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Shannon,

On 18/11/15 02:28, Shannon Zhao wrote:

> On 2015/11/17 21:57, Julien Grall wrote:
>> On 17/11/15 12:32, Shannon Zhao wrote:
>>>> Hi Julien,
>>>>
>>>> On 2015/11/17 19:27, Julien Grall wrote:
>>>>>> Hi Shannon,
>>>>>>
>>>>>> Why do you want to revert this patch?
>>>>>>
>>>> Because d->arch.vgic.cbase will be used by creating Dom0 MADT table
>>>> later. See [PATCH v3 43/62].
>>>> +            gicc.base_address = d->arch.vgic.cbase;
>>>>
>>>> My previous way is get this from ACPI table but someone suggest get it
>>>> from struct domain and I think this way is better too since it uses the
>>>> value after being parsed.
>> It's pointless to store the value in arch_domain for something that it's
>> only use during building...
>>
>> We have struct kernel_info which store any information related to the
>> DOM0 during the building.
>>
> 
> Yeah, that would be better if it could use kernel_info. But the problem
> is that kernel_info is firstly used in construct_dom0(), while it needs
> to store the cbase in domain_create() which is called before
> construct_dom0(). And if we pass kernel_info as parameter to
> domain_create(), this would introduce more changes to common codes.
> 
> Do you have any better idea to handle this?

Yes, introducing callback to create the ACPI table in the GIC driver.
See what we did for make_hwdom_dt_node.

We are trying to make the domain_build domain as agnostic as possible
from the GIC version. However in patch #43, you implement specific
version in the domain builder.

It will also not scale very well when we will introduce GICv2m and ITS.

The version of the GIC (ACPI_MADT_GIC_*) could be introduced in the
vgic_ops.

The re-distributor could be moved in gic-v3.c and the generic interrupt
controller in gic-v2.c.

Note it's a mandatory to emulate the same version as the hardware for
the virtual GIC.

Regards,

-- 
Julien Grall

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

* Re: [PATCH v3 01/62] Revert "xen/arm: vgic-v2: Drop cbase from arch_domain"
  2015-11-18  2:28         ` Shannon Zhao
  2015-11-18 11:41           ` Julien Grall
@ 2015-11-18 11:41           ` Julien Grall
  1 sibling, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-18 11:41 UTC (permalink / raw)
  To: Shannon Zhao, shannon.zhao
  Cc: hangaohuai, ian.campbell, peter.huangpeng, xen-devel,
	stefano.stabellini, linux-arm-kernel

Hi Shannon,

On 18/11/15 02:28, Shannon Zhao wrote:

> On 2015/11/17 21:57, Julien Grall wrote:
>> On 17/11/15 12:32, Shannon Zhao wrote:
>>>> Hi Julien,
>>>>
>>>> On 2015/11/17 19:27, Julien Grall wrote:
>>>>>> Hi Shannon,
>>>>>>
>>>>>> Why do you want to revert this patch?
>>>>>>
>>>> Because d->arch.vgic.cbase will be used by creating Dom0 MADT table
>>>> later. See [PATCH v3 43/62].
>>>> +            gicc.base_address = d->arch.vgic.cbase;
>>>>
>>>> My previous way is get this from ACPI table but someone suggest get it
>>>> from struct domain and I think this way is better too since it uses the
>>>> value after being parsed.
>> It's pointless to store the value in arch_domain for something that it's
>> only use during building...
>>
>> We have struct kernel_info which store any information related to the
>> DOM0 during the building.
>>
> 
> Yeah, that would be better if it could use kernel_info. But the problem
> is that kernel_info is firstly used in construct_dom0(), while it needs
> to store the cbase in domain_create() which is called before
> construct_dom0(). And if we pass kernel_info as parameter to
> domain_create(), this would introduce more changes to common codes.
> 
> Do you have any better idea to handle this?

Yes, introducing callback to create the ACPI table in the GIC driver.
See what we did for make_hwdom_dt_node.

We are trying to make the domain_build domain as agnostic as possible
from the GIC version. However in patch #43, you implement specific
version in the domain builder.

It will also not scale very well when we will introduce GICv2m and ITS.

The version of the GIC (ACPI_MADT_GIC_*) could be introduced in the
vgic_ops.

The re-distributor could be moved in gic-v3.c and the generic interrupt
controller in gic-v2.c.

Note it's a mandatory to emulate the same version as the hardware for
the virtual GIC.

Regards,

-- 
Julien Grall

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

* [PATCH v3 24/62] arm: Introduce a generic way to use a device from acpi
  2015-11-18  2:37         ` Shannon Zhao
  2015-11-18 11:46           ` Julien Grall
@ 2015-11-18 11:46           ` Julien Grall
  1 sibling, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-18 11:46 UTC (permalink / raw)
  To: linux-arm-kernel

On 18/11/15 02:37, Shannon Zhao wrote:
> 
> 
> On 2015/11/17 22:25, Julien Grall wrote:
>> On 17/11/15 13:21, Shannon Zhao wrote:
>>>> AFAICT, it does only works for SPCR table used for UART device. For the
>>>> GIC you've hardcoded the value and I can't find any version number in
>>>> the table.
>>>>
>>> No, I didn't hardcode the GIC version. Since ACPI 6.0 introduces GIC
>>> version in generic distributor table, it could get the version from
>>> that. Please see [PATCH v3 28/62].
>>
>> +    if ( dist->version == ACPI_MADT_GIC_VERSION_V2 )
>> +        rc = acpi_device_init(DEVICE_GIC, NULL, GIC_V2);
>> +    else if ( dist->version == ACPI_MADT_GIC_VERSION_V3 )
>> +        rc = acpi_device_init(DEVICE_GIC, NULL, GIC_V3);
>>
>> Every single time a new GIC version will be added, we will had to add
>> another else if. I'm sorry but it's what I call hardcoding.
>>
> 
> Oh, I see. If it uses the enum acpi_madt_gic_version for ACPI GIC not
> the enum gic_version, it could match 1:1. Something like below:
> 
> It uses ACPI_MADT_GIC_VERSION_V2 for GICv2.
> 
> ACPI_DEVICE_START(agicv2, "GICv2", DEVICE_GIC)
>         .class_type = ACPI_MADT_GIC_VERSION_V2,
>         .init = acpi_gicv2_preinit,
> ACPI_DEVICE_END
> 
> Then get the GIC version from MADT table and call
> 
> acpi_device_init(DEVICE_GIC, NULL, dist->version);
> 
> How about this way?

That would be better. We want the common mode as agnostic as possible
from the GIC version.

Regards,

-- 
Julien Grall

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

* Re: [PATCH v3 24/62] arm: Introduce a generic way to use a device from acpi
  2015-11-18  2:37         ` Shannon Zhao
@ 2015-11-18 11:46           ` Julien Grall
  2015-11-18 11:46           ` Julien Grall
  1 sibling, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-18 11:46 UTC (permalink / raw)
  To: Shannon Zhao, shannon.zhao, xen-devel
  Cc: hangaohuai, stefano.stabellini, ian.campbell, linux-arm-kernel,
	peter.huangpeng

On 18/11/15 02:37, Shannon Zhao wrote:
> 
> 
> On 2015/11/17 22:25, Julien Grall wrote:
>> On 17/11/15 13:21, Shannon Zhao wrote:
>>>> AFAICT, it does only works for SPCR table used for UART device. For the
>>>> GIC you've hardcoded the value and I can't find any version number in
>>>> the table.
>>>>
>>> No, I didn't hardcode the GIC version. Since ACPI 6.0 introduces GIC
>>> version in generic distributor table, it could get the version from
>>> that. Please see [PATCH v3 28/62].
>>
>> +    if ( dist->version == ACPI_MADT_GIC_VERSION_V2 )
>> +        rc = acpi_device_init(DEVICE_GIC, NULL, GIC_V2);
>> +    else if ( dist->version == ACPI_MADT_GIC_VERSION_V3 )
>> +        rc = acpi_device_init(DEVICE_GIC, NULL, GIC_V3);
>>
>> Every single time a new GIC version will be added, we will had to add
>> another else if. I'm sorry but it's what I call hardcoding.
>>
> 
> Oh, I see. If it uses the enum acpi_madt_gic_version for ACPI GIC not
> the enum gic_version, it could match 1:1. Something like below:
> 
> It uses ACPI_MADT_GIC_VERSION_V2 for GICv2.
> 
> ACPI_DEVICE_START(agicv2, "GICv2", DEVICE_GIC)
>         .class_type = ACPI_MADT_GIC_VERSION_V2,
>         .init = acpi_gicv2_preinit,
> ACPI_DEVICE_END
> 
> Then get the GIC version from MADT table and call
> 
> acpi_device_init(DEVICE_GIC, NULL, dist->version);
> 
> How about this way?

That would be better. We want the common mode as agnostic as possible
from the GIC version.

Regards,

-- 
Julien Grall

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

* [PATCH v3 38/62] arm/acpi: Add placeholder for efi and acpi load address
  2015-11-18  3:01         ` Shannon Zhao
@ 2015-11-18 11:56           ` Julien Grall
  2015-11-26 16:04             ` Stefano Stabellini
  2015-11-26 16:04             ` Stefano Stabellini
  2015-11-18 11:56           ` Julien Grall
  1 sibling, 2 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-18 11:56 UTC (permalink / raw)
  To: linux-arm-kernel

On 18/11/15 03:01, Shannon Zhao wrote:
> "All above tables will be mapped to Dom0 non-RAM space. Since when
> booting through ACPI it doesn't need the grant table region(see below
> section 3), it could use this region to store the tables or use the same
> way to find one memory region to store them."
> 
> Firstly, as Jan suggested, these tables should not be in RAM space, so
> we drop the previous way that copying these tables to Dom0 RAM.
> Then I suggested map these tables to the space after the Dom0 RAM space,
> but this not right because Dom0 RAM region might be at the edge of
> physical RAM space and there might be device MMIO regions.
> Then you suggest it could map these tables to the region which is used
> for grant table(or the region found by the same way) while it's not used
> when it boots with ACPI. These regions are not used by Xen and will not
> be used by Dom0 either currently. But as you say, it will be wrong if
> Dom0 memory is not 1:1 mapped.

Will you remember in 6 months why you wrote the code like that?

My point on the previous mail is you don't describe what you did,
neither in the code nor in the commit message.

Most of the place in the code are trying to avoid the assumption that
DOM0 is using direct mapped. If not, we always have a comment/commit
message explaining why we are doing like that and the implication (see
the grant table example [1]).

> So how about below idea:
> We still copy these tables to Dom0 RAM space but when we create
> EFI_MMAP_TABLE, we remove the space occupied by these tables from the
> EfiConventionalMemory descriptor.

As you don't need the grant table region, why don't you re-use it fopr
your tables? It may also be possible that we have some space just after
for the EFI table.

Regards,

[1]
http://xenbits.xen.org/gitweb/?p=xen.git;a=commit;h=7e02c881606eb94f177becfa284494d89a3dba2e

-- 
Julien Grall

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

* Re: [PATCH v3 38/62] arm/acpi: Add placeholder for efi and acpi load address
  2015-11-18  3:01         ` Shannon Zhao
  2015-11-18 11:56           ` Julien Grall
@ 2015-11-18 11:56           ` Julien Grall
  1 sibling, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-18 11:56 UTC (permalink / raw)
  To: Shannon Zhao, shannon.zhao
  Cc: hangaohuai, ian.campbell, peter.huangpeng, xen-devel,
	stefano.stabellini, Jan Beulich, linux-arm-kernel

On 18/11/15 03:01, Shannon Zhao wrote:
> "All above tables will be mapped to Dom0 non-RAM space. Since when
> booting through ACPI it doesn't need the grant table region(see below
> section 3), it could use this region to store the tables or use the same
> way to find one memory region to store them."
> 
> Firstly, as Jan suggested, these tables should not be in RAM space, so
> we drop the previous way that copying these tables to Dom0 RAM.
> Then I suggested map these tables to the space after the Dom0 RAM space,
> but this not right because Dom0 RAM region might be at the edge of
> physical RAM space and there might be device MMIO regions.
> Then you suggest it could map these tables to the region which is used
> for grant table(or the region found by the same way) while it's not used
> when it boots with ACPI. These regions are not used by Xen and will not
> be used by Dom0 either currently. But as you say, it will be wrong if
> Dom0 memory is not 1:1 mapped.

Will you remember in 6 months why you wrote the code like that?

My point on the previous mail is you don't describe what you did,
neither in the code nor in the commit message.

Most of the place in the code are trying to avoid the assumption that
DOM0 is using direct mapped. If not, we always have a comment/commit
message explaining why we are doing like that and the implication (see
the grant table example [1]).

> So how about below idea:
> We still copy these tables to Dom0 RAM space but when we create
> EFI_MMAP_TABLE, we remove the space occupied by these tables from the
> EfiConventionalMemory descriptor.

As you don't need the grant table region, why don't you re-use it fopr
your tables? It may also be possible that we have some space just after
for the EFI table.

Regards,

[1]
http://xenbits.xen.org/gitweb/?p=xen.git;a=commit;h=7e02c881606eb94f177becfa284494d89a3dba2e

-- 
Julien Grall

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

* Re: [PATCH v3 51/62] arm/acpi: Prepare EFI system table for Dom0
  2015-11-18  3:34     ` Shannon Zhao
@ 2015-11-18 12:06       ` Julien Grall
  0 siblings, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-18 12:06 UTC (permalink / raw)
  To: Shannon Zhao, shannon.zhao, xen-devel
  Cc: hangaohuai, stefano.stabellini, ian.campbell, peter.huangpeng

On 18/11/15 03:34, Shannon Zhao wrote:
> On 2015/11/17 20:02, Julien Grall wrote:
>> I'm nearly sure I already said it, this code already exists in the tree.
>> Why do you need to implement a new version?
> Ok, it needs to move the functions to the public place, right? So they
> can be called from other places.

I don't think you need to move the current function code. AFAICT, it's
already exported by common/xz/crc32.c

Regards,

-- 
Julien Grall

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

* [Xen-devel] [PATCH v3 51/62] arm/acpi: Prepare EFI system table for Dom0
  2015-11-17  9:40   ` shannon.zhao
                     ` (3 preceding siblings ...)
  (?)
@ 2015-11-18 12:09   ` Julien Grall
  -1 siblings, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-18 12:09 UTC (permalink / raw)
  To: linux-arm-kernel

On 17/11/15 09:40, shannon.zhao at linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/domain_build.c |  2 ++
>  xen/common/efi/boot.c       | 64 +++++++++++++++++++++++++++++++++++++++++++++

Why do you add the creation of ACPI table in efi/boot.c?

This file is only supposed to contain the EFI stub and nothing else.

Regards,

-- 
Julien Grall

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

* Re: [PATCH v3 51/62] arm/acpi: Prepare EFI system table for Dom0
  2015-11-17  9:40   ` shannon.zhao
                     ` (2 preceding siblings ...)
  (?)
@ 2015-11-18 12:09   ` Julien Grall
  -1 siblings, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-18 12:09 UTC (permalink / raw)
  To: shannon.zhao, ian.campbell, stefano.stabellini, keir, jbeulich,
	andrew.cooper3, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, peter.huangpeng,
	david.vrabel, zhaoshenglong, roger.pau, christoffer.dall,
	linux-arm-kernel

On 17/11/15 09:40, shannon.zhao@linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/domain_build.c |  2 ++
>  xen/common/efi/boot.c       | 64 +++++++++++++++++++++++++++++++++++++++++++++

Why do you add the creation of ACPI table in efi/boot.c?

This file is only supposed to contain the EFI stub and nothing else.

Regards,

-- 
Julien Grall

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

* [Xen-devel] [PATCH v3 31/62] arm/acpi: Add a helper function to get interrupt type
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-18 12:16   ` Julien Grall
  -1 siblings, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-18 12:16 UTC (permalink / raw)
  To: linux-arm-kernel

On 17/11/15 09:40, shannon.zhao at linaro.org wrote:
> +/**
> + * IRQ line type.
> + *
> + * ACPI_IRQ_TYPE_NONE            - default, unspecified type
> + * ACPI_IRQ_TYPE_EDGE_RISING     - rising edge triggered
> + * ACPI_IRQ_TYPE_EDGE_FALLING    - falling edge triggered
> + * ACPI_IRQ_TYPE_EDGE_BOTH       - rising and falling edge triggered
> + * ACPI_IRQ_TYPE_LEVEL_HIGH      - high level triggered
> + * ACPI_IRQ_TYPE_LEVEL_LOW       - low level triggered
> + * ACPI_IRQ_TYPE_LEVEL_MASK      - Mask to filter out the level bits
> + * ACPI_IRQ_TYPE_SENSE_MASK      - Mask for all the above bits
> + * ACPI_IRQ_TYPE_INVALID         - Use to initialize the type
> + */
> +#define ACPI_IRQ_TYPE_NONE           0x00000000
> +#define ACPI_IRQ_TYPE_EDGE_RISING    0x00000001
> +#define ACPI_IRQ_TYPE_EDGE_FALLING   0x00000002
> +#define ACPI_IRQ_TYPE_EDGE_BOTH                           \
> +    (ACPI_IRQ_TYPE_EDGE_FALLING | ACPI_IRQ_TYPE_EDGE_RISING)
> +#define ACPI_IRQ_TYPE_LEVEL_HIGH     0x00000004
> +#define ACPI_IRQ_TYPE_LEVEL_LOW      0x00000008
> +#define ACPI_IRQ_TYPE_LEVEL_MASK                          \
> +    (ACPI_IRQ_TYPE_LEVEL_LOW | ACPI_IRQ_TYPE_LEVEL_HIGH)
> +#define ACPI_IRQ_TYPE_SENSE_MASK     0x0000000f
> +
> +#define ACPI_IRQ_TYPE_INVALID        0x00000010
> +

Using a separate set of *IRQ_TYPE for ACPI and mixing the DT one is wrong.

Today in Xen we only care about edge vs level, so there is no need to
define so many things.

However, if you really want to keep all these types. It should be
firmware agnostic.

>  #endif /*_ASM_ARM_ACPI_H*/
> 

Regards,

-- 
Julien Grall

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

* Re: [PATCH v3 31/62] arm/acpi: Add a helper function to get interrupt type
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-18 12:16   ` Julien Grall
  -1 siblings, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-18 12:16 UTC (permalink / raw)
  To: shannon.zhao, ian.campbell, stefano.stabellini, keir, jbeulich,
	andrew.cooper3, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, peter.huangpeng,
	david.vrabel, zhaoshenglong, roger.pau, christoffer.dall,
	linux-arm-kernel

On 17/11/15 09:40, shannon.zhao@linaro.org wrote:
> +/**
> + * IRQ line type.
> + *
> + * ACPI_IRQ_TYPE_NONE            - default, unspecified type
> + * ACPI_IRQ_TYPE_EDGE_RISING     - rising edge triggered
> + * ACPI_IRQ_TYPE_EDGE_FALLING    - falling edge triggered
> + * ACPI_IRQ_TYPE_EDGE_BOTH       - rising and falling edge triggered
> + * ACPI_IRQ_TYPE_LEVEL_HIGH      - high level triggered
> + * ACPI_IRQ_TYPE_LEVEL_LOW       - low level triggered
> + * ACPI_IRQ_TYPE_LEVEL_MASK      - Mask to filter out the level bits
> + * ACPI_IRQ_TYPE_SENSE_MASK      - Mask for all the above bits
> + * ACPI_IRQ_TYPE_INVALID         - Use to initialize the type
> + */
> +#define ACPI_IRQ_TYPE_NONE           0x00000000
> +#define ACPI_IRQ_TYPE_EDGE_RISING    0x00000001
> +#define ACPI_IRQ_TYPE_EDGE_FALLING   0x00000002
> +#define ACPI_IRQ_TYPE_EDGE_BOTH                           \
> +    (ACPI_IRQ_TYPE_EDGE_FALLING | ACPI_IRQ_TYPE_EDGE_RISING)
> +#define ACPI_IRQ_TYPE_LEVEL_HIGH     0x00000004
> +#define ACPI_IRQ_TYPE_LEVEL_LOW      0x00000008
> +#define ACPI_IRQ_TYPE_LEVEL_MASK                          \
> +    (ACPI_IRQ_TYPE_LEVEL_LOW | ACPI_IRQ_TYPE_LEVEL_HIGH)
> +#define ACPI_IRQ_TYPE_SENSE_MASK     0x0000000f
> +
> +#define ACPI_IRQ_TYPE_INVALID        0x00000010
> +

Using a separate set of *IRQ_TYPE for ACPI and mixing the DT one is wrong.

Today in Xen we only care about edge vs level, so there is no need to
define so many things.

However, if you really want to keep all these types. It should be
firmware agnostic.

>  #endif /*_ASM_ARM_ACPI_H*/
> 

Regards,

-- 
Julien Grall

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

* [PATCH v3 00/62] Add ACPI support for arm64 on Xen
  2015-11-18  8:03   ` Shannon Zhao
@ 2015-11-18 12:18     ` Julien Grall
  2015-11-18 12:18     ` Julien Grall
  1 sibling, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-18 12:18 UTC (permalink / raw)
  To: linux-arm-kernel

On 18/11/15 08:03, Shannon Zhao wrote:
> On 2015/11/17 19:52, Julien Grall wrote:
>> Hi Shannon,
>>
>> On 17/11/15 09:39, shannon.zhao at linaro.org wrote:
>>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>>
>>> This patch set adds ACPI support for arm64 on Xen. The design document
>>> could be found from [1].
>>
>> Thank you for your work on it. I think this series would benefits to be
>> split in smaller series.
>>
>> I would do a first series which split DT code from common code. So we
>> can get this code as soon as possible in Xen, avoid you to spend less
>> time rebasing your us to be spammed with 62 patches for each new version.
>>
> 
> Sure, I think I can split this patch set in three parts.
> 
> First one would be porting the necessary Linux changes of ACPI 5.0~6.0.
> It includes:
> 
> ACPI 5.0: Add new/changed tables to headers (only changes of Generic
> Interrupt and Generic Distributor and some changes already exist)
> ACPICA/ARM: ACPI 5.1: Update for MADT changes.
> ACPICA: ACPI 6.0: Add changes for MADT table.
> ACPICA: ACPI 6.0: Add values for MADT GIC version field
> ACPICA/ARM: ACPI 5.1: Update for FADT changes.
> ACPICA: ACPI 6.0: Add changes for FADT table
> ACPICA/ARM: ACPI 5.1: Update for GTDT table changes.
> ACPICA: Headers: Add GTDT flag definitions for the timer subtable.
> ACPICA: ACPI 6.0: Add support for STAO table
> 
> Second one as you suggest would be the series which split DT codes from
> common code.
> 
> And the last one would be the series which add ACPI support for Xen on
> ARM and prepare the necessary things for Dom0.
> 
> How about this way? The order of the first and second can be changed if
> you like.

I'm fine with either way.

Regards,

-- 
Julien Grall

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

* Re: [PATCH v3 00/62] Add ACPI support for arm64 on Xen
  2015-11-18  8:03   ` Shannon Zhao
  2015-11-18 12:18     ` Julien Grall
@ 2015-11-18 12:18     ` Julien Grall
  1 sibling, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-18 12:18 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: hangaohuai, ian.campbell, peter.huangpeng, xen-devel,
	stefano.stabellini, shannon.zhao, jbeulich, linux-arm-kernel

On 18/11/15 08:03, Shannon Zhao wrote:
> On 2015/11/17 19:52, Julien Grall wrote:
>> Hi Shannon,
>>
>> On 17/11/15 09:39, shannon.zhao@linaro.org wrote:
>>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>>
>>> This patch set adds ACPI support for arm64 on Xen. The design document
>>> could be found from [1].
>>
>> Thank you for your work on it. I think this series would benefits to be
>> split in smaller series.
>>
>> I would do a first series which split DT code from common code. So we
>> can get this code as soon as possible in Xen, avoid you to spend less
>> time rebasing your us to be spammed with 62 patches for each new version.
>>
> 
> Sure, I think I can split this patch set in three parts.
> 
> First one would be porting the necessary Linux changes of ACPI 5.0~6.0.
> It includes:
> 
> ACPI 5.0: Add new/changed tables to headers (only changes of Generic
> Interrupt and Generic Distributor and some changes already exist)
> ACPICA/ARM: ACPI 5.1: Update for MADT changes.
> ACPICA: ACPI 6.0: Add changes for MADT table.
> ACPICA: ACPI 6.0: Add values for MADT GIC version field
> ACPICA/ARM: ACPI 5.1: Update for FADT changes.
> ACPICA: ACPI 6.0: Add changes for FADT table
> ACPICA/ARM: ACPI 5.1: Update for GTDT table changes.
> ACPICA: Headers: Add GTDT flag definitions for the timer subtable.
> ACPICA: ACPI 6.0: Add support for STAO table
> 
> Second one as you suggest would be the series which split DT codes from
> common code.
> 
> And the last one would be the series which add ACPI support for Xen on
> ARM and prepare the necessary things for Dom0.
> 
> How about this way? The order of the first and second can be changed if
> you like.

I'm fine with either way.

Regards,

-- 
Julien Grall

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

* [PATCH v3 01/62] Revert "xen/arm: vgic-v2: Drop cbase from arch_domain"
  2015-11-18 11:41           ` Julien Grall
  2015-11-18 13:09             ` Shannon Zhao
@ 2015-11-18 13:09             ` Shannon Zhao
  2015-11-18 13:33               ` Julien Grall
  2015-11-18 13:33               ` Julien Grall
  1 sibling, 2 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-11-18 13:09 UTC (permalink / raw)
  To: linux-arm-kernel



On 2015/11/18 19:41, Julien Grall wrote:
> Hi Shannon,
>
> On 18/11/15 02:28, Shannon Zhao wrote:
>
>> On 2015/11/17 21:57, Julien Grall wrote:
>>> On 17/11/15 12:32, Shannon Zhao wrote:
>>>>> Hi Julien,
>>>>>
>>>>> On 2015/11/17 19:27, Julien Grall wrote:
>>>>>>> Hi Shannon,
>>>>>>>
>>>>>>> Why do you want to revert this patch?
>>>>>>>
>>>>> Because d->arch.vgic.cbase will be used by creating Dom0 MADT table
>>>>> later. See [PATCH v3 43/62].
>>>>> +            gicc.base_address = d->arch.vgic.cbase;
>>>>>
>>>>> My previous way is get this from ACPI table but someone suggest get it
>>>>> from struct domain and I think this way is better too since it uses the
>>>>> value after being parsed.
>>> It's pointless to store the value in arch_domain for something that it's
>>> only use during building...
>>>
>>> We have struct kernel_info which store any information related to the
>>> DOM0 during the building.
>>>
>>
>> Yeah, that would be better if it could use kernel_info. But the problem
>> is that kernel_info is firstly used in construct_dom0(), while it needs
>> to store the cbase in domain_create() which is called before
>> construct_dom0(). And if we pass kernel_info as parameter to
>> domain_create(), this would introduce more changes to common codes.
>>
>> Do you have any better idea to handle this?
>
> Yes, introducing callback to create the ACPI table in the GIC driver.
> See what we did for make_hwdom_dt_node.
>
> We are trying to make the domain_build domain as agnostic as possible
> from the GIC version. However in patch #43, you implement specific
> version in the domain builder.
>
> It will also not scale very well when we will introduce GICv2m and ITS.
>
> The version of the GIC (ACPI_MADT_GIC_*) could be introduced in the
> vgic_ops.
>
> The re-distributor could be moved in gic-v3.c and the generic interrupt
> controller in gic-v2.c.
>
> Note it's a mandatory to emulate the same version as the hardware for
> the virtual GIC.
>
So it doesn't support vGICv2 on GICv3 hardware for Xen?

Thanks,
-- 
Shannon

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

* Re: [PATCH v3 01/62] Revert "xen/arm: vgic-v2: Drop cbase from arch_domain"
  2015-11-18 11:41           ` Julien Grall
@ 2015-11-18 13:09             ` Shannon Zhao
  2015-11-18 13:09             ` Shannon Zhao
  1 sibling, 0 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-11-18 13:09 UTC (permalink / raw)
  To: Julien Grall, Shannon Zhao
  Cc: hangaohuai, ian.campbell, peter.huangpeng, xen-devel,
	stefano.stabellini, linux-arm-kernel



On 2015/11/18 19:41, Julien Grall wrote:
> Hi Shannon,
>
> On 18/11/15 02:28, Shannon Zhao wrote:
>
>> On 2015/11/17 21:57, Julien Grall wrote:
>>> On 17/11/15 12:32, Shannon Zhao wrote:
>>>>> Hi Julien,
>>>>>
>>>>> On 2015/11/17 19:27, Julien Grall wrote:
>>>>>>> Hi Shannon,
>>>>>>>
>>>>>>> Why do you want to revert this patch?
>>>>>>>
>>>>> Because d->arch.vgic.cbase will be used by creating Dom0 MADT table
>>>>> later. See [PATCH v3 43/62].
>>>>> +            gicc.base_address = d->arch.vgic.cbase;
>>>>>
>>>>> My previous way is get this from ACPI table but someone suggest get it
>>>>> from struct domain and I think this way is better too since it uses the
>>>>> value after being parsed.
>>> It's pointless to store the value in arch_domain for something that it's
>>> only use during building...
>>>
>>> We have struct kernel_info which store any information related to the
>>> DOM0 during the building.
>>>
>>
>> Yeah, that would be better if it could use kernel_info. But the problem
>> is that kernel_info is firstly used in construct_dom0(), while it needs
>> to store the cbase in domain_create() which is called before
>> construct_dom0(). And if we pass kernel_info as parameter to
>> domain_create(), this would introduce more changes to common codes.
>>
>> Do you have any better idea to handle this?
>
> Yes, introducing callback to create the ACPI table in the GIC driver.
> See what we did for make_hwdom_dt_node.
>
> We are trying to make the domain_build domain as agnostic as possible
> from the GIC version. However in patch #43, you implement specific
> version in the domain builder.
>
> It will also not scale very well when we will introduce GICv2m and ITS.
>
> The version of the GIC (ACPI_MADT_GIC_*) could be introduced in the
> vgic_ops.
>
> The re-distributor could be moved in gic-v3.c and the generic interrupt
> controller in gic-v2.c.
>
> Note it's a mandatory to emulate the same version as the hardware for
> the virtual GIC.
>
So it doesn't support vGICv2 on GICv3 hardware for Xen?

Thanks,
-- 
Shannon

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

* [PATCH v3 01/62] Revert "xen/arm: vgic-v2: Drop cbase from arch_domain"
  2015-11-18 13:09             ` Shannon Zhao
  2015-11-18 13:33               ` Julien Grall
@ 2015-11-18 13:33               ` Julien Grall
  2015-11-18 13:38                 ` Shannon Zhao
  2015-11-18 13:38                 ` Shannon Zhao
  1 sibling, 2 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-18 13:33 UTC (permalink / raw)
  To: linux-arm-kernel

On 18/11/15 13:09, Shannon Zhao wrote:
>> Note it's a mandatory to emulate the same version as the hardware for
>> the virtual GIC.
>>
> So it doesn't support vGICv2 on GICv3 hardware for Xen?

Sorry I forgot to say it was for DOM0. We support GICv2 on GICv3 only
for guest.

Regards,

-- 
Julien Grall

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

* Re: [PATCH v3 01/62] Revert "xen/arm: vgic-v2: Drop cbase from arch_domain"
  2015-11-18 13:09             ` Shannon Zhao
@ 2015-11-18 13:33               ` Julien Grall
  2015-11-18 13:33               ` Julien Grall
  1 sibling, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-18 13:33 UTC (permalink / raw)
  To: Shannon Zhao, Shannon Zhao
  Cc: hangaohuai, ian.campbell, peter.huangpeng, xen-devel,
	stefano.stabellini, linux-arm-kernel

On 18/11/15 13:09, Shannon Zhao wrote:
>> Note it's a mandatory to emulate the same version as the hardware for
>> the virtual GIC.
>>
> So it doesn't support vGICv2 on GICv3 hardware for Xen?

Sorry I forgot to say it was for DOM0. We support GICv2 on GICv3 only
for guest.

Regards,

-- 
Julien Grall

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

* [PATCH v3 01/62] Revert "xen/arm: vgic-v2: Drop cbase from arch_domain"
  2015-11-18 13:33               ` Julien Grall
@ 2015-11-18 13:38                 ` Shannon Zhao
  2015-11-18 13:38                 ` Shannon Zhao
  1 sibling, 0 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-11-18 13:38 UTC (permalink / raw)
  To: linux-arm-kernel



On 2015/11/18 21:33, Julien Grall wrote:
> On 18/11/15 13:09, Shannon Zhao wrote:
>>> Note it's a mandatory to emulate the same version as the hardware for
>>> the virtual GIC.
>>>
>> So it doesn't support vGICv2 on GICv3 hardware for Xen?
>
> Sorry I forgot to say it was for DOM0. We support GICv2 on GICv3 only
> for guest.
>
Ok, I see. Thanks for your explanation.

-- 
Shannon

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

* Re: [PATCH v3 01/62] Revert "xen/arm: vgic-v2: Drop cbase from arch_domain"
  2015-11-18 13:33               ` Julien Grall
  2015-11-18 13:38                 ` Shannon Zhao
@ 2015-11-18 13:38                 ` Shannon Zhao
  1 sibling, 0 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-11-18 13:38 UTC (permalink / raw)
  To: Julien Grall, Shannon Zhao
  Cc: hangaohuai, ian.campbell, peter.huangpeng, xen-devel,
	stefano.stabellini, linux-arm-kernel



On 2015/11/18 21:33, Julien Grall wrote:
> On 18/11/15 13:09, Shannon Zhao wrote:
>>> Note it's a mandatory to emulate the same version as the hardware for
>>> the virtual GIC.
>>>
>> So it doesn't support vGICv2 on GICv3 hardware for Xen?
>
> Sorry I forgot to say it was for DOM0. We support GICv2 on GICv3 only
> for guest.
>
Ok, I see. Thanks for your explanation.

-- 
Shannon

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

* [PATCH v3 05/62] acpi: Don't do traditional BIOS table scan for ARM64
  2015-11-17  9:40   ` shannon.zhao
@ 2015-11-23 11:24     ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-23 11:24 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> With the addition of ARM64 that does not have a traditional BIOS to
> scan, add a #ifdef option for x86 to do the traditional BIOS scanning
> for tables.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/drivers/acpi/osl.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/xen/drivers/acpi/osl.c b/xen/drivers/acpi/osl.c
> index ce15470..db74a90 100644
> --- a/xen/drivers/acpi/osl.c
> +++ b/xen/drivers/acpi/osl.c
> @@ -78,7 +78,9 @@ acpi_physical_address __init acpi_os_get_root_pointer(void)
>  	} else {
>  		acpi_physical_address pa = 0;
>  
> +		#ifdef CONFIG_X86
>  		acpi_find_root_pointer(&pa);
> +		#endif
>  		return pa;
>  	}

I think it might be best to error out earlier if acpi and !efi_enabled
on arm and arm64.  If we do that we'll never enter this "else".

If acpi_find_root_pointer doesn't build on arm, we should move it to an
x86 specific location, such as xen/arch/x86/efi.

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

* Re: [PATCH v3 05/62] acpi: Don't do traditional BIOS table scan for ARM64
@ 2015-11-23 11:24     ` Stefano Stabellini
  0 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-23 11:24 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, linux-arm-kernel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, david.vrabel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> With the addition of ARM64 that does not have a traditional BIOS to
> scan, add a #ifdef option for x86 to do the traditional BIOS scanning
> for tables.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/drivers/acpi/osl.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/xen/drivers/acpi/osl.c b/xen/drivers/acpi/osl.c
> index ce15470..db74a90 100644
> --- a/xen/drivers/acpi/osl.c
> +++ b/xen/drivers/acpi/osl.c
> @@ -78,7 +78,9 @@ acpi_physical_address __init acpi_os_get_root_pointer(void)
>  	} else {
>  		acpi_physical_address pa = 0;
>  
> +		#ifdef CONFIG_X86
>  		acpi_find_root_pointer(&pa);
> +		#endif
>  		return pa;
>  	}

I think it might be best to error out earlier if acpi and !efi_enabled
on arm and arm64.  If we do that we'll never enter this "else".

If acpi_find_root_pointer doesn't build on arm, we should move it to an
x86 specific location, such as xen/arch/x86/efi.

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

* [Xen-devel] [PATCH v3 06/62] acpi: Refactor acpi_os_map_memory to be architecturally independent
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-23 11:29   ` Stefano Stabellini
  2015-11-23 11:37     ` Jan Beulich
  2015-11-23 11:37     ` [Xen-devel] " Jan Beulich
  -1 siblings, 2 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-23 11:29 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> Current acpi_os_map_memory is specific to x86. Refactor it to be
> architecturally independent.

I would say "Move it to an x86-specific location".


> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

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


>  xen/arch/x86/acpi/lib.c | 16 ++++++++++++++++
>  xen/drivers/acpi/osl.c  | 12 +-----------
>  xen/include/xen/acpi.h  |  2 ++
>  3 files changed, 19 insertions(+), 11 deletions(-)
> 
> diff --git a/xen/arch/x86/acpi/lib.c b/xen/arch/x86/acpi/lib.c
> index cc15ea3..1e2e124 100644
> --- a/xen/arch/x86/acpi/lib.c
> +++ b/xen/arch/x86/acpi/lib.c
> @@ -33,6 +33,22 @@ u8 __read_mostly acpi_disable_value;
>  u32 __read_mostly x86_acpiid_to_apicid[MAX_MADT_ENTRIES] =
>      {[0 ... MAX_MADT_ENTRIES - 1] = BAD_APICID };
>  
> +void __iomem *
> +arch_acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
> +{
> +	if (system_state >= SYS_STATE_active) {
> +		mfn_t mfn = _mfn(PFN_DOWN(phys));
> +		unsigned int offs = phys & (PAGE_SIZE - 1);
> +
> +		/* The low first Mb is always mapped. */
> +		if ( !((phys + size - 1) >> 20) )
> +			return __va(phys);
> +		return __vmap(&mfn, PFN_UP(offs + size), 1, 1,
> +			      PAGE_HYPERVISOR_NOCACHE) + offs;
> +	}
> +	return __acpi_map_table(phys, size);
> +}
> +
>  /*
>   * Important Safety Note:  The fixed ACPI page numbers are *subtracted*
>   * from the fixed base.  That's why we start at FIX_ACPI_END and
> diff --git a/xen/drivers/acpi/osl.c b/xen/drivers/acpi/osl.c
> index db74a90..54fb0f0 100644
> --- a/xen/drivers/acpi/osl.c
> +++ b/xen/drivers/acpi/osl.c
> @@ -88,17 +88,7 @@ acpi_physical_address __init acpi_os_get_root_pointer(void)
>  void __iomem *
>  acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
>  {
> -	if (system_state >= SYS_STATE_active) {
> -		mfn_t mfn = _mfn(PFN_DOWN(phys));
> -		unsigned int offs = phys & (PAGE_SIZE - 1);
> -
> -		/* The low first Mb is always mapped. */
> -		if ( !((phys + size - 1) >> 20) )
> -			return __va(phys);
> -		return __vmap(&mfn, PFN_UP(offs + size), 1, 1,
> -			      PAGE_HYPERVISOR_NOCACHE) + offs;
> -	}
> -	return __acpi_map_table(phys, size);
> +	return arch_acpi_os_map_memory(phys, size);
>  }
>  
>  void acpi_os_unmap_memory(void __iomem * virt, acpi_size size)
> diff --git a/xen/include/xen/acpi.h b/xen/include/xen/acpi.h
> index 0f1077d..48d7810 100644
> --- a/xen/include/xen/acpi.h
> +++ b/xen/include/xen/acpi.h
> @@ -54,6 +54,8 @@ typedef int (*acpi_table_handler) (struct acpi_table_header *table);
>  
>  typedef int (*acpi_table_entry_handler) (struct acpi_subtable_header *header, const unsigned long end);
>  
> +void __iomem *
> +arch_acpi_os_map_memory(acpi_physical_address phys, acpi_size size);
>  unsigned int acpi_get_processor_id (unsigned int cpu);
>  char * __acpi_map_table (paddr_t phys_addr, unsigned long size);
>  int acpi_boot_init (void);
> -- 
> 2.1.0
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel at lists.xen.org
> http://lists.xen.org/xen-devel
> 

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

* Re: [PATCH v3 06/62] acpi: Refactor acpi_os_map_memory to be architecturally independent
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-23 11:29   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-23 11:29 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, david.vrabel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> Current acpi_os_map_memory is specific to x86. Refactor it to be
> architecturally independent.

I would say "Move it to an x86-specific location".


> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

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


>  xen/arch/x86/acpi/lib.c | 16 ++++++++++++++++
>  xen/drivers/acpi/osl.c  | 12 +-----------
>  xen/include/xen/acpi.h  |  2 ++
>  3 files changed, 19 insertions(+), 11 deletions(-)
> 
> diff --git a/xen/arch/x86/acpi/lib.c b/xen/arch/x86/acpi/lib.c
> index cc15ea3..1e2e124 100644
> --- a/xen/arch/x86/acpi/lib.c
> +++ b/xen/arch/x86/acpi/lib.c
> @@ -33,6 +33,22 @@ u8 __read_mostly acpi_disable_value;
>  u32 __read_mostly x86_acpiid_to_apicid[MAX_MADT_ENTRIES] =
>      {[0 ... MAX_MADT_ENTRIES - 1] = BAD_APICID };
>  
> +void __iomem *
> +arch_acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
> +{
> +	if (system_state >= SYS_STATE_active) {
> +		mfn_t mfn = _mfn(PFN_DOWN(phys));
> +		unsigned int offs = phys & (PAGE_SIZE - 1);
> +
> +		/* The low first Mb is always mapped. */
> +		if ( !((phys + size - 1) >> 20) )
> +			return __va(phys);
> +		return __vmap(&mfn, PFN_UP(offs + size), 1, 1,
> +			      PAGE_HYPERVISOR_NOCACHE) + offs;
> +	}
> +	return __acpi_map_table(phys, size);
> +}
> +
>  /*
>   * Important Safety Note:  The fixed ACPI page numbers are *subtracted*
>   * from the fixed base.  That's why we start at FIX_ACPI_END and
> diff --git a/xen/drivers/acpi/osl.c b/xen/drivers/acpi/osl.c
> index db74a90..54fb0f0 100644
> --- a/xen/drivers/acpi/osl.c
> +++ b/xen/drivers/acpi/osl.c
> @@ -88,17 +88,7 @@ acpi_physical_address __init acpi_os_get_root_pointer(void)
>  void __iomem *
>  acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
>  {
> -	if (system_state >= SYS_STATE_active) {
> -		mfn_t mfn = _mfn(PFN_DOWN(phys));
> -		unsigned int offs = phys & (PAGE_SIZE - 1);
> -
> -		/* The low first Mb is always mapped. */
> -		if ( !((phys + size - 1) >> 20) )
> -			return __va(phys);
> -		return __vmap(&mfn, PFN_UP(offs + size), 1, 1,
> -			      PAGE_HYPERVISOR_NOCACHE) + offs;
> -	}
> -	return __acpi_map_table(phys, size);
> +	return arch_acpi_os_map_memory(phys, size);
>  }
>  
>  void acpi_os_unmap_memory(void __iomem * virt, acpi_size size)
> diff --git a/xen/include/xen/acpi.h b/xen/include/xen/acpi.h
> index 0f1077d..48d7810 100644
> --- a/xen/include/xen/acpi.h
> +++ b/xen/include/xen/acpi.h
> @@ -54,6 +54,8 @@ typedef int (*acpi_table_handler) (struct acpi_table_header *table);
>  
>  typedef int (*acpi_table_entry_handler) (struct acpi_subtable_header *header, const unsigned long end);
>  
> +void __iomem *
> +arch_acpi_os_map_memory(acpi_physical_address phys, acpi_size size);
>  unsigned int acpi_get_processor_id (unsigned int cpu);
>  char * __acpi_map_table (paddr_t phys_addr, unsigned long size);
>  int acpi_boot_init (void);
> -- 
> 2.1.0
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
> 

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

* [PATCH v3 05/62] acpi: Don't do traditional BIOS table scan for ARM64
  2015-11-23 11:24     ` Stefano Stabellini
  (?)
@ 2015-11-23 11:35     ` Jan Beulich
  2015-11-24  3:39       ` Shannon Zhao
  2015-11-24  3:39       ` Shannon Zhao
  -1 siblings, 2 replies; 426+ messages in thread
From: Jan Beulich @ 2015-11-23 11:35 UTC (permalink / raw)
  To: linux-arm-kernel

>>> On 23.11.15 at 12:24, <stefano.stabellini@eu.citrix.com> wrote:
> On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
>> From: Shannon Zhao <shannon.zhao@linaro.org>
>> 
>> With the addition of ARM64 that does not have a traditional BIOS to
>> scan, add a #ifdef option for x86 to do the traditional BIOS scanning
>> for tables.
>> 
>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> ---
>>  xen/drivers/acpi/osl.c | 2 ++
>>  1 file changed, 2 insertions(+)
>> 
>> diff --git a/xen/drivers/acpi/osl.c b/xen/drivers/acpi/osl.c
>> index ce15470..db74a90 100644
>> --- a/xen/drivers/acpi/osl.c
>> +++ b/xen/drivers/acpi/osl.c
>> @@ -78,7 +78,9 @@ acpi_physical_address __init acpi_os_get_root_pointer(void)
>>  	} else {
>>  		acpi_physical_address pa = 0;
>>  
>> +		#ifdef CONFIG_X86
>>  		acpi_find_root_pointer(&pa);
>> +		#endif
>>  		return pa;
>>  	}
> 
> I think it might be best to error out earlier if acpi and !efi_enabled
> on arm and arm64.  If we do that we'll never enter this "else".
> 
> If acpi_find_root_pointer doesn't build on arm, we should move it to an
> x86 specific location, such as xen/arch/x86/efi.

No, definitely not (or if anything, then xen/arch/x86/acpi/). Instead
the function itself should be stubbed out to do nothing on ARM. (And
of course also the #ifdef placement is rather odd).

Jan

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

* Re: [PATCH v3 05/62] acpi: Don't do traditional BIOS table scan for ARM64
  2015-11-23 11:24     ` Stefano Stabellini
  (?)
  (?)
@ 2015-11-23 11:35     ` Jan Beulich
  -1 siblings, 0 replies; 426+ messages in thread
From: Jan Beulich @ 2015-11-23 11:35 UTC (permalink / raw)
  To: Stefano Stabellini, shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, linux-arm-kernel,
	ard.biesheuvel, andrew.cooper3, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, david.vrabel, zhaoshenglong,
	christoffer.dall, roger.pau

>>> On 23.11.15 at 12:24, <stefano.stabellini@eu.citrix.com> wrote:
> On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
>> From: Shannon Zhao <shannon.zhao@linaro.org>
>> 
>> With the addition of ARM64 that does not have a traditional BIOS to
>> scan, add a #ifdef option for x86 to do the traditional BIOS scanning
>> for tables.
>> 
>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> ---
>>  xen/drivers/acpi/osl.c | 2 ++
>>  1 file changed, 2 insertions(+)
>> 
>> diff --git a/xen/drivers/acpi/osl.c b/xen/drivers/acpi/osl.c
>> index ce15470..db74a90 100644
>> --- a/xen/drivers/acpi/osl.c
>> +++ b/xen/drivers/acpi/osl.c
>> @@ -78,7 +78,9 @@ acpi_physical_address __init acpi_os_get_root_pointer(void)
>>  	} else {
>>  		acpi_physical_address pa = 0;
>>  
>> +		#ifdef CONFIG_X86
>>  		acpi_find_root_pointer(&pa);
>> +		#endif
>>  		return pa;
>>  	}
> 
> I think it might be best to error out earlier if acpi and !efi_enabled
> on arm and arm64.  If we do that we'll never enter this "else".
> 
> If acpi_find_root_pointer doesn't build on arm, we should move it to an
> x86 specific location, such as xen/arch/x86/efi.

No, definitely not (or if anything, then xen/arch/x86/acpi/). Instead
the function itself should be stubbed out to do nothing on ARM. (And
of course also the #ifdef placement is rather odd).

Jan

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

* [Xen-devel] [PATCH v3 06/62] acpi: Refactor acpi_os_map_memory to be architecturally independent
  2015-11-23 11:29   ` [Xen-devel] " Stefano Stabellini
  2015-11-23 11:37     ` Jan Beulich
@ 2015-11-23 11:37     ` Jan Beulich
  1 sibling, 0 replies; 426+ messages in thread
From: Jan Beulich @ 2015-11-23 11:37 UTC (permalink / raw)
  To: linux-arm-kernel

>>> On 23.11.15 at 12:29, <stefano.stabellini@eu.citrix.com> wrote:
> On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
>> From: Shannon Zhao <shannon.zhao@linaro.org>
>> Current acpi_os_map_memory is specific to x86. Refactor it to be
>> architecturally independent.
> 
> I would say "Move it to an x86-specific location".

But it shouldn't be moved - only the _truly_ x86-specific pieces should
be factored out.

Jan

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

* Re: [PATCH v3 06/62] acpi: Refactor acpi_os_map_memory to be architecturally independent
  2015-11-23 11:29   ` [Xen-devel] " Stefano Stabellini
@ 2015-11-23 11:37     ` Jan Beulich
  2015-11-23 11:37     ` [Xen-devel] " Jan Beulich
  1 sibling, 0 replies; 426+ messages in thread
From: Jan Beulich @ 2015-11-23 11:37 UTC (permalink / raw)
  To: Stefano Stabellini, shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, linux-arm-kernel,
	ard.biesheuvel, andrew.cooper3, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, david.vrabel, zhaoshenglong,
	christoffer.dall, roger.pau

>>> On 23.11.15 at 12:29, <stefano.stabellini@eu.citrix.com> wrote:
> On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
>> From: Shannon Zhao <shannon.zhao@linaro.org>
>> Current acpi_os_map_memory is specific to x86. Refactor it to be
>> architecturally independent.
> 
> I would say "Move it to an x86-specific location".

But it shouldn't be moved - only the _truly_ x86-specific pieces should
be factored out.

Jan

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

* [PATCH v3 07/62] arm/acpi: Add arch_acpi_os_map_memory helper function for ARM
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-23 11:37   ` Stefano Stabellini
  2015-11-30 14:47     ` Julien Grall
  2015-11-30 14:47     ` [Xen-devel] " Julien Grall
  -1 siblings, 2 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-23 11:37 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>

Hi Shannon,

could you please add a couple of lines to the commit message mentioning
why __va(phys) is an acceptable implementation of arch_acpi_os_map_memory?

Thanks,

Stefano

> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/Makefile      |  1 +
>  xen/arch/arm/acpi/Makefile |  1 +
>  xen/arch/arm/acpi/lib.c    | 33 +++++++++++++++++++++++++++++++++
>  3 files changed, 35 insertions(+)
>  create mode 100644 xen/arch/arm/acpi/Makefile
>  create mode 100644 xen/arch/arm/acpi/lib.c
> 
> diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile
> index 1ef39f7..1851ae8 100644
> --- a/xen/arch/arm/Makefile
> +++ b/xen/arch/arm/Makefile
> @@ -2,6 +2,7 @@ subdir-$(arm32) += arm32
>  subdir-$(arm64) += arm64
>  subdir-y += platforms
>  subdir-$(arm64) += efi
> +subdir-$(HAS_ACPI) += acpi
>  
>  obj-$(EARLY_PRINTK) += early_printk.o
>  obj-y += cpu.o
> diff --git a/xen/arch/arm/acpi/Makefile b/xen/arch/arm/acpi/Makefile
> new file mode 100644
> index 0000000..b5be22d
> --- /dev/null
> +++ b/xen/arch/arm/acpi/Makefile
> @@ -0,0 +1 @@
> +obj-y += lib.o
> diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c
> new file mode 100644
> index 0000000..b68623b
> --- /dev/null
> +++ b/xen/arch/arm/acpi/lib.c
> @@ -0,0 +1,33 @@
> +/*
> + *  lib.c - Architecture-Specific Low-Level ACPI Support
> + *
> + *  Copyright (C) 2015, Shannon Zhao <shannon.zhao@linaro.org>
> + *
> + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License as published by
> + *  the Free Software Foundation; either version 2 of the License, or
> + *  (at your option) any later version.
> + *
> + *  This program is distributed in the hope that it will be useful,
> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + *  GNU General Public License for more details.
> + *
> + *  You should have received a copy of the GNU General Public License
> + *  along with this program; if not, write to the Free Software
> + *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
> + *
> + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> + */
> +
> +#include <xen/acpi.h>
> +#include <xen/mm.h>
> +#include <asm/mm.h>
> +
> +void __iomem *
> +arch_acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
> +{
> +    return __va(phys);
> +}
> -- 
> 2.1.0
> 

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

* Re: [PATCH v3 07/62] arm/acpi: Add arch_acpi_os_map_memory helper function for ARM
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-23 11:37   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-23 11:37 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, linux-arm-kernel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, david.vrabel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>

Hi Shannon,

could you please add a couple of lines to the commit message mentioning
why __va(phys) is an acceptable implementation of arch_acpi_os_map_memory?

Thanks,

Stefano

> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/Makefile      |  1 +
>  xen/arch/arm/acpi/Makefile |  1 +
>  xen/arch/arm/acpi/lib.c    | 33 +++++++++++++++++++++++++++++++++
>  3 files changed, 35 insertions(+)
>  create mode 100644 xen/arch/arm/acpi/Makefile
>  create mode 100644 xen/arch/arm/acpi/lib.c
> 
> diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile
> index 1ef39f7..1851ae8 100644
> --- a/xen/arch/arm/Makefile
> +++ b/xen/arch/arm/Makefile
> @@ -2,6 +2,7 @@ subdir-$(arm32) += arm32
>  subdir-$(arm64) += arm64
>  subdir-y += platforms
>  subdir-$(arm64) += efi
> +subdir-$(HAS_ACPI) += acpi
>  
>  obj-$(EARLY_PRINTK) += early_printk.o
>  obj-y += cpu.o
> diff --git a/xen/arch/arm/acpi/Makefile b/xen/arch/arm/acpi/Makefile
> new file mode 100644
> index 0000000..b5be22d
> --- /dev/null
> +++ b/xen/arch/arm/acpi/Makefile
> @@ -0,0 +1 @@
> +obj-y += lib.o
> diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c
> new file mode 100644
> index 0000000..b68623b
> --- /dev/null
> +++ b/xen/arch/arm/acpi/lib.c
> @@ -0,0 +1,33 @@
> +/*
> + *  lib.c - Architecture-Specific Low-Level ACPI Support
> + *
> + *  Copyright (C) 2015, Shannon Zhao <shannon.zhao@linaro.org>
> + *
> + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License as published by
> + *  the Free Software Foundation; either version 2 of the License, or
> + *  (at your option) any later version.
> + *
> + *  This program is distributed in the hope that it will be useful,
> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + *  GNU General Public License for more details.
> + *
> + *  You should have received a copy of the GNU General Public License
> + *  along with this program; if not, write to the Free Software
> + *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
> + *
> + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> + */
> +
> +#include <xen/acpi.h>
> +#include <xen/mm.h>
> +#include <asm/mm.h>
> +
> +void __iomem *
> +arch_acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
> +{
> +    return __va(phys);
> +}
> -- 
> 2.1.0
> 

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

* [PATCH v3 08/62] arm/acpi: Add arm specific acpi header file
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-23 11:43   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-23 11:43 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Add architecture specific definitions and calls required for acpi in new
> header file.
> 
> 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/setup.c       |  3 +++
>  xen/include/asm-arm/acpi.h | 38 ++++++++++++++++++++++++++++++++++++++
>  2 files changed, 41 insertions(+)
>  create mode 100644 xen/include/asm-arm/acpi.h
> 
> diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
> index e95759d..3b29904 100644
> --- a/xen/arch/arm/setup.c
> +++ b/xen/arch/arm/setup.c
> @@ -45,11 +45,14 @@
>  #include <asm/procinfo.h>
>  #include <asm/setup.h>
>  #include <xsm/xsm.h>
> +#include <asm/acpi.h>
>  
>  struct bootinfo __initdata bootinfo;
>  
>  struct cpuinfo_arm __read_mostly boot_cpu_data;
>  
> +bool_t __read_mostly acpi_disabled;
> +
>  #ifdef CONFIG_ARM_32
>  static unsigned long opt_xenheap_megabytes __initdata;
>  integer_param("xenheap_megabytes", opt_xenheap_megabytes);
> diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
> new file mode 100644
> index 0000000..e41e03b
> --- /dev/null
> +++ b/xen/include/asm-arm/acpi.h
> @@ -0,0 +1,38 @@
> +/*
> + *  Copyright (C) 2015, Shannon Zhao <shannon.zhao@linaro.org>
> + *
> + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License as published by
> + *  the Free Software Foundation; either version 2 of the License, or
> + *  (at your option) any later version.
> + *
> + *  This program is distributed in the hope that it will be useful,
> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + *  GNU General Public License for more details.
> + *
> + *  You should have received a copy of the GNU General Public License
> + *  along with this program; if not, write to the Free Software
> + *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
> + *
> + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> + */
> +
> +#ifndef _ASM_ARM_ACPI_H
> +#define _ASM_ARM_ACPI_H
> +
> +#include <xen/init.h>
> +
> +#define COMPILER_DEPENDENT_INT64   long long
> +#define COMPILER_DEPENDENT_UINT64  unsigned long long
> +
> +extern bool_t acpi_disabled;
> +/* Basic configuration for ACPI */
> +static inline void disable_acpi(void)
> +{
> +    acpi_disabled = 1;
> +}
> +
> +#endif /*_ASM_ARM_ACPI_H*/
> -- 
> 2.1.0
> 

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

* Re: [PATCH v3 08/62] arm/acpi: Add arm specific acpi header file
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-23 11:43   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-23 11:43 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, linux-arm-kernel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, david.vrabel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Add architecture specific definitions and calls required for acpi in new
> header file.
> 
> 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/setup.c       |  3 +++
>  xen/include/asm-arm/acpi.h | 38 ++++++++++++++++++++++++++++++++++++++
>  2 files changed, 41 insertions(+)
>  create mode 100644 xen/include/asm-arm/acpi.h
> 
> diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
> index e95759d..3b29904 100644
> --- a/xen/arch/arm/setup.c
> +++ b/xen/arch/arm/setup.c
> @@ -45,11 +45,14 @@
>  #include <asm/procinfo.h>
>  #include <asm/setup.h>
>  #include <xsm/xsm.h>
> +#include <asm/acpi.h>
>  
>  struct bootinfo __initdata bootinfo;
>  
>  struct cpuinfo_arm __read_mostly boot_cpu_data;
>  
> +bool_t __read_mostly acpi_disabled;
> +
>  #ifdef CONFIG_ARM_32
>  static unsigned long opt_xenheap_megabytes __initdata;
>  integer_param("xenheap_megabytes", opt_xenheap_megabytes);
> diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
> new file mode 100644
> index 0000000..e41e03b
> --- /dev/null
> +++ b/xen/include/asm-arm/acpi.h
> @@ -0,0 +1,38 @@
> +/*
> + *  Copyright (C) 2015, Shannon Zhao <shannon.zhao@linaro.org>
> + *
> + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License as published by
> + *  the Free Software Foundation; either version 2 of the License, or
> + *  (at your option) any later version.
> + *
> + *  This program is distributed in the hope that it will be useful,
> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + *  GNU General Public License for more details.
> + *
> + *  You should have received a copy of the GNU General Public License
> + *  along with this program; if not, write to the Free Software
> + *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
> + *
> + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> + */
> +
> +#ifndef _ASM_ARM_ACPI_H
> +#define _ASM_ARM_ACPI_H
> +
> +#include <xen/init.h>
> +
> +#define COMPILER_DEPENDENT_INT64   long long
> +#define COMPILER_DEPENDENT_UINT64  unsigned long long
> +
> +extern bool_t acpi_disabled;
> +/* Basic configuration for ACPI */
> +static inline void disable_acpi(void)
> +{
> +    acpi_disabled = 1;
> +}
> +
> +#endif /*_ASM_ARM_ACPI_H*/
> -- 
> 2.1.0
> 

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

* [Xen-devel] [PATCH v3 09/62] arm/acpi: Add basic ACPI initialization
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-23 11:52   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-23 11:52 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:

> From: Parth Dixit <parth.dixit@linaro.org>
> 
> acpi_boot_table_init() will be called in start_xen to get the RSDP and
> all the table pointers. With this patch, we can get ACPI boot-time
> tables from firmware on ARM64.

The patch looks good, only one comment below.


> 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>
> ---
>  xen/arch/arm/acpi/Makefile |  1 +
>  xen/arch/arm/acpi/boot.c   | 62 ++++++++++++++++++++++++++++++++++++++++++++++
>  xen/arch/arm/setup.c       |  4 +++
>  3 files changed, 67 insertions(+)
>  create mode 100644 xen/arch/arm/acpi/boot.c
> 
> diff --git a/xen/arch/arm/acpi/Makefile b/xen/arch/arm/acpi/Makefile
> index b5be22d..196c40a 100644
> --- a/xen/arch/arm/acpi/Makefile
> +++ b/xen/arch/arm/acpi/Makefile
> @@ -1 +1,2 @@
>  obj-y += lib.o
> +obj-y += boot.o
> diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c
> new file mode 100644
> index 0000000..ad51afc
> --- /dev/null
> +++ b/xen/arch/arm/acpi/boot.c
> @@ -0,0 +1,62 @@
> +/*
> + *  ARM Specific Low-Level ACPI Boot Support
> + *
> + *  Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
> + *  Copyright (C) 2001 Jun Nakajima <jun.nakajima@intel.com>
> + *  Copyright (C) 2014, Naresh Bhat <naresh.bhat@linaro.org>
> + *  Copyright (C) 2015, Shannon Zhao <shannon.zhao@linaro.org>
> + *
> + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License as published by
> + *  the Free Software Foundation; either version 2 of the License, or
> + *  (at your option) any later version.
> + *
> + *  This program is distributed in the hope that it will be useful,
> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + *  GNU General Public License for more details.
> + *
> + *  You should have received a copy of the GNU General Public License
> + *  along with this program; if not, write to the Free Software
> + *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
> + *
> + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> + */
> +
> +#include <xen/init.h>
> +#include <xen/acpi.h>
> +
> +#include <asm/acpi.h>
> +
> +/*
> + * acpi_boot_table_init() called from setup_arch(), always.
> + *      1. find RSDP and get its address, and then find XSDT
> + *      2. extract all tables and checksums them all
> + *
> + * return value: (currently ignored)
> + *	0: success
> + *	!0: failure
> + *
> + * We can parse ACPI boot-time tables such as FADT, MADT after
> + * this function is called.
> + */
> +int __init acpi_boot_table_init(void)
> +{
> +    int error;
> +
> +    /* If acpi_disabled, bail out */
> +    if ( acpi_disabled )
> +        return 1;
> +
> +    /* Initialize the ACPI boot-time table parser. */
> +    error = acpi_table_init();
> +    if ( error )
> +    {
> +        disable_acpi();
> +        return error;
> +    }
> +
> +    return 0;
> +}
> diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
> index 3b29904..768312f 100644
> --- a/xen/arch/arm/setup.c
> +++ b/xen/arch/arm/setup.c
> @@ -36,6 +36,7 @@
>  #include <xen/pfn.h>
>  #include <xen/vmap.h>
>  #include <xen/libfdt/libfdt.h>
> +#include <xen/acpi.h>
>  #include <asm/page.h>
>  #include <asm/current.h>
>  #include <asm/setup.h>
> @@ -753,6 +754,9 @@ void __init start_xen(unsigned long boot_phys_offset,
>  
>      setup_mm(fdt_paddr, fdt_size);
>  
> +    /* Parse the ACPI tables for possible boot-time configuration */
> +    acpi_boot_table_init();

Are you sure that you need to call acpi_boot_table_init before vm_init?


>      vm_init();
>      dt_unflatten_host_device_tree();
>  
> -- 
> 2.1.0
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel at lists.xen.org
> http://lists.xen.org/xen-devel
> 

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

* Re: [PATCH v3 09/62] arm/acpi: Add basic ACPI initialization
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-23 11:52   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-23 11:52 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, david.vrabel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:

> From: Parth Dixit <parth.dixit@linaro.org>
> 
> acpi_boot_table_init() will be called in start_xen to get the RSDP and
> all the table pointers. With this patch, we can get ACPI boot-time
> tables from firmware on ARM64.

The patch looks good, only one comment below.


> 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>
> ---
>  xen/arch/arm/acpi/Makefile |  1 +
>  xen/arch/arm/acpi/boot.c   | 62 ++++++++++++++++++++++++++++++++++++++++++++++
>  xen/arch/arm/setup.c       |  4 +++
>  3 files changed, 67 insertions(+)
>  create mode 100644 xen/arch/arm/acpi/boot.c
> 
> diff --git a/xen/arch/arm/acpi/Makefile b/xen/arch/arm/acpi/Makefile
> index b5be22d..196c40a 100644
> --- a/xen/arch/arm/acpi/Makefile
> +++ b/xen/arch/arm/acpi/Makefile
> @@ -1 +1,2 @@
>  obj-y += lib.o
> +obj-y += boot.o
> diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c
> new file mode 100644
> index 0000000..ad51afc
> --- /dev/null
> +++ b/xen/arch/arm/acpi/boot.c
> @@ -0,0 +1,62 @@
> +/*
> + *  ARM Specific Low-Level ACPI Boot Support
> + *
> + *  Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
> + *  Copyright (C) 2001 Jun Nakajima <jun.nakajima@intel.com>
> + *  Copyright (C) 2014, Naresh Bhat <naresh.bhat@linaro.org>
> + *  Copyright (C) 2015, Shannon Zhao <shannon.zhao@linaro.org>
> + *
> + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> + *
> + *  This program is free software; you can redistribute it and/or modify
> + *  it under the terms of the GNU General Public License as published by
> + *  the Free Software Foundation; either version 2 of the License, or
> + *  (at your option) any later version.
> + *
> + *  This program is distributed in the hope that it will be useful,
> + *  but WITHOUT ANY WARRANTY; without even the implied warranty of
> + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + *  GNU General Public License for more details.
> + *
> + *  You should have received a copy of the GNU General Public License
> + *  along with this program; if not, write to the Free Software
> + *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
> + *
> + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> + */
> +
> +#include <xen/init.h>
> +#include <xen/acpi.h>
> +
> +#include <asm/acpi.h>
> +
> +/*
> + * acpi_boot_table_init() called from setup_arch(), always.
> + *      1. find RSDP and get its address, and then find XSDT
> + *      2. extract all tables and checksums them all
> + *
> + * return value: (currently ignored)
> + *	0: success
> + *	!0: failure
> + *
> + * We can parse ACPI boot-time tables such as FADT, MADT after
> + * this function is called.
> + */
> +int __init acpi_boot_table_init(void)
> +{
> +    int error;
> +
> +    /* If acpi_disabled, bail out */
> +    if ( acpi_disabled )
> +        return 1;
> +
> +    /* Initialize the ACPI boot-time table parser. */
> +    error = acpi_table_init();
> +    if ( error )
> +    {
> +        disable_acpi();
> +        return error;
> +    }
> +
> +    return 0;
> +}
> diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
> index 3b29904..768312f 100644
> --- a/xen/arch/arm/setup.c
> +++ b/xen/arch/arm/setup.c
> @@ -36,6 +36,7 @@
>  #include <xen/pfn.h>
>  #include <xen/vmap.h>
>  #include <xen/libfdt/libfdt.h>
> +#include <xen/acpi.h>
>  #include <asm/page.h>
>  #include <asm/current.h>
>  #include <asm/setup.h>
> @@ -753,6 +754,9 @@ void __init start_xen(unsigned long boot_phys_offset,
>  
>      setup_mm(fdt_paddr, fdt_size);
>  
> +    /* Parse the ACPI tables for possible boot-time configuration */
> +    acpi_boot_table_init();

Are you sure that you need to call acpi_boot_table_init before vm_init?


>      vm_init();
>      dt_unflatten_host_device_tree();
>  
> -- 
> 2.1.0
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
> 

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

* [PATCH v3 10/62] arm/acpi: Move end_boot_allocator after acpi_boot_table_init
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-23 11:54   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-23 11:54 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> If ACPI is initialized after the boot allocator has ended(the system
> state is not early boot), assert happens in acpi_os_zalloc_memory and
> acpi_boot_table_init will fail. So it needs to move end_boot_allocator
> after acpi_boot_table_init.
> 
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

This is the reason why you are calling acpi_boot_table_init before
vm_init, correct?


>  xen/arch/arm/setup.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
> index 768312f..c15a09d 100644
> --- a/xen/arch/arm/setup.c
> +++ b/xen/arch/arm/setup.c
> @@ -613,8 +613,6 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size)
>         allocator. */
>      init_xenheap_pages(pfn_to_paddr(xenheap_mfn_start),
>                         pfn_to_paddr(boot_mfn_start));
> -
> -    end_boot_allocator();
>  }
>  #else /* CONFIG_ARM_64 */
>  static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size)
> @@ -682,8 +680,6 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size)
>  
>      setup_frametable_mappings(ram_start, ram_end);
>      max_page = PFN_DOWN(ram_end);
> -
> -    end_boot_allocator();
>  }
>  #endif
>  
> @@ -757,6 +753,8 @@ void __init start_xen(unsigned long boot_phys_offset,
>      /* Parse the ACPI tables for possible boot-time configuration */
>      acpi_boot_table_init();
>  
> +    end_boot_allocator();
> +
>      vm_init();
>      dt_unflatten_host_device_tree();
>  
> -- 
> 2.1.0
> 

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

* Re: [PATCH v3 10/62] arm/acpi: Move end_boot_allocator after acpi_boot_table_init
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-23 11:54   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-23 11:54 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, linux-arm-kernel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, david.vrabel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> If ACPI is initialized after the boot allocator has ended(the system
> state is not early boot), assert happens in acpi_os_zalloc_memory and
> acpi_boot_table_init will fail. So it needs to move end_boot_allocator
> after acpi_boot_table_init.
> 
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

This is the reason why you are calling acpi_boot_table_init before
vm_init, correct?


>  xen/arch/arm/setup.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
> index 768312f..c15a09d 100644
> --- a/xen/arch/arm/setup.c
> +++ b/xen/arch/arm/setup.c
> @@ -613,8 +613,6 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size)
>         allocator. */
>      init_xenheap_pages(pfn_to_paddr(xenheap_mfn_start),
>                         pfn_to_paddr(boot_mfn_start));
> -
> -    end_boot_allocator();
>  }
>  #else /* CONFIG_ARM_64 */
>  static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size)
> @@ -682,8 +680,6 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size)
>  
>      setup_frametable_mappings(ram_start, ram_end);
>      max_page = PFN_DOWN(ram_end);
> -
> -    end_boot_allocator();
>  }
>  #endif
>  
> @@ -757,6 +753,8 @@ void __init start_xen(unsigned long boot_phys_offset,
>      /* Parse the ACPI tables for possible boot-time configuration */
>      acpi_boot_table_init();
>  
> +    end_boot_allocator();
> +
>      vm_init();
>      dt_unflatten_host_device_tree();
>  
> -- 
> 2.1.0
> 

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

* [PATCH v3 11/62] arm/acpi: Introduce ARM Boot Architecture Flags in FADT
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-23 12:13   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-23 12:13 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> The Power State Coordination Interface (PSCI) defines an API that
> can be used to coordinate power control amongst the various supervisory
> systems concurrently running on a device. ACPI support for this
> technology would require the addition of two flags: PSCI_COMPLIANT and
> PSCI_USE_HVC. When set, the former signals to the OS that the hardware
> is PSCI compliant. The latter selects the appropriate conduit for PSCI
> calls by toggling between Hypervisor Calls (HVC) and Secure Monitor
> Calls (SMC).
> 
> An ARM Boot Architecture Flags structure to support new ARM hardware
> was introduced in FADT in ACPI 5.1, add the code accordingly to
> implement that in ACPICA core.
> 
> Since ACPI 5.1 doesn't support self defined PSCI function IDs,
> which means that only PSCI 0.2+ is supported in ACPI.
> 
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> Signed-off-by: Naresh Bhat <naresh.bhat@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

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


>  xen/include/acpi/actbl.h | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/xen/include/acpi/actbl.h b/xen/include/acpi/actbl.h
> index 856945d..66e29c3 100644
> --- a/xen/include/acpi/actbl.h
> +++ b/xen/include/acpi/actbl.h
> @@ -244,7 +244,8 @@ struct acpi_table_fadt {
>  	u32 flags;		/* Miscellaneous flag bits (see below for individual flags) */
>  	struct acpi_generic_address reset_register;	/* 64-bit address of the Reset register */
>  	u8 reset_value;		/* Value to write to the reset_register port to reset the system */
> -	u8 reserved4[3];	/* Reserved, must be zero */
> +	u16 arm_boot_flags;     /* ARM-Specific Boot Flags (see below for individual flags) (ACPI 5.1) */
> +	u8 minor_revision;      /* FADT Minor Revision (ACPI 5.1) */
>  	u64 Xfacs;		/* 64-bit physical address of FACS */
>  	u64 Xdsdt;		/* 64-bit physical address of DSDT */
>  	struct acpi_generic_address xpm1a_event_block;	/* 64-bit Extended Power Mgt 1a Event Reg Blk address */
> @@ -259,7 +260,7 @@ struct acpi_table_fadt {
>  	struct acpi_generic_address sleep_status;	/* 64-bit Sleep Status register */
>  };
>  
> -/* Masks for FADT Boot Architecture Flags (boot_flags) */
> +/* Masks for FADT IA-PC Boot Architecture Flags (boot_flags) */
>  
>  #define ACPI_FADT_LEGACY_DEVICES    (1)  	/* 00: [V2] System has LPC or ISA bus devices */
>  #define ACPI_FADT_8042              (1<<1)	/* 01: [V3] System has an 8042 controller on port 60/64 */
> @@ -270,6 +271,11 @@ struct acpi_table_fadt {
>  
>  #define FADT2_REVISION_ID               3
>  
> +/* Masks for FADT ARM Boot Architecture Flags (arm_boot_flags) ACPI 5.1 */
> +
> +#define ACPI_FADT_PSCI_COMPLIANT    (1)        /* 00:  [V5+] PSCI 0.2+ is implemented */
> +#define ACPI_FADT_PSCI_USE_HVC      (1<<1)     /* 01:  [V5+] HVC must be used instead of SMC as the PSCI conduit */
> +
>  /* Masks for FADT flags */
>  
>  #define ACPI_FADT_WBINVD            (1)	/* 00: [V1] The wbinvd instruction works properly */
> @@ -345,7 +351,7 @@ enum acpi_prefered_pm_profiles {
>   *     FADT V5  size: 0x10C
>   */
>  #define ACPI_FADT_V1_SIZE       (u32) (ACPI_FADT_OFFSET (flags) + 4)
> -#define ACPI_FADT_V2_SIZE       (u32) (ACPI_FADT_OFFSET (reserved4[0]) + 3)
> +#define ACPI_FADT_V2_SIZE       (u32) (ACPI_FADT_OFFSET (minor_revision) + 1)
>  #define ACPI_FADT_V3_SIZE       (u32) (ACPI_FADT_OFFSET (sleep_control))
>  #define ACPI_FADT_V5_SIZE       (u32) (sizeof (struct acpi_table_fadt))
>  
> -- 
> 2.1.0
> 

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

* Re: [PATCH v3 11/62] arm/acpi: Introduce ARM Boot Architecture Flags in FADT
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-23 12:13   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-23 12:13 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, linux-arm-kernel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, david.vrabel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> The Power State Coordination Interface (PSCI) defines an API that
> can be used to coordinate power control amongst the various supervisory
> systems concurrently running on a device. ACPI support for this
> technology would require the addition of two flags: PSCI_COMPLIANT and
> PSCI_USE_HVC. When set, the former signals to the OS that the hardware
> is PSCI compliant. The latter selects the appropriate conduit for PSCI
> calls by toggling between Hypervisor Calls (HVC) and Secure Monitor
> Calls (SMC).
> 
> An ARM Boot Architecture Flags structure to support new ARM hardware
> was introduced in FADT in ACPI 5.1, add the code accordingly to
> implement that in ACPICA core.
> 
> Since ACPI 5.1 doesn't support self defined PSCI function IDs,
> which means that only PSCI 0.2+ is supported in ACPI.
> 
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> Signed-off-by: Naresh Bhat <naresh.bhat@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

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


>  xen/include/acpi/actbl.h | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/xen/include/acpi/actbl.h b/xen/include/acpi/actbl.h
> index 856945d..66e29c3 100644
> --- a/xen/include/acpi/actbl.h
> +++ b/xen/include/acpi/actbl.h
> @@ -244,7 +244,8 @@ struct acpi_table_fadt {
>  	u32 flags;		/* Miscellaneous flag bits (see below for individual flags) */
>  	struct acpi_generic_address reset_register;	/* 64-bit address of the Reset register */
>  	u8 reset_value;		/* Value to write to the reset_register port to reset the system */
> -	u8 reserved4[3];	/* Reserved, must be zero */
> +	u16 arm_boot_flags;     /* ARM-Specific Boot Flags (see below for individual flags) (ACPI 5.1) */
> +	u8 minor_revision;      /* FADT Minor Revision (ACPI 5.1) */
>  	u64 Xfacs;		/* 64-bit physical address of FACS */
>  	u64 Xdsdt;		/* 64-bit physical address of DSDT */
>  	struct acpi_generic_address xpm1a_event_block;	/* 64-bit Extended Power Mgt 1a Event Reg Blk address */
> @@ -259,7 +260,7 @@ struct acpi_table_fadt {
>  	struct acpi_generic_address sleep_status;	/* 64-bit Sleep Status register */
>  };
>  
> -/* Masks for FADT Boot Architecture Flags (boot_flags) */
> +/* Masks for FADT IA-PC Boot Architecture Flags (boot_flags) */
>  
>  #define ACPI_FADT_LEGACY_DEVICES    (1)  	/* 00: [V2] System has LPC or ISA bus devices */
>  #define ACPI_FADT_8042              (1<<1)	/* 01: [V3] System has an 8042 controller on port 60/64 */
> @@ -270,6 +271,11 @@ struct acpi_table_fadt {
>  
>  #define FADT2_REVISION_ID               3
>  
> +/* Masks for FADT ARM Boot Architecture Flags (arm_boot_flags) ACPI 5.1 */
> +
> +#define ACPI_FADT_PSCI_COMPLIANT    (1)        /* 00:  [V5+] PSCI 0.2+ is implemented */
> +#define ACPI_FADT_PSCI_USE_HVC      (1<<1)     /* 01:  [V5+] HVC must be used instead of SMC as the PSCI conduit */
> +
>  /* Masks for FADT flags */
>  
>  #define ACPI_FADT_WBINVD            (1)	/* 00: [V1] The wbinvd instruction works properly */
> @@ -345,7 +351,7 @@ enum acpi_prefered_pm_profiles {
>   *     FADT V5  size: 0x10C
>   */
>  #define ACPI_FADT_V1_SIZE       (u32) (ACPI_FADT_OFFSET (flags) + 4)
> -#define ACPI_FADT_V2_SIZE       (u32) (ACPI_FADT_OFFSET (reserved4[0]) + 3)
> +#define ACPI_FADT_V2_SIZE       (u32) (ACPI_FADT_OFFSET (minor_revision) + 1)
>  #define ACPI_FADT_V3_SIZE       (u32) (ACPI_FADT_OFFSET (sleep_control))
>  #define ACPI_FADT_V5_SIZE       (u32) (sizeof (struct acpi_table_fadt))
>  
> -- 
> 2.1.0
> 

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

* [PATCH v3 12/62] ACPICA: ACPI 6.0: Add changes for FADT table
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-23 12:15   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-23 12:15 UTC (permalink / raw)
  To: linux-arm-kernel



On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:

> From: Bob Moore <robert.moore@intel.com>
> 
> ACPICA commit 72b0b6741990f619f6aaa915302836b7cbb41ac4
> 
> One new 64-bit field at the end of the table.
> FADT version is now 6.
> 
> Link: https://github.com/acpica/acpica/commit/72b0b674
> Signed-off-by: Bob Moore <robert.moore@intel.com>
> Signed-off-by: Lv Zheng <lv.zheng@intel.com>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> [Linux commit aeb823bbacc2a3aaee29eda5875b58a049fa1f78]
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

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


>  xen/include/acpi/actbl.h | 17 ++++++++++-------
>  1 file changed, 10 insertions(+), 7 deletions(-)
> 
> diff --git a/xen/include/acpi/actbl.h b/xen/include/acpi/actbl.h
> index 66e29c3..3079176 100644
> --- a/xen/include/acpi/actbl.h
> +++ b/xen/include/acpi/actbl.h
> @@ -258,6 +258,7 @@ struct acpi_table_fadt {
>  	struct acpi_generic_address xgpe1_block;	/* 64-bit Extended General Purpose Event 1 Reg Blk address */
>  	struct acpi_generic_address sleep_control;	/* 64-bit Sleep Control register */
>  	struct acpi_generic_address sleep_status;	/* 64-bit Sleep Status register */
> +	u64 hypervisor_id;      /* Hypervisor Vendor ID (ACPI 6.0) */
>  };
>  
>  /* Masks for FADT IA-PC Boot Architecture Flags (boot_flags) */
> @@ -315,7 +316,7 @@ enum acpi_prefered_pm_profiles {
>  	PM_TABLET = 8
>  };
>  
> -/* Values for sleep_status and sleep_control registers (V5 FADT) */
> +/* Values for sleep_status and sleep_control registers (V5+ FADT) */
>  
>  #define ACPI_X_WAKE_STATUS          0x80
>  #define ACPI_X_SLEEP_TYPE_MASK      0x1C
> @@ -344,15 +345,17 @@ enum acpi_prefered_pm_profiles {
>   * FADT is the bottom line as to what the version really is.
>   *
>   * For reference, the values below are as follows:
> - *     FADT V1  size: 0x074
> - *     FADT V2  size: 0x084
> - *     FADT V3  size: 0x0F4
> - *     FADT V4  size: 0x0F4
> - *     FADT V5  size: 0x10C
> + *     FADT V1 size: 0x074
> + *     FADT V2 size: 0x084
> + *     FADT V3 size: 0x0F4
> + *     FADT V4 size: 0x0F4
> + *     FADT V5 size: 0x10C
> + *     FADT V6 size: 0x114
>   */
>  #define ACPI_FADT_V1_SIZE       (u32) (ACPI_FADT_OFFSET (flags) + 4)
>  #define ACPI_FADT_V2_SIZE       (u32) (ACPI_FADT_OFFSET (minor_revision) + 1)
>  #define ACPI_FADT_V3_SIZE       (u32) (ACPI_FADT_OFFSET (sleep_control))
> -#define ACPI_FADT_V5_SIZE       (u32) (sizeof (struct acpi_table_fadt))
> +#define ACPI_FADT_V5_SIZE       (u32) (ACPI_FADT_OFFSET (hypervisor_id))
> +#define ACPI_FADT_V6_SIZE       (u32) (sizeof (struct acpi_table_fadt))
>  
>  #endif				/* __ACTBL_H__ */
> -- 
> 2.1.0
> 

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

* Re: [PATCH v3 12/62] ACPICA: ACPI 6.0: Add changes for FADT table
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-23 12:15   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-23 12:15 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, linux-arm-kernel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, david.vrabel



On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:

> From: Bob Moore <robert.moore@intel.com>
> 
> ACPICA commit 72b0b6741990f619f6aaa915302836b7cbb41ac4
> 
> One new 64-bit field at the end of the table.
> FADT version is now 6.
> 
> Link: https://github.com/acpica/acpica/commit/72b0b674
> Signed-off-by: Bob Moore <robert.moore@intel.com>
> Signed-off-by: Lv Zheng <lv.zheng@intel.com>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> [Linux commit aeb823bbacc2a3aaee29eda5875b58a049fa1f78]
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

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


>  xen/include/acpi/actbl.h | 17 ++++++++++-------
>  1 file changed, 10 insertions(+), 7 deletions(-)
> 
> diff --git a/xen/include/acpi/actbl.h b/xen/include/acpi/actbl.h
> index 66e29c3..3079176 100644
> --- a/xen/include/acpi/actbl.h
> +++ b/xen/include/acpi/actbl.h
> @@ -258,6 +258,7 @@ struct acpi_table_fadt {
>  	struct acpi_generic_address xgpe1_block;	/* 64-bit Extended General Purpose Event 1 Reg Blk address */
>  	struct acpi_generic_address sleep_control;	/* 64-bit Sleep Control register */
>  	struct acpi_generic_address sleep_status;	/* 64-bit Sleep Status register */
> +	u64 hypervisor_id;      /* Hypervisor Vendor ID (ACPI 6.0) */
>  };
>  
>  /* Masks for FADT IA-PC Boot Architecture Flags (boot_flags) */
> @@ -315,7 +316,7 @@ enum acpi_prefered_pm_profiles {
>  	PM_TABLET = 8
>  };
>  
> -/* Values for sleep_status and sleep_control registers (V5 FADT) */
> +/* Values for sleep_status and sleep_control registers (V5+ FADT) */
>  
>  #define ACPI_X_WAKE_STATUS          0x80
>  #define ACPI_X_SLEEP_TYPE_MASK      0x1C
> @@ -344,15 +345,17 @@ enum acpi_prefered_pm_profiles {
>   * FADT is the bottom line as to what the version really is.
>   *
>   * For reference, the values below are as follows:
> - *     FADT V1  size: 0x074
> - *     FADT V2  size: 0x084
> - *     FADT V3  size: 0x0F4
> - *     FADT V4  size: 0x0F4
> - *     FADT V5  size: 0x10C
> + *     FADT V1 size: 0x074
> + *     FADT V2 size: 0x084
> + *     FADT V3 size: 0x0F4
> + *     FADT V4 size: 0x0F4
> + *     FADT V5 size: 0x10C
> + *     FADT V6 size: 0x114
>   */
>  #define ACPI_FADT_V1_SIZE       (u32) (ACPI_FADT_OFFSET (flags) + 4)
>  #define ACPI_FADT_V2_SIZE       (u32) (ACPI_FADT_OFFSET (minor_revision) + 1)
>  #define ACPI_FADT_V3_SIZE       (u32) (ACPI_FADT_OFFSET (sleep_control))
> -#define ACPI_FADT_V5_SIZE       (u32) (sizeof (struct acpi_table_fadt))
> +#define ACPI_FADT_V5_SIZE       (u32) (ACPI_FADT_OFFSET (hypervisor_id))
> +#define ACPI_FADT_V6_SIZE       (u32) (sizeof (struct acpi_table_fadt))
>  
>  #endif				/* __ACTBL_H__ */
> -- 
> 2.1.0
> 

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

* [PATCH v3 13/62] arm/acpi: Parse FADT table and get PSCI flags
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-23 12:42   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-23 12:42 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> There are two flags: PSCI_COMPLIANT and PSCI_USE_HVC. When set,
> the former signals to the OS that the hardware is PSCI compliant.
> The latter selects the appropriate conduit for PSCI calls by
> toggling between Hypervisor Calls (HVC) and Secure Monitor Calls
> (SMC).
> 
> FADT table contains such information, parse FADT to get the flags
> for furture usage. At the same time, only ACPI 5.1 or higher verison
> supports PSCI, and FADT Major.Minor version was introduced in ACPI
> 5.1, but for Xen it needs FADT hypervisor_id introduced by ACPI 6.0 to
> tell Dom0 that it runs on Xen hypervisor, so we will check the version
> and only parse FADT table with version >= 6.0.
> 
> If firmware provides ACPI tables with ACPI version less than 6.0,
> OS will be messed up with those information, so disable ACPI if we
> get an FADT table with version less that 6.0.
> 
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> 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>
> ---
>  xen/arch/arm/acpi/boot.c   | 31 +++++++++++++++++++++++++++++++
>  xen/arch/arm/acpi/lib.c    | 12 ++++++++++++
>  xen/include/asm-arm/acpi.h |  9 +++++++++
>  3 files changed, 52 insertions(+)
> 
> diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c
> index ad51afc..0fabe7d 100644
> --- a/xen/arch/arm/acpi/boot.c
> +++ b/xen/arch/arm/acpi/boot.c
> @@ -27,9 +27,33 @@
>  
>  #include <xen/init.h>
>  #include <xen/acpi.h>
> +#include <xen/errno.h>
> +#include <acpi/actables.h>
> +#include <xen/mm.h>
>  
>  #include <asm/acpi.h>
>  
> +static int __init acpi_parse_fadt(struct acpi_table_header *table)
> +{
> +    struct acpi_table_fadt *fadt = (struct acpi_table_fadt *)table;
> +
> +    /*
> +     * Revision in table header is the FADT Major revision, and there
> +     * is a minor revision of FADT which was introduced by ACPI 6.0,
> +     * we only deal with ACPI 6.0 or newer revision to get GIC and SMP
> +     * boot protocol configuration data, or we will disable ACPI.
> +     */
> +    if ( table->revision > 6
> +         || (table->revision == 6 && fadt->minor_revision >= 0) )
> +        return 0;
> +
> +    printk("Unsupported FADT revision %d.%d, should be 6.0+, will disable ACPI\n",
> +            table->revision, fadt->minor_revision);
> +    disable_acpi();

This call to disable_acpi is redundant, given the other call below


> +    return -EINVAL;
> +}
> +
>  /*
>   * acpi_boot_table_init() called from setup_arch(), always.
>   *      1. find RSDP and get its address, and then find XSDT
> @@ -58,5 +82,12 @@ int __init acpi_boot_table_init(void)
>          return error;
>      }
>  
> +    if ( acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt) )
> +    {
> +        /* disable ACPI if no FADT is found */
> +        disable_acpi();
> +        printk("Can't find FADT\n");
> +    }
> +
>      return 0;
>  }
> diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c
> index b68623b..d8b7635 100644
> --- a/xen/arch/arm/acpi/lib.c
> +++ b/xen/arch/arm/acpi/lib.c
> @@ -31,3 +31,15 @@ arch_acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
>  {
>      return __va(phys);
>  }
> +
> +/* 1 to indicate PSCI 0.2+ is implemented */
> +bool_t __init acpi_psci_present(void)
> +{
> +    return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_COMPLIANT;
> +}
> +
> +/* 1 to indicate HVC is present instead of SMC as the PSCI conduit */
> +bool_t __init acpi_psci_hvc_present(void)
> +{
> +    return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_USE_HVC;
> +}
> diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
> index e41e03b..65f80b1 100644
> --- a/xen/include/asm-arm/acpi.h
> +++ b/xen/include/asm-arm/acpi.h
> @@ -29,6 +29,15 @@
>  #define COMPILER_DEPENDENT_UINT64  unsigned long long
>  
>  extern bool_t acpi_disabled;
> +
> +#ifdef CONFIG_ACPI
> +bool_t __init acpi_psci_present(void);
> +bool_t __init acpi_psci_hvc_present(void);
> +#else
> +static inline bool_t acpi_psci_present(void) { return false; }
> +static inline bool_t acpi_psci_hvc_present(void) {return false; }
> +#endif /* CONFIG_ACPI */

It doesn't look like this is necessary on x86, acpi_gbl_FADT is used in
a few places, including xen/arch/x86/time.c, without checking for
CONFIG_ACPI or HAS_ACPI. Is the x86 code wrong?


>  /* Basic configuration for ACPI */
>  static inline void disable_acpi(void)
>  {
> -- 
> 2.1.0
> 

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

* Re: [PATCH v3 13/62] arm/acpi: Parse FADT table and get PSCI flags
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-23 12:42   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-23 12:42 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, linux-arm-kernel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, david.vrabel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> There are two flags: PSCI_COMPLIANT and PSCI_USE_HVC. When set,
> the former signals to the OS that the hardware is PSCI compliant.
> The latter selects the appropriate conduit for PSCI calls by
> toggling between Hypervisor Calls (HVC) and Secure Monitor Calls
> (SMC).
> 
> FADT table contains such information, parse FADT to get the flags
> for furture usage. At the same time, only ACPI 5.1 or higher verison
> supports PSCI, and FADT Major.Minor version was introduced in ACPI
> 5.1, but for Xen it needs FADT hypervisor_id introduced by ACPI 6.0 to
> tell Dom0 that it runs on Xen hypervisor, so we will check the version
> and only parse FADT table with version >= 6.0.
> 
> If firmware provides ACPI tables with ACPI version less than 6.0,
> OS will be messed up with those information, so disable ACPI if we
> get an FADT table with version less that 6.0.
> 
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> 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>
> ---
>  xen/arch/arm/acpi/boot.c   | 31 +++++++++++++++++++++++++++++++
>  xen/arch/arm/acpi/lib.c    | 12 ++++++++++++
>  xen/include/asm-arm/acpi.h |  9 +++++++++
>  3 files changed, 52 insertions(+)
> 
> diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c
> index ad51afc..0fabe7d 100644
> --- a/xen/arch/arm/acpi/boot.c
> +++ b/xen/arch/arm/acpi/boot.c
> @@ -27,9 +27,33 @@
>  
>  #include <xen/init.h>
>  #include <xen/acpi.h>
> +#include <xen/errno.h>
> +#include <acpi/actables.h>
> +#include <xen/mm.h>
>  
>  #include <asm/acpi.h>
>  
> +static int __init acpi_parse_fadt(struct acpi_table_header *table)
> +{
> +    struct acpi_table_fadt *fadt = (struct acpi_table_fadt *)table;
> +
> +    /*
> +     * Revision in table header is the FADT Major revision, and there
> +     * is a minor revision of FADT which was introduced by ACPI 6.0,
> +     * we only deal with ACPI 6.0 or newer revision to get GIC and SMP
> +     * boot protocol configuration data, or we will disable ACPI.
> +     */
> +    if ( table->revision > 6
> +         || (table->revision == 6 && fadt->minor_revision >= 0) )
> +        return 0;
> +
> +    printk("Unsupported FADT revision %d.%d, should be 6.0+, will disable ACPI\n",
> +            table->revision, fadt->minor_revision);
> +    disable_acpi();

This call to disable_acpi is redundant, given the other call below


> +    return -EINVAL;
> +}
> +
>  /*
>   * acpi_boot_table_init() called from setup_arch(), always.
>   *      1. find RSDP and get its address, and then find XSDT
> @@ -58,5 +82,12 @@ int __init acpi_boot_table_init(void)
>          return error;
>      }
>  
> +    if ( acpi_table_parse(ACPI_SIG_FADT, acpi_parse_fadt) )
> +    {
> +        /* disable ACPI if no FADT is found */
> +        disable_acpi();
> +        printk("Can't find FADT\n");
> +    }
> +
>      return 0;
>  }
> diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c
> index b68623b..d8b7635 100644
> --- a/xen/arch/arm/acpi/lib.c
> +++ b/xen/arch/arm/acpi/lib.c
> @@ -31,3 +31,15 @@ arch_acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
>  {
>      return __va(phys);
>  }
> +
> +/* 1 to indicate PSCI 0.2+ is implemented */
> +bool_t __init acpi_psci_present(void)
> +{
> +    return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_COMPLIANT;
> +}
> +
> +/* 1 to indicate HVC is present instead of SMC as the PSCI conduit */
> +bool_t __init acpi_psci_hvc_present(void)
> +{
> +    return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_USE_HVC;
> +}
> diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
> index e41e03b..65f80b1 100644
> --- a/xen/include/asm-arm/acpi.h
> +++ b/xen/include/asm-arm/acpi.h
> @@ -29,6 +29,15 @@
>  #define COMPILER_DEPENDENT_UINT64  unsigned long long
>  
>  extern bool_t acpi_disabled;
> +
> +#ifdef CONFIG_ACPI
> +bool_t __init acpi_psci_present(void);
> +bool_t __init acpi_psci_hvc_present(void);
> +#else
> +static inline bool_t acpi_psci_present(void) { return false; }
> +static inline bool_t acpi_psci_hvc_present(void) {return false; }
> +#endif /* CONFIG_ACPI */

It doesn't look like this is necessary on x86, acpi_gbl_FADT is used in
a few places, including xen/arch/x86/time.c, without checking for
CONFIG_ACPI or HAS_ACPI. Is the x86 code wrong?


>  /* Basic configuration for ACPI */
>  static inline void disable_acpi(void)
>  {
> -- 
> 2.1.0
> 

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

* [PATCH v3 14/62] arm/acpi: Add Generic Interrupt and Distributor struct
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-23 14:43   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-23 14:43 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Add Generic Interrupt and Distributor (ACPI 5.0) structure.
> Add new features for MADT introduced by ACPI 5.1.
> Comment on the GIC ID field of the GIC structure which is replaced
> by CPU Interface Number.
> Add new fields: Redistributor Base Address, GICV, GICH, and MPIDR.
> Add new structures for GIC MSI frame and GICR.
> Add flag definition for GICC flags.
> 
> Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> Signed-off-by: Naresh Bhat <naresh.bhat@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

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

Would it make sense to add the changes for ACPI 6.0 compatibility too?


>  xen/include/acpi/actbl1.h | 69 +++++++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 67 insertions(+), 2 deletions(-)
> 
> diff --git a/xen/include/acpi/actbl1.h b/xen/include/acpi/actbl1.h
> index 9311e3a..2fb2ad7 100644
> --- a/xen/include/acpi/actbl1.h
> +++ b/xen/include/acpi/actbl1.h
> @@ -639,7 +639,11 @@ enum acpi_madt_type {
>  	ACPI_MADT_TYPE_INTERRUPT_SOURCE = 8,
>  	ACPI_MADT_TYPE_LOCAL_X2APIC = 9,
>  	ACPI_MADT_TYPE_LOCAL_X2APIC_NMI = 10,
> -	ACPI_MADT_TYPE_RESERVED = 11	/* 11 and greater are reserved */
> +	ACPI_MADT_TYPE_GENERIC_INTERRUPT = 11,
> +	ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR = 12,
> +	ACPI_MADT_TYPE_GENERIC_MSI_FRAME = 13,
> +	ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR = 14,
> +	ACPI_MADT_TYPE_RESERVED = 15    /* 15 and greater are reserved */
>  };
>  
>  /*
> @@ -760,11 +764,72 @@ struct acpi_madt_local_x2apic_nmi {
>  	u8 reserved[3];
>  };
>  
> +/* 11: Generic Interrupt (ACPI 5.0) */
> +
> +struct acpi_madt_generic_interrupt {
> +	struct acpi_subtable_header header;
> +	u16 reserved;           /* reserved - must be zero */
> +	u32 cpu_interface_number;
> +	u32 uid;
> +	u32 flags;
> +	u32 parking_version;
> +	u32 performance_interrupt;
> +	u64 parked_address;
> +	u64 base_address;
> +	u64 gicv_base_address;
> +	u64 gich_base_address;
> +	u32 vgic_interrupt;
> +	u64 gicr_base_address;
> +	u64 arm_mpidr;
> +};
> +
> +/* Masks for Flags field above */
> +
> +/* ACPI_MADT_ENABLED                    (1)      Processor is usable if set */
> +#define ACPI_MADT_PERFORMANCE_IRQ_MODE  (1<<1) /* 01: Performance Interrupt Mode */
> +#define ACPI_MADT_VGIC_IRQ_MODE         (1<<2) /* 02: VGIC Maintenance Interrupt mode */
> +
> +/* 12: Generic Distributor (ACPI 5.0) */
> +
> +struct acpi_madt_generic_distributor {
> +	struct acpi_subtable_header header;
> +	u16 reserved;           /* reserved - must be zero */
> +	u32 gic_id;
> +	u64 base_address;
> +	u32 global_irq_base;
> +	u32 reserved2;          /* reserved - must be zero */
> +};
> +
> +/* 13: GIC MSI Frame (ACPI 5.1) */
> +
> +struct acpi_madt_generic_msi_frame {
> +	struct acpi_subtable_header header;
> +	u16 reserved;		/* reserved - must be zero */
> +	u32 msi_frame_id;
> +	u64 base_address;
> +	u32 flags;
> +	u16 spi_count;
> +	u16 spi_base;
> +};
> +
> +/* Masks for Flags field above */
> +
> +#define ACPI_MADT_OVERRIDE_SPI_VALUES   (1)
> +
> +/* 14: GIC Redistributor (ACPI 5.1) */
> +
> +struct acpi_madt_generic_redistributor {
> +	struct acpi_subtable_header header;
> +	u16 reserved;		/* reserved - must be zero */
> +	u64 base_address;
> +	u32 length;
> +};
> +
>  /*
>   * Common flags fields for MADT subtables
>   */
>  
> -/* MADT Local APIC flags (lapic_flags) */
> +/* MADT Local APIC flags */
>  
>  #define ACPI_MADT_ENABLED           (1)	/* 00: Processor is usable if set */
>  
> -- 
> 2.1.0
> 

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

* Re: [PATCH v3 14/62] arm/acpi: Add Generic Interrupt and Distributor struct
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-23 14:43   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-23 14:43 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, linux-arm-kernel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, david.vrabel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Add Generic Interrupt and Distributor (ACPI 5.0) structure.
> Add new features for MADT introduced by ACPI 5.1.
> Comment on the GIC ID field of the GIC structure which is replaced
> by CPU Interface Number.
> Add new fields: Redistributor Base Address, GICV, GICH, and MPIDR.
> Add new structures for GIC MSI frame and GICR.
> Add flag definition for GICC flags.
> 
> Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> Signed-off-by: Naresh Bhat <naresh.bhat@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

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

Would it make sense to add the changes for ACPI 6.0 compatibility too?


>  xen/include/acpi/actbl1.h | 69 +++++++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 67 insertions(+), 2 deletions(-)
> 
> diff --git a/xen/include/acpi/actbl1.h b/xen/include/acpi/actbl1.h
> index 9311e3a..2fb2ad7 100644
> --- a/xen/include/acpi/actbl1.h
> +++ b/xen/include/acpi/actbl1.h
> @@ -639,7 +639,11 @@ enum acpi_madt_type {
>  	ACPI_MADT_TYPE_INTERRUPT_SOURCE = 8,
>  	ACPI_MADT_TYPE_LOCAL_X2APIC = 9,
>  	ACPI_MADT_TYPE_LOCAL_X2APIC_NMI = 10,
> -	ACPI_MADT_TYPE_RESERVED = 11	/* 11 and greater are reserved */
> +	ACPI_MADT_TYPE_GENERIC_INTERRUPT = 11,
> +	ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR = 12,
> +	ACPI_MADT_TYPE_GENERIC_MSI_FRAME = 13,
> +	ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR = 14,
> +	ACPI_MADT_TYPE_RESERVED = 15    /* 15 and greater are reserved */
>  };
>  
>  /*
> @@ -760,11 +764,72 @@ struct acpi_madt_local_x2apic_nmi {
>  	u8 reserved[3];
>  };
>  
> +/* 11: Generic Interrupt (ACPI 5.0) */
> +
> +struct acpi_madt_generic_interrupt {
> +	struct acpi_subtable_header header;
> +	u16 reserved;           /* reserved - must be zero */
> +	u32 cpu_interface_number;
> +	u32 uid;
> +	u32 flags;
> +	u32 parking_version;
> +	u32 performance_interrupt;
> +	u64 parked_address;
> +	u64 base_address;
> +	u64 gicv_base_address;
> +	u64 gich_base_address;
> +	u32 vgic_interrupt;
> +	u64 gicr_base_address;
> +	u64 arm_mpidr;
> +};
> +
> +/* Masks for Flags field above */
> +
> +/* ACPI_MADT_ENABLED                    (1)      Processor is usable if set */
> +#define ACPI_MADT_PERFORMANCE_IRQ_MODE  (1<<1) /* 01: Performance Interrupt Mode */
> +#define ACPI_MADT_VGIC_IRQ_MODE         (1<<2) /* 02: VGIC Maintenance Interrupt mode */
> +
> +/* 12: Generic Distributor (ACPI 5.0) */
> +
> +struct acpi_madt_generic_distributor {
> +	struct acpi_subtable_header header;
> +	u16 reserved;           /* reserved - must be zero */
> +	u32 gic_id;
> +	u64 base_address;
> +	u32 global_irq_base;
> +	u32 reserved2;          /* reserved - must be zero */
> +};
> +
> +/* 13: GIC MSI Frame (ACPI 5.1) */
> +
> +struct acpi_madt_generic_msi_frame {
> +	struct acpi_subtable_header header;
> +	u16 reserved;		/* reserved - must be zero */
> +	u32 msi_frame_id;
> +	u64 base_address;
> +	u32 flags;
> +	u16 spi_count;
> +	u16 spi_base;
> +};
> +
> +/* Masks for Flags field above */
> +
> +#define ACPI_MADT_OVERRIDE_SPI_VALUES   (1)
> +
> +/* 14: GIC Redistributor (ACPI 5.1) */
> +
> +struct acpi_madt_generic_redistributor {
> +	struct acpi_subtable_header header;
> +	u16 reserved;		/* reserved - must be zero */
> +	u64 base_address;
> +	u32 length;
> +};
> +
>  /*
>   * Common flags fields for MADT subtables
>   */
>  
> -/* MADT Local APIC flags (lapic_flags) */
> +/* MADT Local APIC flags */
>  
>  #define ACPI_MADT_ENABLED           (1)	/* 00: Processor is usable if set */
>  
> -- 
> 2.1.0
> 

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

* [PATCH v3 15/62] ACPICA: ACPI 6.0: Add changes for MADT table.
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-23 14:51   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-23 14:51 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> From: Bob Moore <robert.moore@intel.com>
> 
> ACPICA commit 02cbb41232bccf7a91967140cab95d5f48291f21
> 
> New subtable type. Some additions to existing subtables.
> 
> Link: https://github.com/acpica/acpica/commit/02cbb412
> Signed-off-by: Bob Moore <robert.moore@intel.com>
> Signed-off-by: Lv Zheng <lv.zheng@intel.com>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> [Linux commit 0cff8dc0099f6d4f7431181918b37a472bcd1bbb]
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

These are the ACPI 6.0 changes. I am OK both with them being folded in
the previous patch or kept separate.

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


>  xen/include/acpi/actbl1.h | 22 ++++++++++++++++++----
>  1 file changed, 18 insertions(+), 4 deletions(-)
> 
> diff --git a/xen/include/acpi/actbl1.h b/xen/include/acpi/actbl1.h
> index 2fb2ad7..7dd6960 100644
> --- a/xen/include/acpi/actbl1.h
> +++ b/xen/include/acpi/actbl1.h
> @@ -643,7 +643,8 @@ enum acpi_madt_type {
>  	ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR = 12,
>  	ACPI_MADT_TYPE_GENERIC_MSI_FRAME = 13,
>  	ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR = 14,
> -	ACPI_MADT_TYPE_RESERVED = 15    /* 15 and greater are reserved */
> +	ACPI_MADT_TYPE_GENERIC_TRANSLATOR = 15,
> +	ACPI_MADT_TYPE_RESERVED = 16    /* 16 and greater are reserved */
>  };
>  
>  /*
> @@ -764,7 +765,7 @@ struct acpi_madt_local_x2apic_nmi {
>  	u8 reserved[3];
>  };
>  
> -/* 11: Generic Interrupt (ACPI 5.0) */
> +/* 11: Generic Interrupt (ACPI 5.0 + ACPI 6.0 changes) */
>  
>  struct acpi_madt_generic_interrupt {
>  	struct acpi_subtable_header header;
> @@ -781,6 +782,8 @@ struct acpi_madt_generic_interrupt {
>  	u32 vgic_interrupt;
>  	u64 gicr_base_address;
>  	u64 arm_mpidr;
> +	u8 efficiency_class;
> +	u8 reserved2[3];
>  };
>  
>  /* Masks for Flags field above */
> @@ -789,7 +792,7 @@ struct acpi_madt_generic_interrupt {
>  #define ACPI_MADT_PERFORMANCE_IRQ_MODE  (1<<1) /* 01: Performance Interrupt Mode */
>  #define ACPI_MADT_VGIC_IRQ_MODE         (1<<2) /* 02: VGIC Maintenance Interrupt mode */
>  
> -/* 12: Generic Distributor (ACPI 5.0) */
> +/* 12: Generic Distributor (ACPI 5.0 + ACPI 6.0 changes) */
>  
>  struct acpi_madt_generic_distributor {
>  	struct acpi_subtable_header header;
> @@ -797,7 +800,8 @@ struct acpi_madt_generic_distributor {
>  	u32 gic_id;
>  	u64 base_address;
>  	u32 global_irq_base;
> -	u32 reserved2;          /* reserved - must be zero */
> +	u8 version;
> +	u8 reserved2[3];          /* reserved - must be zero */
>  };
>  
>  /* 13: GIC MSI Frame (ACPI 5.1) */
> @@ -825,6 +829,16 @@ struct acpi_madt_generic_redistributor {
>  	u32 length;
>  };
>  
> +/* 15: Generic Translator (ACPI 6.0) */
> +
> +struct acpi_madt_generic_translator {
> +	struct acpi_subtable_header header;
> +	u16 reserved;           /* reserved - must be zero */
> +	u32 translation_id;
> +	u64 base_address;
> +	u32 reserved2;
> +};
> +
>  /*
>   * Common flags fields for MADT subtables
>   */
> -- 
> 2.1.0
> 

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

* Re: [PATCH v3 15/62] ACPICA: ACPI 6.0: Add changes for MADT table.
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-23 14:51   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-23 14:51 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, linux-arm-kernel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, david.vrabel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> From: Bob Moore <robert.moore@intel.com>
> 
> ACPICA commit 02cbb41232bccf7a91967140cab95d5f48291f21
> 
> New subtable type. Some additions to existing subtables.
> 
> Link: https://github.com/acpica/acpica/commit/02cbb412
> Signed-off-by: Bob Moore <robert.moore@intel.com>
> Signed-off-by: Lv Zheng <lv.zheng@intel.com>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> [Linux commit 0cff8dc0099f6d4f7431181918b37a472bcd1bbb]
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

These are the ACPI 6.0 changes. I am OK both with them being folded in
the previous patch or kept separate.

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


>  xen/include/acpi/actbl1.h | 22 ++++++++++++++++++----
>  1 file changed, 18 insertions(+), 4 deletions(-)
> 
> diff --git a/xen/include/acpi/actbl1.h b/xen/include/acpi/actbl1.h
> index 2fb2ad7..7dd6960 100644
> --- a/xen/include/acpi/actbl1.h
> +++ b/xen/include/acpi/actbl1.h
> @@ -643,7 +643,8 @@ enum acpi_madt_type {
>  	ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR = 12,
>  	ACPI_MADT_TYPE_GENERIC_MSI_FRAME = 13,
>  	ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR = 14,
> -	ACPI_MADT_TYPE_RESERVED = 15    /* 15 and greater are reserved */
> +	ACPI_MADT_TYPE_GENERIC_TRANSLATOR = 15,
> +	ACPI_MADT_TYPE_RESERVED = 16    /* 16 and greater are reserved */
>  };
>  
>  /*
> @@ -764,7 +765,7 @@ struct acpi_madt_local_x2apic_nmi {
>  	u8 reserved[3];
>  };
>  
> -/* 11: Generic Interrupt (ACPI 5.0) */
> +/* 11: Generic Interrupt (ACPI 5.0 + ACPI 6.0 changes) */
>  
>  struct acpi_madt_generic_interrupt {
>  	struct acpi_subtable_header header;
> @@ -781,6 +782,8 @@ struct acpi_madt_generic_interrupt {
>  	u32 vgic_interrupt;
>  	u64 gicr_base_address;
>  	u64 arm_mpidr;
> +	u8 efficiency_class;
> +	u8 reserved2[3];
>  };
>  
>  /* Masks for Flags field above */
> @@ -789,7 +792,7 @@ struct acpi_madt_generic_interrupt {
>  #define ACPI_MADT_PERFORMANCE_IRQ_MODE  (1<<1) /* 01: Performance Interrupt Mode */
>  #define ACPI_MADT_VGIC_IRQ_MODE         (1<<2) /* 02: VGIC Maintenance Interrupt mode */
>  
> -/* 12: Generic Distributor (ACPI 5.0) */
> +/* 12: Generic Distributor (ACPI 5.0 + ACPI 6.0 changes) */
>  
>  struct acpi_madt_generic_distributor {
>  	struct acpi_subtable_header header;
> @@ -797,7 +800,8 @@ struct acpi_madt_generic_distributor {
>  	u32 gic_id;
>  	u64 base_address;
>  	u32 global_irq_base;
> -	u32 reserved2;          /* reserved - must be zero */
> +	u8 version;
> +	u8 reserved2[3];          /* reserved - must be zero */
>  };
>  
>  /* 13: GIC MSI Frame (ACPI 5.1) */
> @@ -825,6 +829,16 @@ struct acpi_madt_generic_redistributor {
>  	u32 length;
>  };
>  
> +/* 15: Generic Translator (ACPI 6.0) */
> +
> +struct acpi_madt_generic_translator {
> +	struct acpi_subtable_header header;
> +	u16 reserved;           /* reserved - must be zero */
> +	u32 translation_id;
> +	u64 base_address;
> +	u32 reserved2;
> +};
> +
>  /*
>   * Common flags fields for MADT subtables
>   */
> -- 
> 2.1.0
> 

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

* [PATCH v3 16/62] ACPICA: ACPI 6.0: Add values for MADT GIC version field
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-23 14:52   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-23 14:52 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> From: Hanjun Guo <hanjun.guo@linaro.org>
> 
> ACPICA commit 4b100dc43e8baee8c8b4891b23bc7ad03eba6a28
> 
> Support for the new version field in the generic distributor
> subtable. Hanjun Guo <hanjun.guo@linaro.org>
> 
> Link: https://github.com/acpica/acpica/commit/4b100dc4
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> Signed-off-by: Bob Moore <robert.moore@intel.com>
> Signed-off-by: Lv Zheng <lv.zheng@intel.com>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> [Linux commit a8bd0f07eb594df51845d33f272fb1952fec1a6f]
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

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


>  xen/include/acpi/actbl1.h | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/xen/include/acpi/actbl1.h b/xen/include/acpi/actbl1.h
> index 7dd6960..cf31837 100644
> --- a/xen/include/acpi/actbl1.h
> +++ b/xen/include/acpi/actbl1.h
> @@ -804,6 +804,17 @@ struct acpi_madt_generic_distributor {
>  	u8 reserved2[3];          /* reserved - must be zero */
>  };
>  
> +/* Values for Version field above */
> +
> +enum acpi_madt_gic_version {
> +	ACPI_MADT_GIC_VERSION_NONE = 0,
> +	ACPI_MADT_GIC_VERSION_V1 = 1,
> +	ACPI_MADT_GIC_VERSION_V2 = 2,
> +	ACPI_MADT_GIC_VERSION_V3 = 3,
> +	ACPI_MADT_GIC_VERSION_V4 = 4,
> +	ACPI_MADT_GIC_VERSION_RESERVED = 5      /* 5 and greater are reserved */
> +};
> +
>  /* 13: GIC MSI Frame (ACPI 5.1) */
>  
>  struct acpi_madt_generic_msi_frame {
> -- 
> 2.1.0
> 

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

* Re: [PATCH v3 16/62] ACPICA: ACPI 6.0: Add values for MADT GIC version field
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-23 14:52   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-23 14:52 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, linux-arm-kernel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, david.vrabel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> From: Hanjun Guo <hanjun.guo@linaro.org>
> 
> ACPICA commit 4b100dc43e8baee8c8b4891b23bc7ad03eba6a28
> 
> Support for the new version field in the generic distributor
> subtable. Hanjun Guo <hanjun.guo@linaro.org>
> 
> Link: https://github.com/acpica/acpica/commit/4b100dc4
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> Signed-off-by: Bob Moore <robert.moore@intel.com>
> Signed-off-by: Lv Zheng <lv.zheng@intel.com>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> [Linux commit a8bd0f07eb594df51845d33f272fb1952fec1a6f]
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

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


>  xen/include/acpi/actbl1.h | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/xen/include/acpi/actbl1.h b/xen/include/acpi/actbl1.h
> index 7dd6960..cf31837 100644
> --- a/xen/include/acpi/actbl1.h
> +++ b/xen/include/acpi/actbl1.h
> @@ -804,6 +804,17 @@ struct acpi_madt_generic_distributor {
>  	u8 reserved2[3];          /* reserved - must be zero */
>  };
>  
> +/* Values for Version field above */
> +
> +enum acpi_madt_gic_version {
> +	ACPI_MADT_GIC_VERSION_NONE = 0,
> +	ACPI_MADT_GIC_VERSION_V1 = 1,
> +	ACPI_MADT_GIC_VERSION_V2 = 2,
> +	ACPI_MADT_GIC_VERSION_V3 = 3,
> +	ACPI_MADT_GIC_VERSION_V4 = 4,
> +	ACPI_MADT_GIC_VERSION_RESERVED = 5      /* 5 and greater are reserved */
> +};
> +
>  /* 13: GIC MSI Frame (ACPI 5.1) */
>  
>  struct acpi_madt_generic_msi_frame {
> -- 
> 2.1.0
> 

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

* [PATCH v3 17/62] arm/acpi: Print GIC information when MADT is parsed
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-23 14:56   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-23 14:56 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> From: Naresh Bhat <naresh.bhat@linaro.org>
> 
> When MADT is parsed, print GIC information to make the boot
> log look pretty.
> 
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
> Signed-off-by: Naresh Bhat <naresh.bhat@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/drivers/acpi/tables.c | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/xen/drivers/acpi/tables.c b/xen/drivers/acpi/tables.c
> index 60c4ab1..6573175 100644
> --- a/xen/drivers/acpi/tables.c
> +++ b/xen/drivers/acpi/tables.c
> @@ -189,6 +189,30 @@ void __init acpi_table_print_madt_entry(struct acpi_subtable_header *header)
>  		}
>  		break;
>  
> +	case ACPI_MADT_TYPE_GENERIC_INTERRUPT:
> +		{
> +			struct acpi_madt_generic_interrupt *p =
> +				(struct acpi_madt_generic_interrupt *)header;
> +			printk(KERN_INFO PREFIX
> +			       "GICC (acpi_id[0x%04x] address[%llx] MPIDR[0x%llx] %s)\n",
> +			       p->uid, (long long unsigned int)p->base_address,
> +			       (long long unsigned int)p->arm_mpidr,
> +			       (p->flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");

PRIx64?


> +		}
> +		break;
> +
> +	case ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR:
> +		{
> +			struct acpi_madt_generic_distributor *p =
> +				(struct acpi_madt_generic_distributor *)header;
> +			printk(KERN_INFO PREFIX
> +			       "GIC Distributor (gic_id[0x%04x] address[%llx] gsi_base[%d])\n",
> +			       p->gic_id, (long long unsigned int)p->base_address,
> +			       p->global_irq_base);

ditto


> +		}
> +		break;
> +
>  	default:
>  		printk(KERN_WARNING PREFIX
>  		       "Found unsupported MADT entry (type = %#x)\n",
> -- 
> 2.1.0
> 

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

* Re: [PATCH v3 17/62] arm/acpi: Print GIC information when MADT is parsed
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-23 14:56   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-23 14:56 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, linux-arm-kernel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, david.vrabel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> From: Naresh Bhat <naresh.bhat@linaro.org>
> 
> When MADT is parsed, print GIC information to make the boot
> log look pretty.
> 
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
> Signed-off-by: Naresh Bhat <naresh.bhat@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/drivers/acpi/tables.c | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/xen/drivers/acpi/tables.c b/xen/drivers/acpi/tables.c
> index 60c4ab1..6573175 100644
> --- a/xen/drivers/acpi/tables.c
> +++ b/xen/drivers/acpi/tables.c
> @@ -189,6 +189,30 @@ void __init acpi_table_print_madt_entry(struct acpi_subtable_header *header)
>  		}
>  		break;
>  
> +	case ACPI_MADT_TYPE_GENERIC_INTERRUPT:
> +		{
> +			struct acpi_madt_generic_interrupt *p =
> +				(struct acpi_madt_generic_interrupt *)header;
> +			printk(KERN_INFO PREFIX
> +			       "GICC (acpi_id[0x%04x] address[%llx] MPIDR[0x%llx] %s)\n",
> +			       p->uid, (long long unsigned int)p->base_address,
> +			       (long long unsigned int)p->arm_mpidr,
> +			       (p->flags & ACPI_MADT_ENABLED) ? "enabled" : "disabled");

PRIx64?


> +		}
> +		break;
> +
> +	case ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR:
> +		{
> +			struct acpi_madt_generic_distributor *p =
> +				(struct acpi_madt_generic_distributor *)header;
> +			printk(KERN_INFO PREFIX
> +			       "GIC Distributor (gic_id[0x%04x] address[%llx] gsi_base[%d])\n",
> +			       p->gic_id, (long long unsigned int)p->base_address,
> +			       p->global_irq_base);

ditto


> +		}
> +		break;
> +
>  	default:
>  		printk(KERN_WARNING PREFIX
>  		       "Found unsupported MADT entry (type = %#x)\n",
> -- 
> 2.1.0
> 

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

* [PATCH v3 18/62] arm/acpi: Parse MADT to map logical cpu to MPIDR and get cpu_possible_map
  2015-11-17  9:40   ` shannon.zhao
@ 2015-11-23 15:18     ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-23 15:18 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> From: Parth Dixit <parth.dixit@linaro.org>
> 
> MADT contains the information for MPIDR which is essential for SMP
> initialization, parse the GIC cpu interface structures to get the MPIDR
> value and map it to cpu_logical_map(), and add enabled cpu with valid
> MPIDR into cpu_possible_map.
> 
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
> 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>
> ---
>  xen/arch/arm/acpi/boot.c   | 121 +++++++++++++++++++++++++++++++++++++++++++++
>  xen/include/asm-arm/acpi.h |   2 +
>  xen/include/xen/acpi.h     |   4 ++
>  3 files changed, 127 insertions(+)
> 
> diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c
> index 0fabe7d..913d2a5 100644
> --- a/xen/arch/arm/acpi/boot.c
> +++ b/xen/arch/arm/acpi/boot.c
> @@ -32,6 +32,127 @@
>  #include <xen/mm.h>
>  
>  #include <asm/acpi.h>
> +#include <asm/smp.h>
> +
> +/* Processors with enabled flag and sane MPIDR */
> +static int enabled_cpus;

unsigned int


> +/* Boot CPU is valid or not in MADT */
> +static bool_t __initdata bootcpu_valid;
> +
> +/* total number of cpus in this system */
> +static unsigned int __initdata total_cpus = 0;

no need to explicitly initialize to 0


> +/*
> + * acpi_map_gic_cpu_interface - generates a logical cpu number
> + * and map to MPIDR represented by GICC structure
> + */
> +static void __init
> +acpi_map_gic_cpu_interface(struct acpi_madt_generic_interrupt *processor)
> +{
> +    int i;
> +    u64 mpidr = processor->arm_mpidr & MPIDR_HWID_MASK;
> +    bool enabled = !!(processor->flags & ACPI_MADT_ENABLED);

bool_t


> +    if (mpidr == MPIDR_INVALID) {
> +        printk("Skip MADT cpu entry with invalid MPIDR\n");
> +        return;
> +    }

I am not sure which coding style we are supposed to follow in this file.
This is the Linux coding style, not the Xen coding style.


> +    total_cpus++;
> +    if (!enabled)
> +        return;
> +
> +    if (enabled_cpus >=  NR_CPUS) {

unnecessary space


> +        printk("NR_CPUS limit of %d reached, Processor %d/0x%"PRIx64" ignored.\n",
> +               NR_CPUS, total_cpus, mpidr);
> +        return;
> +    }
> +
> +    /* Check if GICC structure of boot CPU is available in the MADT */
> +    if (cpu_logical_map(0) == mpidr) {
> +        if (bootcpu_valid) {
> +            printk("Firmware bug, duplicate CPU MPIDR: 0x%"PRIx64" in MADT\n",
> +                   mpidr);
> +            return;
> +        }
> +
> +        bootcpu_valid = true;
> +    }
> +
> +    /*
> +     * Duplicate MPIDRs are a recipe for disaster. Scan
> +     * all initialized entries and check for
> +     * duplicates. If any is found just ignore the CPU.
> +     */
> +    for (i = 1; i < enabled_cpus; i++) {
> +        if (cpu_logical_map(i) == mpidr) {
> +            printk("Firmware bug, duplicate CPU MPIDR: 0x%"PRIx64" in MADT\n",
> +                   mpidr);
> +            return;
> +        }
> +    }

I would merge this loop with the previous if statement and just add one
cpu_logical_map(0) check to set bootcpu_valid.


> +    if (!acpi_psci_present())
> +        return;
> +
> +    /* CPU 0 was already initialized */
> +    if (enabled_cpus) {
> +        if (arch_cpu_init(enabled_cpus, NULL) < 0)
> +            return;
> +
> +        /* map the logical cpu id to cpu MPIDR */
> +        cpu_logical_map(enabled_cpus) = mpidr;
> +    }
> +
> +    enabled_cpus++;
> +}
> +
> +static int __init
> +acpi_parse_gic_cpu_interface(struct acpi_subtable_header *header,
> +                             const unsigned long end)
> +{
> +    struct acpi_madt_generic_interrupt *processor;
> +
> +    processor = (struct acpi_madt_generic_interrupt *)header;

struct acpi_madt_generic_interrupt *processor =
		container_of(header, struct acpi_madt_generic_interrupt, header);


> +    if (BAD_MADT_ENTRY(processor, end))
> +        return -EINVAL;
> +
> +    acpi_table_print_madt_entry(header);
> +    acpi_map_gic_cpu_interface(processor);
> +    return 0;
> +}
> +
> +/* Parse GIC cpu interface entries in MADT for SMP init */
> +void __init acpi_smp_init_cpus(void)
> +{
> +    int count, i;
> +
> +    /*
> +     * do a partial walk of MADT to determine how many CPUs
> +     * we have including disabled CPUs, and get information
> +     * we need for SMP init
> +     */
> +    count = acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_INTERRUPT,
> +                    acpi_parse_gic_cpu_interface, 0);
> +
> +    if (count <= 0) {
> +        printk("Error parsing GIC CPU interface entry\n");
> +        return;
> +    }
> +
> +    if (!bootcpu_valid) {
> +        printk("MADT missing boot CPU MPIDR, not enabling secondaries\n");
> +        return;
> +    }
> +
> +    for (i = 0; i < enabled_cpus; i++)
> +        cpumask_set_cpu(i, &cpu_possible_map);
> +
> +    /* Make boot-up look pretty */
> +    printk("%d CPUs enabled, %d CPUs total\n", enabled_cpus, total_cpus);
> +}
>  
>  static int __init acpi_parse_fadt(struct acpi_table_header *table)
>  {
> diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
> index 65f80b1..1efa29d 100644
> --- a/xen/include/asm-arm/acpi.h
> +++ b/xen/include/asm-arm/acpi.h
> @@ -33,9 +33,11 @@ extern bool_t acpi_disabled;
>  #ifdef CONFIG_ACPI
>  bool_t __init acpi_psci_present(void);
>  bool_t __init acpi_psci_hvc_present(void);
> +void __init acpi_smp_init_cpus(void);
>  #else
>  static inline bool_t acpi_psci_present(void) { return false; }
>  static inline bool_t acpi_psci_hvc_present(void) {return false; }
> +static inline void acpi_smp_init_cpus(void) { }
>  #endif /* CONFIG_ACPI */
>  
>  /* Basic configuration for ACPI */
> diff --git a/xen/include/xen/acpi.h b/xen/include/xen/acpi.h
> index 48d7810..723ece8 100644
> --- a/xen/include/xen/acpi.h
> +++ b/xen/include/xen/acpi.h
> @@ -39,6 +39,10 @@
>  #define ACPI_MADT_GET_POLARITY(inti)	ACPI_MADT_GET_(POLARITY, inti)
>  #define ACPI_MADT_GET_TRIGGER(inti)	ACPI_MADT_GET_(TRIGGER, inti)
>  
> +#define BAD_MADT_ENTRY(entry, end) (                                        \
> +                (!entry) || (unsigned long)entry + sizeof(*entry) > end ||  \
> +                ((struct acpi_subtable_header *)entry)->length < sizeof(*entry))
> +
>  #ifdef CONFIG_ACPI_BOOT
>  
>  enum acpi_interrupt_id {
> -- 
> 2.1.0
> 

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

* Re: [PATCH v3 18/62] arm/acpi: Parse MADT to map logical cpu to MPIDR and get cpu_possible_map
@ 2015-11-23 15:18     ` Stefano Stabellini
  0 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-23 15:18 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, linux-arm-kernel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, david.vrabel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> From: Parth Dixit <parth.dixit@linaro.org>
> 
> MADT contains the information for MPIDR which is essential for SMP
> initialization, parse the GIC cpu interface structures to get the MPIDR
> value and map it to cpu_logical_map(), and add enabled cpu with valid
> MPIDR into cpu_possible_map.
> 
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
> 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>
> ---
>  xen/arch/arm/acpi/boot.c   | 121 +++++++++++++++++++++++++++++++++++++++++++++
>  xen/include/asm-arm/acpi.h |   2 +
>  xen/include/xen/acpi.h     |   4 ++
>  3 files changed, 127 insertions(+)
> 
> diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c
> index 0fabe7d..913d2a5 100644
> --- a/xen/arch/arm/acpi/boot.c
> +++ b/xen/arch/arm/acpi/boot.c
> @@ -32,6 +32,127 @@
>  #include <xen/mm.h>
>  
>  #include <asm/acpi.h>
> +#include <asm/smp.h>
> +
> +/* Processors with enabled flag and sane MPIDR */
> +static int enabled_cpus;

unsigned int


> +/* Boot CPU is valid or not in MADT */
> +static bool_t __initdata bootcpu_valid;
> +
> +/* total number of cpus in this system */
> +static unsigned int __initdata total_cpus = 0;

no need to explicitly initialize to 0


> +/*
> + * acpi_map_gic_cpu_interface - generates a logical cpu number
> + * and map to MPIDR represented by GICC structure
> + */
> +static void __init
> +acpi_map_gic_cpu_interface(struct acpi_madt_generic_interrupt *processor)
> +{
> +    int i;
> +    u64 mpidr = processor->arm_mpidr & MPIDR_HWID_MASK;
> +    bool enabled = !!(processor->flags & ACPI_MADT_ENABLED);

bool_t


> +    if (mpidr == MPIDR_INVALID) {
> +        printk("Skip MADT cpu entry with invalid MPIDR\n");
> +        return;
> +    }

I am not sure which coding style we are supposed to follow in this file.
This is the Linux coding style, not the Xen coding style.


> +    total_cpus++;
> +    if (!enabled)
> +        return;
> +
> +    if (enabled_cpus >=  NR_CPUS) {

unnecessary space


> +        printk("NR_CPUS limit of %d reached, Processor %d/0x%"PRIx64" ignored.\n",
> +               NR_CPUS, total_cpus, mpidr);
> +        return;
> +    }
> +
> +    /* Check if GICC structure of boot CPU is available in the MADT */
> +    if (cpu_logical_map(0) == mpidr) {
> +        if (bootcpu_valid) {
> +            printk("Firmware bug, duplicate CPU MPIDR: 0x%"PRIx64" in MADT\n",
> +                   mpidr);
> +            return;
> +        }
> +
> +        bootcpu_valid = true;
> +    }
> +
> +    /*
> +     * Duplicate MPIDRs are a recipe for disaster. Scan
> +     * all initialized entries and check for
> +     * duplicates. If any is found just ignore the CPU.
> +     */
> +    for (i = 1; i < enabled_cpus; i++) {
> +        if (cpu_logical_map(i) == mpidr) {
> +            printk("Firmware bug, duplicate CPU MPIDR: 0x%"PRIx64" in MADT\n",
> +                   mpidr);
> +            return;
> +        }
> +    }

I would merge this loop with the previous if statement and just add one
cpu_logical_map(0) check to set bootcpu_valid.


> +    if (!acpi_psci_present())
> +        return;
> +
> +    /* CPU 0 was already initialized */
> +    if (enabled_cpus) {
> +        if (arch_cpu_init(enabled_cpus, NULL) < 0)
> +            return;
> +
> +        /* map the logical cpu id to cpu MPIDR */
> +        cpu_logical_map(enabled_cpus) = mpidr;
> +    }
> +
> +    enabled_cpus++;
> +}
> +
> +static int __init
> +acpi_parse_gic_cpu_interface(struct acpi_subtable_header *header,
> +                             const unsigned long end)
> +{
> +    struct acpi_madt_generic_interrupt *processor;
> +
> +    processor = (struct acpi_madt_generic_interrupt *)header;

struct acpi_madt_generic_interrupt *processor =
		container_of(header, struct acpi_madt_generic_interrupt, header);


> +    if (BAD_MADT_ENTRY(processor, end))
> +        return -EINVAL;
> +
> +    acpi_table_print_madt_entry(header);
> +    acpi_map_gic_cpu_interface(processor);
> +    return 0;
> +}
> +
> +/* Parse GIC cpu interface entries in MADT for SMP init */
> +void __init acpi_smp_init_cpus(void)
> +{
> +    int count, i;
> +
> +    /*
> +     * do a partial walk of MADT to determine how many CPUs
> +     * we have including disabled CPUs, and get information
> +     * we need for SMP init
> +     */
> +    count = acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_INTERRUPT,
> +                    acpi_parse_gic_cpu_interface, 0);
> +
> +    if (count <= 0) {
> +        printk("Error parsing GIC CPU interface entry\n");
> +        return;
> +    }
> +
> +    if (!bootcpu_valid) {
> +        printk("MADT missing boot CPU MPIDR, not enabling secondaries\n");
> +        return;
> +    }
> +
> +    for (i = 0; i < enabled_cpus; i++)
> +        cpumask_set_cpu(i, &cpu_possible_map);
> +
> +    /* Make boot-up look pretty */
> +    printk("%d CPUs enabled, %d CPUs total\n", enabled_cpus, total_cpus);
> +}
>  
>  static int __init acpi_parse_fadt(struct acpi_table_header *table)
>  {
> diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
> index 65f80b1..1efa29d 100644
> --- a/xen/include/asm-arm/acpi.h
> +++ b/xen/include/asm-arm/acpi.h
> @@ -33,9 +33,11 @@ extern bool_t acpi_disabled;
>  #ifdef CONFIG_ACPI
>  bool_t __init acpi_psci_present(void);
>  bool_t __init acpi_psci_hvc_present(void);
> +void __init acpi_smp_init_cpus(void);
>  #else
>  static inline bool_t acpi_psci_present(void) { return false; }
>  static inline bool_t acpi_psci_hvc_present(void) {return false; }
> +static inline void acpi_smp_init_cpus(void) { }
>  #endif /* CONFIG_ACPI */
>  
>  /* Basic configuration for ACPI */
> diff --git a/xen/include/xen/acpi.h b/xen/include/xen/acpi.h
> index 48d7810..723ece8 100644
> --- a/xen/include/xen/acpi.h
> +++ b/xen/include/xen/acpi.h
> @@ -39,6 +39,10 @@
>  #define ACPI_MADT_GET_POLARITY(inti)	ACPI_MADT_GET_(POLARITY, inti)
>  #define ACPI_MADT_GET_TRIGGER(inti)	ACPI_MADT_GET_(TRIGGER, inti)
>  
> +#define BAD_MADT_ENTRY(entry, end) (                                        \
> +                (!entry) || (unsigned long)entry + sizeof(*entry) > end ||  \
> +                ((struct acpi_subtable_header *)entry)->length < sizeof(*entry))
> +
>  #ifdef CONFIG_ACPI_BOOT
>  
>  enum acpi_interrupt_id {
> -- 
> 2.1.0
> 

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

* [PATCH v3 19/62] arm/smpboot: Move dt specific code in smp to seperate functions
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-23 15:22   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-23 15:22 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> From: Parth Dixit <parth.dixit@linaro.org>
> 
> Partition smp initialization functions into generic and dt specific
> parts, this will be useful when introducing new functions for smp
> initialization based on acpi.
> 
> 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/arm64/smpboot.c |  7 ++++++-
>  xen/arch/arm/smpboot.c       | 29 ++++++++++++++++++-----------
>  2 files changed, 24 insertions(+), 12 deletions(-)
> 
> diff --git a/xen/arch/arm/arm64/smpboot.c b/xen/arch/arm/arm64/smpboot.c
> index 62e6abb..7928f69 100644
> --- a/xen/arch/arm/arm64/smpboot.c
> +++ b/xen/arch/arm/arm64/smpboot.c
> @@ -70,7 +70,7 @@ int __init arch_smp_init(void)
>      return 0;
>  }
>  
> -int __init arch_cpu_init(int cpu, struct dt_device_node *dn)
> +static int __init dt_arch_cpu_init(int cpu, struct dt_device_node *dn)
>  {
>      const char *enable_method;
>  
> @@ -94,6 +94,11 @@ int __init arch_cpu_init(int cpu, struct dt_device_node *dn)
>      return 0;
>  }
>  
> +int __init arch_cpu_init(int cpu, struct dt_device_node *dn)
> +{
> +    return dt_arch_cpu_init(cpu, dn);
> +}
> +
>  int __init arch_cpu_up(int cpu)
>  {
>      if ( !smp_enable_ops[cpu].prepare_cpu )
> diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c
> index a96cda2..d115228 100644
> --- a/xen/arch/arm/smpboot.c
> +++ b/xen/arch/arm/smpboot.c
> @@ -92,7 +92,7 @@ smp_clear_cpu_maps (void)
>   * MPIDR values related to logical cpus
>   * Code base on Linux arch/arm/kernel/devtree.c
>   */
> -void __init smp_init_cpus(void)
> +static void __init dt_smp_init_cpus(void)
>  {
>      register_t mpidr;
>      struct dt_device_node *cpus = dt_find_node_by_path("/cpus");
> @@ -106,16 +106,6 @@ void __init smp_init_cpus(void)
>      bool_t bootcpu_valid = 0;
>      int rc;
>  
> -    /* scan the DTB for a PSCI node and set a global variable */
> -    psci_init();
> -
> -    if ( (rc = arch_smp_init()) < 0 )
> -    {
> -        printk(XENLOG_WARNING "SMP init failed (%d)\n"
> -               "Using only 1 CPU\n", rc);
> -        return;
> -    }
> -
>      mpidr = boot_cpu_data.mpidr.bits & MPIDR_HWID_MASK;
>  
>      if ( !cpus )
> @@ -243,6 +233,23 @@ void __init smp_init_cpus(void)
>      }
>  }
>  
> +void __init smp_init_cpus(void)
> +{
> +    int rc;
> +
> +    /* initialize PSCI and set a global variable */
> +    psci_init();
> +
> +    if ( (rc = arch_smp_init()) < 0 )
> +    {
> +        printk(XENLOG_WARNING "SMP init failed (%d)\n"
> +               "Using only 1 CPU\n", rc);
> +        return;
> +    }
> +
> +    dt_smp_init_cpus();
> +}
> +
>  int __init
>  smp_get_max_cpus (void)
>  {
> -- 
> 2.1.0
> 

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

* Re: [PATCH v3 19/62] arm/smpboot: Move dt specific code in smp to seperate functions
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-23 15:22   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-23 15:22 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, linux-arm-kernel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, david.vrabel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> From: Parth Dixit <parth.dixit@linaro.org>
> 
> Partition smp initialization functions into generic and dt specific
> parts, this will be useful when introducing new functions for smp
> initialization based on acpi.
> 
> 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/arm64/smpboot.c |  7 ++++++-
>  xen/arch/arm/smpboot.c       | 29 ++++++++++++++++++-----------
>  2 files changed, 24 insertions(+), 12 deletions(-)
> 
> diff --git a/xen/arch/arm/arm64/smpboot.c b/xen/arch/arm/arm64/smpboot.c
> index 62e6abb..7928f69 100644
> --- a/xen/arch/arm/arm64/smpboot.c
> +++ b/xen/arch/arm/arm64/smpboot.c
> @@ -70,7 +70,7 @@ int __init arch_smp_init(void)
>      return 0;
>  }
>  
> -int __init arch_cpu_init(int cpu, struct dt_device_node *dn)
> +static int __init dt_arch_cpu_init(int cpu, struct dt_device_node *dn)
>  {
>      const char *enable_method;
>  
> @@ -94,6 +94,11 @@ int __init arch_cpu_init(int cpu, struct dt_device_node *dn)
>      return 0;
>  }
>  
> +int __init arch_cpu_init(int cpu, struct dt_device_node *dn)
> +{
> +    return dt_arch_cpu_init(cpu, dn);
> +}
> +
>  int __init arch_cpu_up(int cpu)
>  {
>      if ( !smp_enable_ops[cpu].prepare_cpu )
> diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c
> index a96cda2..d115228 100644
> --- a/xen/arch/arm/smpboot.c
> +++ b/xen/arch/arm/smpboot.c
> @@ -92,7 +92,7 @@ smp_clear_cpu_maps (void)
>   * MPIDR values related to logical cpus
>   * Code base on Linux arch/arm/kernel/devtree.c
>   */
> -void __init smp_init_cpus(void)
> +static void __init dt_smp_init_cpus(void)
>  {
>      register_t mpidr;
>      struct dt_device_node *cpus = dt_find_node_by_path("/cpus");
> @@ -106,16 +106,6 @@ void __init smp_init_cpus(void)
>      bool_t bootcpu_valid = 0;
>      int rc;
>  
> -    /* scan the DTB for a PSCI node and set a global variable */
> -    psci_init();
> -
> -    if ( (rc = arch_smp_init()) < 0 )
> -    {
> -        printk(XENLOG_WARNING "SMP init failed (%d)\n"
> -               "Using only 1 CPU\n", rc);
> -        return;
> -    }
> -
>      mpidr = boot_cpu_data.mpidr.bits & MPIDR_HWID_MASK;
>  
>      if ( !cpus )
> @@ -243,6 +233,23 @@ void __init smp_init_cpus(void)
>      }
>  }
>  
> +void __init smp_init_cpus(void)
> +{
> +    int rc;
> +
> +    /* initialize PSCI and set a global variable */
> +    psci_init();
> +
> +    if ( (rc = arch_smp_init()) < 0 )
> +    {
> +        printk(XENLOG_WARNING "SMP init failed (%d)\n"
> +               "Using only 1 CPU\n", rc);
> +        return;
> +    }
> +
> +    dt_smp_init_cpus();
> +}
> +
>  int __init
>  smp_get_max_cpus (void)
>  {
> -- 
> 2.1.0
> 

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

* [PATCH v3 20/62] arm/acpi: Add ACPI support for SMP initialization
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-23 15:27   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-23 15:27 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> ACPI 5.1 only has two explicit methods to boot up SMP, PSCI and Parking
> protocol, but the Parking protocol is only specified for ARMv7 now, so
> make PSCI as the only way for the SMP boot protocol before some updates
> for the ACPI spec or the Parking protocol spec.
> 
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/arm64/smpboot.c |  7 ++++++-
>  xen/arch/arm/psci.c          | 30 +++++++++++++++++++++++-------
>  xen/arch/arm/smpboot.c       |  7 ++++++-
>  3 files changed, 35 insertions(+), 9 deletions(-)
> 
> diff --git a/xen/arch/arm/arm64/smpboot.c b/xen/arch/arm/arm64/smpboot.c
> index 7928f69..93cb6b3 100644
> --- a/xen/arch/arm/arm64/smpboot.c
> +++ b/xen/arch/arm/arm64/smpboot.c
> @@ -7,6 +7,7 @@
>  #include <xen/vmap.h>
>  #include <asm/io.h>
>  #include <asm/psci.h>
> +#include <asm/acpi.h>
>  
>  struct smp_enable_ops {
>          int             (*prepare_cpu)(int);
> @@ -96,7 +97,11 @@ static int __init dt_arch_cpu_init(int cpu, struct dt_device_node *dn)
>  
>  int __init arch_cpu_init(int cpu, struct dt_device_node *dn)
>  {
> -    return dt_arch_cpu_init(cpu, dn);
> +    if( acpi_disabled )
> +        return dt_arch_cpu_init(cpu, dn);
> +    else
> +        /* acpi only supports psci at present */
> +        return smp_psci_init(cpu);
>  }
>  
>  int __init arch_cpu_up(int cpu)
> diff --git a/xen/arch/arm/psci.c b/xen/arch/arm/psci.c
> index d800cb6..dede0e1 100644
> --- a/xen/arch/arm/psci.c
> +++ b/xen/arch/arm/psci.c
> @@ -22,6 +22,7 @@
>  #include <xen/mm.h>
>  #include <xen/smp.h>
>  #include <asm/psci.h>
> +#include <asm/acpi.h>
>  
>  /*
>   * While a 64-bit OS can make calls with SMC32 calling conventions, for
> @@ -86,6 +87,9 @@ int __init psci_init_0_1(void)
>      int ret;
>      const struct dt_device_node *psci;
>  
> +    if ( !acpi_disabled )
> +        return -EINVAL;

It might be worth printing an error message here


>      psci = dt_find_compatible_node(NULL, NULL, "arm,psci");
>      if ( !psci )
>          return -EOPNOTSUPP;
> @@ -116,15 +120,24 @@ int __init psci_init_0_2(void)
>          { /* sentinel */ },
>      };
>      int ret;
> -    const struct dt_device_node *psci;
>  
> -    psci = dt_find_matching_node(NULL, psci_ids);
> -    if ( !psci )
> -        return -EOPNOTSUPP;
> +    if( acpi_disabled )
> +    {
> +        const struct dt_device_node *psci;
>  
> -    ret = psci_is_smc_method(psci);
> -    if ( ret )
> -        return -EINVAL;
> +        psci = dt_find_matching_node(NULL, psci_ids);
> +        if ( !psci )
> +            return -EOPNOTSUPP;
> +
> +        ret = psci_is_smc_method(psci);
> +        if ( ret )
> +            return -EINVAL;
> +    }
> +    else
> +    {
> +        if ( acpi_psci_hvc_present() )
> +            return -EINVAL;

and also here


> +    }
>  
>      psci_ver = call_smc(PSCI_0_2_FN_PSCI_VERSION, 0, 0, 0);
>  
> @@ -148,6 +161,9 @@ int __init psci_init(void)
>  {
>      int ret;
>  
> +    if( !acpi_disabled && !acpi_psci_present() )
> +        return -EOPNOTSUPP;
> +
>      ret = psci_init_0_2();
>      if ( ret )
>          ret = psci_init_0_1();
> diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c
> index d115228..513f1f6 100644
> --- a/xen/arch/arm/smpboot.c
> +++ b/xen/arch/arm/smpboot.c
> @@ -31,6 +31,7 @@
>  #include <xen/console.h>
>  #include <asm/gic.h>
>  #include <asm/psci.h>
> +#include <asm/acpi.h>
>  
>  cpumask_t cpu_online_map;
>  cpumask_t cpu_present_map;
> @@ -247,7 +248,11 @@ void __init smp_init_cpus(void)
>          return;
>      }
>  
> -    dt_smp_init_cpus();
> +    if ( acpi_disabled )
> +        dt_smp_init_cpus();
> +    else
> +        acpi_smp_init_cpus();
> +
>  }
>  
>  int __init
> -- 
> 2.1.0
> 

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

* Re: [PATCH v3 20/62] arm/acpi: Add ACPI support for SMP initialization
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-23 15:27   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-23 15:27 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, linux-arm-kernel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, david.vrabel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> ACPI 5.1 only has two explicit methods to boot up SMP, PSCI and Parking
> protocol, but the Parking protocol is only specified for ARMv7 now, so
> make PSCI as the only way for the SMP boot protocol before some updates
> for the ACPI spec or the Parking protocol spec.
> 
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/arm64/smpboot.c |  7 ++++++-
>  xen/arch/arm/psci.c          | 30 +++++++++++++++++++++++-------
>  xen/arch/arm/smpboot.c       |  7 ++++++-
>  3 files changed, 35 insertions(+), 9 deletions(-)
> 
> diff --git a/xen/arch/arm/arm64/smpboot.c b/xen/arch/arm/arm64/smpboot.c
> index 7928f69..93cb6b3 100644
> --- a/xen/arch/arm/arm64/smpboot.c
> +++ b/xen/arch/arm/arm64/smpboot.c
> @@ -7,6 +7,7 @@
>  #include <xen/vmap.h>
>  #include <asm/io.h>
>  #include <asm/psci.h>
> +#include <asm/acpi.h>
>  
>  struct smp_enable_ops {
>          int             (*prepare_cpu)(int);
> @@ -96,7 +97,11 @@ static int __init dt_arch_cpu_init(int cpu, struct dt_device_node *dn)
>  
>  int __init arch_cpu_init(int cpu, struct dt_device_node *dn)
>  {
> -    return dt_arch_cpu_init(cpu, dn);
> +    if( acpi_disabled )
> +        return dt_arch_cpu_init(cpu, dn);
> +    else
> +        /* acpi only supports psci at present */
> +        return smp_psci_init(cpu);
>  }
>  
>  int __init arch_cpu_up(int cpu)
> diff --git a/xen/arch/arm/psci.c b/xen/arch/arm/psci.c
> index d800cb6..dede0e1 100644
> --- a/xen/arch/arm/psci.c
> +++ b/xen/arch/arm/psci.c
> @@ -22,6 +22,7 @@
>  #include <xen/mm.h>
>  #include <xen/smp.h>
>  #include <asm/psci.h>
> +#include <asm/acpi.h>
>  
>  /*
>   * While a 64-bit OS can make calls with SMC32 calling conventions, for
> @@ -86,6 +87,9 @@ int __init psci_init_0_1(void)
>      int ret;
>      const struct dt_device_node *psci;
>  
> +    if ( !acpi_disabled )
> +        return -EINVAL;

It might be worth printing an error message here


>      psci = dt_find_compatible_node(NULL, NULL, "arm,psci");
>      if ( !psci )
>          return -EOPNOTSUPP;
> @@ -116,15 +120,24 @@ int __init psci_init_0_2(void)
>          { /* sentinel */ },
>      };
>      int ret;
> -    const struct dt_device_node *psci;
>  
> -    psci = dt_find_matching_node(NULL, psci_ids);
> -    if ( !psci )
> -        return -EOPNOTSUPP;
> +    if( acpi_disabled )
> +    {
> +        const struct dt_device_node *psci;
>  
> -    ret = psci_is_smc_method(psci);
> -    if ( ret )
> -        return -EINVAL;
> +        psci = dt_find_matching_node(NULL, psci_ids);
> +        if ( !psci )
> +            return -EOPNOTSUPP;
> +
> +        ret = psci_is_smc_method(psci);
> +        if ( ret )
> +            return -EINVAL;
> +    }
> +    else
> +    {
> +        if ( acpi_psci_hvc_present() )
> +            return -EINVAL;

and also here


> +    }
>  
>      psci_ver = call_smc(PSCI_0_2_FN_PSCI_VERSION, 0, 0, 0);
>  
> @@ -148,6 +161,9 @@ int __init psci_init(void)
>  {
>      int ret;
>  
> +    if( !acpi_disabled && !acpi_psci_present() )
> +        return -EOPNOTSUPP;
> +
>      ret = psci_init_0_2();
>      if ( ret )
>          ret = psci_init_0_1();
> diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c
> index d115228..513f1f6 100644
> --- a/xen/arch/arm/smpboot.c
> +++ b/xen/arch/arm/smpboot.c
> @@ -31,6 +31,7 @@
>  #include <xen/console.h>
>  #include <asm/gic.h>
>  #include <asm/psci.h>
> +#include <asm/acpi.h>
>  
>  cpumask_t cpu_online_map;
>  cpumask_t cpu_present_map;
> @@ -247,7 +248,11 @@ void __init smp_init_cpus(void)
>          return;
>      }
>  
> -    dt_smp_init_cpus();
> +    if ( acpi_disabled )
> +        dt_smp_init_cpus();
> +    else
> +        acpi_smp_init_cpus();
> +
>  }
>  
>  int __init
> -- 
> 2.1.0
> 

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

* [PATCH v3 21/62] arm/gic-v2: Refactor gicv2_init into generic and dt specific parts
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-23 15:40   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-23 15:40 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Refactor gic-v2 related functions into dt and generic parts. This will be
> helpful when adding acpi support for gic.
> 
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/gic-v2.c | 21 ++++++++++++++-------
>  1 file changed, 14 insertions(+), 7 deletions(-)
> 
> diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
> index 01e36b5..e31d38e 100644
> --- a/xen/arch/arm/gic-v2.c
> +++ b/xen/arch/arm/gic-v2.c
> @@ -628,13 +628,12 @@ static bool_t gicv2_is_aliased(paddr_t cbase, paddr_t csize)
>      return ((val_low & 0xfff0fff) == 0x0202043B && val_low == val_high);
>  }
>  
> -static int __init gicv2_init(void)
> +static paddr_t __initdata hbase, dbase, cbase, csize, vbase;
> +
> +static void __init dt_gicv2_init(void)
>  {
>      int res;
> -    paddr_t hbase, dbase;
> -    paddr_t cbase, csize;
> -    paddr_t vbase, vsize;
> -    uint32_t aliased_offset = 0;
> +    paddr_t vsize;
>      const struct dt_device_node *node = gicv2_info.node;
>  
>      res = dt_device_get_address(node, 0, &dbase, NULL);
> @@ -680,6 +679,13 @@ static int __init gicv2_init(void)
>      if ( csize != vsize )
>          panic("GICv2: Sizes of GICC (%#"PRIpaddr") and GICV (%#"PRIpaddr") don't match\n",
>                 csize, vsize);
> +}
> +
> +static int __init gicv2_init(void)
> +{
> +    uint32_t aliased_offset = 0;
> +
> +    dt_gicv2_init();
>  
>      printk("GICv2 initialization:\n"
>                "        gic_dist_addr=%"PRIpaddr"\n"
> @@ -765,7 +771,8 @@ const static struct gic_hw_operations gicv2_ops = {
>  };
>  
>  /* Set up the GIC */
> -static int __init gicv2_preinit(struct dt_device_node *node, const void *data)
> +static int __init dt_gicv2_preinit(struct dt_device_node *node,
> +                                   const void *data)
>  {
>      gicv2_info.hw_version = GIC_V2;
>      gicv2_info.node = node;
> @@ -783,7 +790,7 @@ static const struct dt_device_match gicv2_dt_match[] __initconst =
>  
>  DT_DEVICE_START(gicv2, "GICv2", DEVICE_GIC)
>          .dt_match = gicv2_dt_match,
> -        .init = gicv2_preinit,
> +        .init = dt_gicv2_preinit,

Maybe it would make sense to call this gicv2_dt_preinit for consistency,
nonetheless

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


>  DT_DEVICE_END
>  
>  /*
> -- 
> 2.1.0
> 

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

* Re: [PATCH v3 21/62] arm/gic-v2: Refactor gicv2_init into generic and dt specific parts
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-23 15:40   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-23 15:40 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, linux-arm-kernel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, david.vrabel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Refactor gic-v2 related functions into dt and generic parts. This will be
> helpful when adding acpi support for gic.
> 
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/gic-v2.c | 21 ++++++++++++++-------
>  1 file changed, 14 insertions(+), 7 deletions(-)
> 
> diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
> index 01e36b5..e31d38e 100644
> --- a/xen/arch/arm/gic-v2.c
> +++ b/xen/arch/arm/gic-v2.c
> @@ -628,13 +628,12 @@ static bool_t gicv2_is_aliased(paddr_t cbase, paddr_t csize)
>      return ((val_low & 0xfff0fff) == 0x0202043B && val_low == val_high);
>  }
>  
> -static int __init gicv2_init(void)
> +static paddr_t __initdata hbase, dbase, cbase, csize, vbase;
> +
> +static void __init dt_gicv2_init(void)
>  {
>      int res;
> -    paddr_t hbase, dbase;
> -    paddr_t cbase, csize;
> -    paddr_t vbase, vsize;
> -    uint32_t aliased_offset = 0;
> +    paddr_t vsize;
>      const struct dt_device_node *node = gicv2_info.node;
>  
>      res = dt_device_get_address(node, 0, &dbase, NULL);
> @@ -680,6 +679,13 @@ static int __init gicv2_init(void)
>      if ( csize != vsize )
>          panic("GICv2: Sizes of GICC (%#"PRIpaddr") and GICV (%#"PRIpaddr") don't match\n",
>                 csize, vsize);
> +}
> +
> +static int __init gicv2_init(void)
> +{
> +    uint32_t aliased_offset = 0;
> +
> +    dt_gicv2_init();
>  
>      printk("GICv2 initialization:\n"
>                "        gic_dist_addr=%"PRIpaddr"\n"
> @@ -765,7 +771,8 @@ const static struct gic_hw_operations gicv2_ops = {
>  };
>  
>  /* Set up the GIC */
> -static int __init gicv2_preinit(struct dt_device_node *node, const void *data)
> +static int __init dt_gicv2_preinit(struct dt_device_node *node,
> +                                   const void *data)
>  {
>      gicv2_info.hw_version = GIC_V2;
>      gicv2_info.node = node;
> @@ -783,7 +790,7 @@ static const struct dt_device_match gicv2_dt_match[] __initconst =
>  
>  DT_DEVICE_START(gicv2, "GICv2", DEVICE_GIC)
>          .dt_match = gicv2_dt_match,
> -        .init = gicv2_preinit,
> +        .init = dt_gicv2_preinit,

Maybe it would make sense to call this gicv2_dt_preinit for consistency,
nonetheless

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


>  DT_DEVICE_END
>  
>  /*
> -- 
> 2.1.0
> 

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

* [PATCH v3 03/62] acpi/pmstat: Build pmstat for x86 only
  2015-11-17  9:40 ` shannon.zhao at linaro.org
  2015-11-23 15:46   ` Jan Beulich
@ 2015-11-23 15:46   ` Jan Beulich
  1 sibling, 0 replies; 426+ messages in thread
From: Jan Beulich @ 2015-11-23 15:46 UTC (permalink / raw)
  To: linux-arm-kernel

>>> On 17.11.15 at 10:40, <shannon.zhao@linaro.org> wrote:
> --- a/xen/common/sysctl.c
> +++ b/xen/common/sysctl.c
> @@ -171,7 +171,7 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl)
>          op->u.availheap.avail_bytes <<= PAGE_SHIFT;
>          break;
>  
> -#ifdef HAS_ACPI
> +#ifdef HAS_CPUFREQ

You should combine the two instead of replacing one with the other.

Jan

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

* Re: [PATCH v3 03/62] acpi/pmstat: Build pmstat for x86 only
  2015-11-17  9:40 ` shannon.zhao at linaro.org
@ 2015-11-23 15:46   ` Jan Beulich
  2015-11-23 15:46   ` Jan Beulich
  1 sibling, 0 replies; 426+ messages in thread
From: Jan Beulich @ 2015-11-23 15:46 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, linux-arm-kernel,
	ard.biesheuvel, andrew.cooper3, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, david.vrabel, zhaoshenglong,
	christoffer.dall, roger.pau

>>> On 17.11.15 at 10:40, <shannon.zhao@linaro.org> wrote:
> --- a/xen/common/sysctl.c
> +++ b/xen/common/sysctl.c
> @@ -171,7 +171,7 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl)
>          op->u.availheap.avail_bytes <<= PAGE_SHIFT;
>          break;
>  
> -#ifdef HAS_ACPI
> +#ifdef HAS_CPUFREQ

You should combine the two instead of replacing one with the other.

Jan

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

* [PATCH v3 23/62] acpi/table: Introduce acpi_parse_entries
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-23 16:56   ` Jan Beulich
  -1 siblings, 0 replies; 426+ messages in thread
From: Jan Beulich @ 2015-11-23 16:56 UTC (permalink / raw)
  To: linux-arm-kernel

>>> On 17.11.15 at 10:40, <shannon.zhao@linaro.org> wrote:
> From: Parth Dixit <parth.dixit@linaro.org>
> 
> Add new function acpi_parse_entries which takes acpi table as argument.
> This will avoid fetching table everytime in acpi_table_parse_entries.
> This function will be used in acpi_gicv2_init within another patch.
> 
> 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>

Please clarify authorship: From and first S-o-b aren't really in line.

> --- a/xen/drivers/acpi/tables.c
> +++ b/xen/drivers/acpi/tables.c
> @@ -221,29 +221,27 @@ void __init acpi_table_print_madt_entry(struct 
> acpi_subtable_header *header)
>  	}
>  }
>  
> -
>  int __init
> -acpi_table_parse_entries(char *id,
> -			     unsigned long table_size,
> -			     int entry_id,
> -			     acpi_table_entry_handler handler,
> -			     unsigned int max_entries)
> +acpi_parse_entries(char *id,
> +		      unsigned long table_size,
> +		      acpi_table_entry_handler handler,
> +		      struct acpi_table_header *table_header,
> +		      int entry_id,
> +		      unsigned int max_entries)
>  {
> -	struct acpi_table_header *table_header = NULL;

Looks like Linux has gained similar functionality. Can't you simply
pull in one or more Linux commits?

> -	if (!handler)
> +	if ( !handler )

But in any event please don't change the file's coding style.

Jan

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

* Re: [PATCH v3 23/62] acpi/table: Introduce acpi_parse_entries
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-23 16:56   ` Jan Beulich
  -1 siblings, 0 replies; 426+ messages in thread
From: Jan Beulich @ 2015-11-23 16:56 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, linux-arm-kernel,
	ard.biesheuvel, andrew.cooper3, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, david.vrabel, zhaoshenglong,
	christoffer.dall, roger.pau

>>> On 17.11.15 at 10:40, <shannon.zhao@linaro.org> wrote:
> From: Parth Dixit <parth.dixit@linaro.org>
> 
> Add new function acpi_parse_entries which takes acpi table as argument.
> This will avoid fetching table everytime in acpi_table_parse_entries.
> This function will be used in acpi_gicv2_init within another patch.
> 
> 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>

Please clarify authorship: From and first S-o-b aren't really in line.

> --- a/xen/drivers/acpi/tables.c
> +++ b/xen/drivers/acpi/tables.c
> @@ -221,29 +221,27 @@ void __init acpi_table_print_madt_entry(struct 
> acpi_subtable_header *header)
>  	}
>  }
>  
> -
>  int __init
> -acpi_table_parse_entries(char *id,
> -			     unsigned long table_size,
> -			     int entry_id,
> -			     acpi_table_entry_handler handler,
> -			     unsigned int max_entries)
> +acpi_parse_entries(char *id,
> +		      unsigned long table_size,
> +		      acpi_table_entry_handler handler,
> +		      struct acpi_table_header *table_header,
> +		      int entry_id,
> +		      unsigned int max_entries)
>  {
> -	struct acpi_table_header *table_header = NULL;

Looks like Linux has gained similar functionality. Can't you simply
pull in one or more Linux commits?

> -	if (!handler)
> +	if ( !handler )

But in any event please don't change the file's coding style.

Jan

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

* [PATCH v3 25/62] acpi/table: Introduce acpi_get_entry to get specified entry
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-23 16:59   ` Jan Beulich
  2015-11-24  3:08     ` Shannon Zhao
  2015-11-24  3:08     ` Shannon Zhao
  -1 siblings, 2 replies; 426+ messages in thread
From: Jan Beulich @ 2015-11-23 16:59 UTC (permalink / raw)
  To: linux-arm-kernel

>>> On 17.11.15 at 10:40, <shannon.zhao@linaro.org> wrote:
> --- a/xen/drivers/acpi/tables.c
> +++ b/xen/drivers/acpi/tables.c
> @@ -221,6 +221,51 @@ void __init acpi_table_print_madt_entry(struct acpi_subtable_header *header)
>  	}
>  }
>  
> +struct acpi_subtable_header * __init
> +acpi_get_entry(char *id, unsigned long table_size,
> +	       struct acpi_table_header *table_header, int entry_id,
> +	       unsigned int entry_index)
> +{
> +	struct acpi_subtable_header *entry;
> +	unsigned int count = 0;
> +	unsigned long table_end;
> +
> +	if ( !table_size )

Linux coding style please in this file.

> +		return NULL;
> +
> +	if ( !table_header )
> +	{
> +		printk("Table header not present\n");
> +		return NULL;
> +	}
> +
> +	table_end = (unsigned long)table_header + table_header->length;

So here you use ->length, ...

> +	/* Parse all entries looking for a match. */
> +	entry = (struct acpi_subtable_header *)
> +	    ((unsigned long)table_header + table_size);

... but here table_size. Why?

Jan

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

* Re: [PATCH v3 25/62] acpi/table: Introduce acpi_get_entry to get specified entry
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-23 16:59   ` Jan Beulich
  -1 siblings, 0 replies; 426+ messages in thread
From: Jan Beulich @ 2015-11-23 16:59 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, linux-arm-kernel,
	ard.biesheuvel, andrew.cooper3, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, david.vrabel, zhaoshenglong,
	christoffer.dall, roger.pau

>>> On 17.11.15 at 10:40, <shannon.zhao@linaro.org> wrote:
> --- a/xen/drivers/acpi/tables.c
> +++ b/xen/drivers/acpi/tables.c
> @@ -221,6 +221,51 @@ void __init acpi_table_print_madt_entry(struct acpi_subtable_header *header)
>  	}
>  }
>  
> +struct acpi_subtable_header * __init
> +acpi_get_entry(char *id, unsigned long table_size,
> +	       struct acpi_table_header *table_header, int entry_id,
> +	       unsigned int entry_index)
> +{
> +	struct acpi_subtable_header *entry;
> +	unsigned int count = 0;
> +	unsigned long table_end;
> +
> +	if ( !table_size )

Linux coding style please in this file.

> +		return NULL;
> +
> +	if ( !table_header )
> +	{
> +		printk("Table header not present\n");
> +		return NULL;
> +	}
> +
> +	table_end = (unsigned long)table_header + table_header->length;

So here you use ->length, ...

> +	/* Parse all entries looking for a match. */
> +	entry = (struct acpi_subtable_header *)
> +	    ((unsigned long)table_header + table_size);

... but here table_size. Why?

Jan

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

* [PATCH v3 25/62] acpi/table: Introduce acpi_get_entry to get specified entry
  2015-11-23 16:59   ` Jan Beulich
@ 2015-11-24  3:08     ` Shannon Zhao
  2015-11-24  7:22       ` Jan Beulich
  2015-11-24  7:22       ` Jan Beulich
  2015-11-24  3:08     ` Shannon Zhao
  1 sibling, 2 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-11-24  3:08 UTC (permalink / raw)
  To: linux-arm-kernel



On 2015/11/24 0:59, Jan Beulich wrote:
>>>> On 17.11.15 at 10:40, <shannon.zhao@linaro.org> wrote:
>> --- a/xen/drivers/acpi/tables.c
>> +++ b/xen/drivers/acpi/tables.c
>> @@ -221,6 +221,51 @@ void __init acpi_table_print_madt_entry(struct acpi_subtable_header *header)
>>  	}
>>  }
>>  
>> +struct acpi_subtable_header * __init
>> +acpi_get_entry(char *id, unsigned long table_size,
>> +	       struct acpi_table_header *table_header, int entry_id,
>> +	       unsigned int entry_index)
>> +{
>> +	struct acpi_subtable_header *entry;
>> +	unsigned int count = 0;
>> +	unsigned long table_end;
>> +
>> +	if ( !table_size )
> 
> Linux coding style please in this file.
> 
Sure.

>> +		return NULL;
>> +
>> +	if ( !table_header )
>> +	{
>> +		printk("Table header not present\n");
>> +		return NULL;
>> +	}
>> +
>> +	table_end = (unsigned long)table_header + table_header->length;
> 
> So here you use ->length, ...
> 
>> +	/* Parse all entries looking for a match. */
>> +	entry = (struct acpi_subtable_header *)
>> +	    ((unsigned long)table_header + table_size);
> 
> ... but here table_size. Why?
> 
Here it just skips the main table size at the beginning. Then it could
point to the start of sub-table.
For example, to MADT table, the table_size is sizeof(struct
acpi_table_madt).

Thanks,
-- 
Shannon

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

* Re: [PATCH v3 25/62] acpi/table: Introduce acpi_get_entry to get specified entry
  2015-11-23 16:59   ` Jan Beulich
  2015-11-24  3:08     ` Shannon Zhao
@ 2015-11-24  3:08     ` Shannon Zhao
  1 sibling, 0 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-11-24  3:08 UTC (permalink / raw)
  To: Jan Beulich
  Cc: hangaohuai, ian.campbell, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, shannon.zhao, linux-arm-kernel



On 2015/11/24 0:59, Jan Beulich wrote:
>>>> On 17.11.15 at 10:40, <shannon.zhao@linaro.org> wrote:
>> --- a/xen/drivers/acpi/tables.c
>> +++ b/xen/drivers/acpi/tables.c
>> @@ -221,6 +221,51 @@ void __init acpi_table_print_madt_entry(struct acpi_subtable_header *header)
>>  	}
>>  }
>>  
>> +struct acpi_subtable_header * __init
>> +acpi_get_entry(char *id, unsigned long table_size,
>> +	       struct acpi_table_header *table_header, int entry_id,
>> +	       unsigned int entry_index)
>> +{
>> +	struct acpi_subtable_header *entry;
>> +	unsigned int count = 0;
>> +	unsigned long table_end;
>> +
>> +	if ( !table_size )
> 
> Linux coding style please in this file.
> 
Sure.

>> +		return NULL;
>> +
>> +	if ( !table_header )
>> +	{
>> +		printk("Table header not present\n");
>> +		return NULL;
>> +	}
>> +
>> +	table_end = (unsigned long)table_header + table_header->length;
> 
> So here you use ->length, ...
> 
>> +	/* Parse all entries looking for a match. */
>> +	entry = (struct acpi_subtable_header *)
>> +	    ((unsigned long)table_header + table_size);
> 
> ... but here table_size. Why?
> 
Here it just skips the main table size at the beginning. Then it could
point to the start of sub-table.
For example, to MADT table, the table_size is sizeof(struct
acpi_table_madt).

Thanks,
-- 
Shannon

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

* [PATCH v3 05/62] acpi: Don't do traditional BIOS table scan for ARM64
  2015-11-23 11:35     ` Jan Beulich
  2015-11-24  3:39       ` Shannon Zhao
@ 2015-11-24  3:39       ` Shannon Zhao
  2015-11-24  7:20         ` Jan Beulich
  2015-11-24  7:20         ` Jan Beulich
  1 sibling, 2 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-11-24  3:39 UTC (permalink / raw)
  To: linux-arm-kernel



On 2015/11/23 19:35, Jan Beulich wrote:
>>>> On 23.11.15 at 12:24, <stefano.stabellini@eu.citrix.com> wrote:
>> On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
>>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>>
>>> With the addition of ARM64 that does not have a traditional BIOS to
>>> scan, add a #ifdef option for x86 to do the traditional BIOS scanning
>>> for tables.
>>>
>>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>>> ---
>>>  xen/drivers/acpi/osl.c | 2 ++
>>>  1 file changed, 2 insertions(+)
>>>
>>> diff --git a/xen/drivers/acpi/osl.c b/xen/drivers/acpi/osl.c
>>> index ce15470..db74a90 100644
>>> --- a/xen/drivers/acpi/osl.c
>>> +++ b/xen/drivers/acpi/osl.c
>>> @@ -78,7 +78,9 @@ acpi_physical_address __init acpi_os_get_root_pointer(void)
>>>  	} else {
>>>  		acpi_physical_address pa = 0;
>>>  
>>> +		#ifdef CONFIG_X86
>>>  		acpi_find_root_pointer(&pa);
>>> +		#endif
>>>  		return pa;
>>>  	}
>>
>> I think it might be best to error out earlier if acpi and !efi_enabled
>> on arm and arm64.  If we do that we'll never enter this "else".
>>
>> If acpi_find_root_pointer doesn't build on arm, we should move it to an
>> x86 specific location, such as xen/arch/x86/efi.
> 
> No, definitely not (or if anything, then xen/arch/x86/acpi/). Instead
> the function itself should be stubbed out to do nothing on ARM. (And
> of course also the #ifdef placement is rather odd).
> 
How about adding a new CONFIG_ACPI_LEGACY_TABLES_LOOKUP like Linux
kernel for x86?

Thanks,
-- 
Shannon

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

* Re: [PATCH v3 05/62] acpi: Don't do traditional BIOS table scan for ARM64
  2015-11-23 11:35     ` Jan Beulich
@ 2015-11-24  3:39       ` Shannon Zhao
  2015-11-24  3:39       ` Shannon Zhao
  1 sibling, 0 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-11-24  3:39 UTC (permalink / raw)
  To: Jan Beulich, Stefano Stabellini, shannon.zhao
  Cc: hangaohuai, ian.campbell, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, linux-arm-kernel



On 2015/11/23 19:35, Jan Beulich wrote:
>>>> On 23.11.15 at 12:24, <stefano.stabellini@eu.citrix.com> wrote:
>> On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
>>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>>
>>> With the addition of ARM64 that does not have a traditional BIOS to
>>> scan, add a #ifdef option for x86 to do the traditional BIOS scanning
>>> for tables.
>>>
>>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>>> ---
>>>  xen/drivers/acpi/osl.c | 2 ++
>>>  1 file changed, 2 insertions(+)
>>>
>>> diff --git a/xen/drivers/acpi/osl.c b/xen/drivers/acpi/osl.c
>>> index ce15470..db74a90 100644
>>> --- a/xen/drivers/acpi/osl.c
>>> +++ b/xen/drivers/acpi/osl.c
>>> @@ -78,7 +78,9 @@ acpi_physical_address __init acpi_os_get_root_pointer(void)
>>>  	} else {
>>>  		acpi_physical_address pa = 0;
>>>  
>>> +		#ifdef CONFIG_X86
>>>  		acpi_find_root_pointer(&pa);
>>> +		#endif
>>>  		return pa;
>>>  	}
>>
>> I think it might be best to error out earlier if acpi and !efi_enabled
>> on arm and arm64.  If we do that we'll never enter this "else".
>>
>> If acpi_find_root_pointer doesn't build on arm, we should move it to an
>> x86 specific location, such as xen/arch/x86/efi.
> 
> No, definitely not (or if anything, then xen/arch/x86/acpi/). Instead
> the function itself should be stubbed out to do nothing on ARM. (And
> of course also the #ifdef placement is rather odd).
> 
How about adding a new CONFIG_ACPI_LEGACY_TABLES_LOOKUP like Linux
kernel for x86?

Thanks,
-- 
Shannon

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

* [PATCH v3 05/62] acpi: Don't do traditional BIOS table scan for ARM64
  2015-11-24  3:39       ` Shannon Zhao
  2015-11-24  7:20         ` Jan Beulich
@ 2015-11-24  7:20         ` Jan Beulich
  1 sibling, 0 replies; 426+ messages in thread
From: Jan Beulich @ 2015-11-24  7:20 UTC (permalink / raw)
  To: linux-arm-kernel

>>> On 24.11.15 at 04:39, <zhaoshenglong@huawei.com> wrote:
> On 2015/11/23 19:35, Jan Beulich wrote:
>>>>> On 23.11.15 at 12:24, <stefano.stabellini@eu.citrix.com> wrote:
>>> On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
>>>> --- a/xen/drivers/acpi/osl.c
>>>> +++ b/xen/drivers/acpi/osl.c
>>>> @@ -78,7 +78,9 @@ acpi_physical_address __init acpi_os_get_root_pointer(void)
>>>>  	} else {
>>>>  		acpi_physical_address pa = 0;
>>>>  
>>>> +		#ifdef CONFIG_X86
>>>>  		acpi_find_root_pointer(&pa);
>>>> +		#endif
>>>>  		return pa;
>>>>  	}
>>>
>>> I think it might be best to error out earlier if acpi and !efi_enabled
>>> on arm and arm64.  If we do that we'll never enter this "else".
>>>
>>> If acpi_find_root_pointer doesn't build on arm, we should move it to an
>>> x86 specific location, such as xen/arch/x86/efi.
>> 
>> No, definitely not (or if anything, then xen/arch/x86/acpi/). Instead
>> the function itself should be stubbed out to do nothing on ARM. (And
>> of course also the #ifdef placement is rather odd).
>> 
> How about adding a new CONFIG_ACPI_LEGACY_TABLES_LOOKUP like Linux
> kernel for x86?

Unless you know of an architecture other than x86 potentially
needing this, I think this would go too far. Plus the suggested name
would imply "old style" lookup only, whereas per-arch customization
also allows for other "modern" (or simply "alternative") mechanisms
to be used.

Jan

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

* Re: [PATCH v3 05/62] acpi: Don't do traditional BIOS table scan for ARM64
  2015-11-24  3:39       ` Shannon Zhao
@ 2015-11-24  7:20         ` Jan Beulich
  2015-11-24  7:20         ` Jan Beulich
  1 sibling, 0 replies; 426+ messages in thread
From: Jan Beulich @ 2015-11-24  7:20 UTC (permalink / raw)
  To: Shannon Zhao, shannon.zhao
  Cc: hangaohuai, ian.campbell, Stefano Stabellini, peter.huangpeng,
	xen-devel, julien.grall, stefano.stabellini, linux-arm-kernel

>>> On 24.11.15 at 04:39, <zhaoshenglong@huawei.com> wrote:
> On 2015/11/23 19:35, Jan Beulich wrote:
>>>>> On 23.11.15 at 12:24, <stefano.stabellini@eu.citrix.com> wrote:
>>> On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
>>>> --- a/xen/drivers/acpi/osl.c
>>>> +++ b/xen/drivers/acpi/osl.c
>>>> @@ -78,7 +78,9 @@ acpi_physical_address __init acpi_os_get_root_pointer(void)
>>>>  	} else {
>>>>  		acpi_physical_address pa = 0;
>>>>  
>>>> +		#ifdef CONFIG_X86
>>>>  		acpi_find_root_pointer(&pa);
>>>> +		#endif
>>>>  		return pa;
>>>>  	}
>>>
>>> I think it might be best to error out earlier if acpi and !efi_enabled
>>> on arm and arm64.  If we do that we'll never enter this "else".
>>>
>>> If acpi_find_root_pointer doesn't build on arm, we should move it to an
>>> x86 specific location, such as xen/arch/x86/efi.
>> 
>> No, definitely not (or if anything, then xen/arch/x86/acpi/). Instead
>> the function itself should be stubbed out to do nothing on ARM. (And
>> of course also the #ifdef placement is rather odd).
>> 
> How about adding a new CONFIG_ACPI_LEGACY_TABLES_LOOKUP like Linux
> kernel for x86?

Unless you know of an architecture other than x86 potentially
needing this, I think this would go too far. Plus the suggested name
would imply "old style" lookup only, whereas per-arch customization
also allows for other "modern" (or simply "alternative") mechanisms
to be used.

Jan

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

* [PATCH v3 25/62] acpi/table: Introduce acpi_get_entry to get specified entry
  2015-11-24  3:08     ` Shannon Zhao
@ 2015-11-24  7:22       ` Jan Beulich
  2015-11-24  7:48         ` Shannon Zhao
  2015-11-24  7:48         ` Shannon Zhao
  2015-11-24  7:22       ` Jan Beulich
  1 sibling, 2 replies; 426+ messages in thread
From: Jan Beulich @ 2015-11-24  7:22 UTC (permalink / raw)
  To: linux-arm-kernel

>>> On 24.11.15 at 04:08, <zhaoshenglong@huawei.com> wrote:
> On 2015/11/24 0:59, Jan Beulich wrote:
>>>>> On 17.11.15 at 10:40, <shannon.zhao@linaro.org> wrote:
>>> +	if ( !table_header )
>>> +	{
>>> +		printk("Table header not present\n");
>>> +		return NULL;
>>> +	}
>>> +
>>> +	table_end = (unsigned long)table_header + table_header->length;
>> 
>> So here you use ->length, ...
>> 
>>> +	/* Parse all entries looking for a match. */
>>> +	entry = (struct acpi_subtable_header *)
>>> +	    ((unsigned long)table_header + table_size);
>> 
>> ... but here table_size. Why?
>> 
> Here it just skips the main table size at the beginning. Then it could
> point to the start of sub-table.
> For example, to MADT table, the table_size is sizeof(struct
> acpi_table_madt).

Well, but for one then the parameter name is kind of wrong, and
second - is it really reasonable for the caller to tell the function?

Jan

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

* Re: [PATCH v3 25/62] acpi/table: Introduce acpi_get_entry to get specified entry
  2015-11-24  3:08     ` Shannon Zhao
  2015-11-24  7:22       ` Jan Beulich
@ 2015-11-24  7:22       ` Jan Beulich
  1 sibling, 0 replies; 426+ messages in thread
From: Jan Beulich @ 2015-11-24  7:22 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: hangaohuai, ian.campbell, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, shannon.zhao, linux-arm-kernel

>>> On 24.11.15 at 04:08, <zhaoshenglong@huawei.com> wrote:
> On 2015/11/24 0:59, Jan Beulich wrote:
>>>>> On 17.11.15 at 10:40, <shannon.zhao@linaro.org> wrote:
>>> +	if ( !table_header )
>>> +	{
>>> +		printk("Table header not present\n");
>>> +		return NULL;
>>> +	}
>>> +
>>> +	table_end = (unsigned long)table_header + table_header->length;
>> 
>> So here you use ->length, ...
>> 
>>> +	/* Parse all entries looking for a match. */
>>> +	entry = (struct acpi_subtable_header *)
>>> +	    ((unsigned long)table_header + table_size);
>> 
>> ... but here table_size. Why?
>> 
> Here it just skips the main table size at the beginning. Then it could
> point to the start of sub-table.
> For example, to MADT table, the table_size is sizeof(struct
> acpi_table_madt).

Well, but for one then the parameter name is kind of wrong, and
second - is it really reasonable for the caller to tell the function?

Jan

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

* [PATCH v3 57/62] hvm/params: Add a new dilivery type for event-channel in HVM_PARAM_CALLBACK_IRQ
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-24  7:35   ` Jan Beulich
  -1 siblings, 0 replies; 426+ messages in thread
From: Jan Beulich @ 2015-11-24  7:35 UTC (permalink / raw)
  To: linux-arm-kernel

>>> On 17.11.15 at 10:40, <shannon.zhao@linaro.org> 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).
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

Please sync up with Andrew's cleaning up of the modified comment;
I definitely will want that to go in first.

Jan

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

* Re: [PATCH v3 57/62] hvm/params: Add a new dilivery type for event-channel in HVM_PARAM_CALLBACK_IRQ
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-24  7:35   ` Jan Beulich
  -1 siblings, 0 replies; 426+ messages in thread
From: Jan Beulich @ 2015-11-24  7:35 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, linux-arm-kernel,
	ard.biesheuvel, andrew.cooper3, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, david.vrabel, zhaoshenglong,
	christoffer.dall, roger.pau

>>> On 17.11.15 at 10:40, <shannon.zhao@linaro.org> 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).
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

Please sync up with Andrew's cleaning up of the modified comment;
I definitely will want that to go in first.

Jan

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

* [PATCH v3 25/62] acpi/table: Introduce acpi_get_entry to get specified entry
  2015-11-24  7:22       ` Jan Beulich
  2015-11-24  7:48         ` Shannon Zhao
@ 2015-11-24  7:48         ` Shannon Zhao
  2015-11-24  8:04           ` Jan Beulich
  2015-11-24  8:04           ` Jan Beulich
  1 sibling, 2 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-11-24  7:48 UTC (permalink / raw)
  To: linux-arm-kernel



On 2015/11/24 15:22, Jan Beulich wrote:
>>>> On 24.11.15 at 04:08, <zhaoshenglong@huawei.com> wrote:
>> On 2015/11/24 0:59, Jan Beulich wrote:
>>>>>> On 17.11.15 at 10:40, <shannon.zhao@linaro.org> wrote:
>>>> +	if ( !table_header )
>>>> +	{
>>>> +		printk("Table header not present\n");
>>>> +		return NULL;
>>>> +	}
>>>> +
>>>> +	table_end = (unsigned long)table_header + table_header->length;
>>>
>>> So here you use ->length, ...
>>>
>>>> +	/* Parse all entries looking for a match. */
>>>> +	entry = (struct acpi_subtable_header *)
>>>> +	    ((unsigned long)table_header + table_size);
>>>
>>> ... but here table_size. Why?
>>>
>> Here it just skips the main table size at the beginning. Then it could
>> point to the start of sub-table.
>> For example, to MADT table, the table_size is sizeof(struct
>> acpi_table_madt).
> 
> Well, but for one then the parameter name is kind of wrong, and
> second - is it really reasonable for the caller to tell the function?
>  
I think the caller knows which table it wants to parse and could
calculate the size. But within this function, there is no clue to get
the main table size.

Thanks,
-- 
Shannon

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

* Re: [PATCH v3 25/62] acpi/table: Introduce acpi_get_entry to get specified entry
  2015-11-24  7:22       ` Jan Beulich
@ 2015-11-24  7:48         ` Shannon Zhao
  2015-11-24  7:48         ` Shannon Zhao
  1 sibling, 0 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-11-24  7:48 UTC (permalink / raw)
  To: Jan Beulich
  Cc: hangaohuai, ian.campbell, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, shannon.zhao, linux-arm-kernel



On 2015/11/24 15:22, Jan Beulich wrote:
>>>> On 24.11.15 at 04:08, <zhaoshenglong@huawei.com> wrote:
>> On 2015/11/24 0:59, Jan Beulich wrote:
>>>>>> On 17.11.15 at 10:40, <shannon.zhao@linaro.org> wrote:
>>>> +	if ( !table_header )
>>>> +	{
>>>> +		printk("Table header not present\n");
>>>> +		return NULL;
>>>> +	}
>>>> +
>>>> +	table_end = (unsigned long)table_header + table_header->length;
>>>
>>> So here you use ->length, ...
>>>
>>>> +	/* Parse all entries looking for a match. */
>>>> +	entry = (struct acpi_subtable_header *)
>>>> +	    ((unsigned long)table_header + table_size);
>>>
>>> ... but here table_size. Why?
>>>
>> Here it just skips the main table size at the beginning. Then it could
>> point to the start of sub-table.
>> For example, to MADT table, the table_size is sizeof(struct
>> acpi_table_madt).
> 
> Well, but for one then the parameter name is kind of wrong, and
> second - is it really reasonable for the caller to tell the function?
>  
I think the caller knows which table it wants to parse and could
calculate the size. But within this function, there is no clue to get
the main table size.

Thanks,
-- 
Shannon

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

* [PATCH v3 25/62] acpi/table: Introduce acpi_get_entry to get specified entry
  2015-11-24  7:48         ` Shannon Zhao
@ 2015-11-24  8:04           ` Jan Beulich
  2015-11-24  8:04           ` Jan Beulich
  1 sibling, 0 replies; 426+ messages in thread
From: Jan Beulich @ 2015-11-24  8:04 UTC (permalink / raw)
  To: linux-arm-kernel

>>> On 24.11.15 at 08:48, <zhaoshenglong@huawei.com> wrote:
> On 2015/11/24 15:22, Jan Beulich wrote:
>>>>> On 24.11.15 at 04:08, <zhaoshenglong@huawei.com> wrote:
>>> On 2015/11/24 0:59, Jan Beulich wrote:
>>>>>>> On 17.11.15 at 10:40, <shannon.zhao@linaro.org> wrote:
>>>>> +	if ( !table_header )
>>>>> +	{
>>>>> +		printk("Table header not present\n");
>>>>> +		return NULL;
>>>>> +	}
>>>>> +
>>>>> +	table_end = (unsigned long)table_header + table_header->length;
>>>>
>>>> So here you use ->length, ...
>>>>
>>>>> +	/* Parse all entries looking for a match. */
>>>>> +	entry = (struct acpi_subtable_header *)
>>>>> +	    ((unsigned long)table_header + table_size);
>>>>
>>>> ... but here table_size. Why?
>>>>
>>> Here it just skips the main table size at the beginning. Then it could
>>> point to the start of sub-table.
>>> For example, to MADT table, the table_size is sizeof(struct
>>> acpi_table_madt).
>> 
>> Well, but for one then the parameter name is kind of wrong, and
>> second - is it really reasonable for the caller to tell the function?
>>  
> I think the caller knows which table it wants to parse and could
> calculate the size. But within this function, there is no clue to get
> the main table size.

Well, yes and no: acpi_table_parse_entries() also gets table_size
passed in, but all its callers live under xen/drivers/acpi/. Hence it's
basically an internal ACPI interface with its declaration misplaced.
Thus the question is where the callers of the new interface you add
will end up living. If this is going to be a similarly internal interface,
then I'm fine. If you mean to add callers under xen/arch/arm/, then
I'm afraid I'm going to NAK this patch.

(And yes, I'd welcome a patch to introduce an internal header under
xen/drivers/acpi/ to hold declarations and definitions which aren't
supposed to be used outside that sub-tree.)

Jan

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

* Re: [PATCH v3 25/62] acpi/table: Introduce acpi_get_entry to get specified entry
  2015-11-24  7:48         ` Shannon Zhao
  2015-11-24  8:04           ` Jan Beulich
@ 2015-11-24  8:04           ` Jan Beulich
  1 sibling, 0 replies; 426+ messages in thread
From: Jan Beulich @ 2015-11-24  8:04 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: hangaohuai, ian.campbell, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, shannon.zhao, linux-arm-kernel

>>> On 24.11.15 at 08:48, <zhaoshenglong@huawei.com> wrote:
> On 2015/11/24 15:22, Jan Beulich wrote:
>>>>> On 24.11.15 at 04:08, <zhaoshenglong@huawei.com> wrote:
>>> On 2015/11/24 0:59, Jan Beulich wrote:
>>>>>>> On 17.11.15 at 10:40, <shannon.zhao@linaro.org> wrote:
>>>>> +	if ( !table_header )
>>>>> +	{
>>>>> +		printk("Table header not present\n");
>>>>> +		return NULL;
>>>>> +	}
>>>>> +
>>>>> +	table_end = (unsigned long)table_header + table_header->length;
>>>>
>>>> So here you use ->length, ...
>>>>
>>>>> +	/* Parse all entries looking for a match. */
>>>>> +	entry = (struct acpi_subtable_header *)
>>>>> +	    ((unsigned long)table_header + table_size);
>>>>
>>>> ... but here table_size. Why?
>>>>
>>> Here it just skips the main table size at the beginning. Then it could
>>> point to the start of sub-table.
>>> For example, to MADT table, the table_size is sizeof(struct
>>> acpi_table_madt).
>> 
>> Well, but for one then the parameter name is kind of wrong, and
>> second - is it really reasonable for the caller to tell the function?
>>  
> I think the caller knows which table it wants to parse and could
> calculate the size. But within this function, there is no clue to get
> the main table size.

Well, yes and no: acpi_table_parse_entries() also gets table_size
passed in, but all its callers live under xen/drivers/acpi/. Hence it's
basically an internal ACPI interface with its declaration misplaced.
Thus the question is where the callers of the new interface you add
will end up living. If this is going to be a similarly internal interface,
then I'm fine. If you mean to add callers under xen/arch/arm/, then
I'm afraid I'm going to NAK this patch.

(And yes, I'd welcome a patch to introduce an internal header under
xen/drivers/acpi/ to hold declarations and definitions which aren't
supposed to be used outside that sub-tree.)

Jan

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

* [Xen-devel] [PATCH v3 22/62] arm/gic-v3: Refactor gicv3_init into generic and dt specific parts
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-24 10:51   ` Stefano Stabellini
  2015-11-30 15:01     ` Julien Grall
  2015-11-30 15:01     ` [Xen-devel] " Julien Grall
  -1 siblings, 2 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-24 10:51 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Refactor gic-v3 related functions into dt and generic parts. This will be
> helpful when adding acpi support for gic-v3.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/gic-v3.c | 95 +++++++++++++++++++++++++++------------------------
>  1 file changed, 51 insertions(+), 44 deletions(-)
> 
> diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
> index 4fe0c37..bd13010 100644
> --- a/xen/arch/arm/gic-v3.c
> +++ b/xen/arch/arm/gic-v3.c
> @@ -1138,62 +1138,27 @@ static int __init cmp_rdist(const void *a, const void *b)
>      return ( l->base < r->base) ? -1 : 0;
>  }
>  
> +static paddr_t __initdata dbase = 0, cbase = 0, csize = 0, vbase = 0;

It might be best to initialize them to something like INVALID_PADDR
rather then 0, which is actually a possible address value.


>  /* If the GICv3 supports GICv2, initialize it */
> -static void __init gicv3_init_v2(const struct dt_device_node *node,
> -                                 paddr_t dbase)
> +static void __init gicv3_init_v2(void)
>  {
> -    int res;
> -    paddr_t cbase, csize;
> -    paddr_t vbase, vsize;
> -
> -    /*
> -     * For GICv3 supporting GICv2, GICC and GICV base address will be
> -     * provided.
> -     */
> -    res = dt_device_get_address(node, 1 + gicv3.rdist_count,
> -                                &cbase, &csize);
> -    if ( res )
> +    if ( cbase == 0 || vbase == 0 )
>          return;
>  
> -    res = dt_device_get_address(node, 1 + gicv3.rdist_count + 2,
> -                                &vbase, &vsize);
> -    if ( res )
> -        return;
> -
> -    /*
> -     * We emulate a vGICv2 using a GIC CPU interface of GUEST_GICC_SIZE.
> -     * So only support GICv2 on GICv3 when the virtual CPU interface is
> -     * at least GUEST_GICC_SIZE.
> -     */
> -    if ( vsize < GUEST_GICC_SIZE )
> -    {
> -        printk(XENLOG_WARNING
> -               "GICv3: WARNING: Not enabling support for GICv2 compat mode.\n"
> -               "Size of GICV (%#"PRIpaddr") must at least be %#llx.\n",
> -               vsize, GUEST_GICC_SIZE);
> -        return;
> -    }
> -
>      printk("GICv3 compatible with GICv2 cbase %#"PRIpaddr" vbase %#"PRIpaddr"\n",
>             cbase, vbase);
>  
>      vgic_v2_setup_hw(dbase, cbase, csize, vbase, 0);
>  }
>  
> -/* Set up the GIC */
> -static int __init gicv3_init(void)
> +static void __init dt_gicv3_init(void)
>  {
>      struct rdist_region *rdist_regs;
>      int res, i;
>      uint32_t reg;
>      const struct dt_device_node *node = gicv3_info.node;
> -    paddr_t dbase;
> -
> -    if ( !cpu_has_gicv3 )
> -    {
> -        dprintk(XENLOG_ERR, "GICv3: driver requires system register support\n");
> -        return -ENODEV;
> -    }
> +    paddr_t vsize;
>  
>      res = dt_device_get_address(node, 0, &dbase, NULL);
>      if ( res )
> @@ -1248,6 +1213,48 @@ static int __init gicv3_init(void)
>          panic("GICv3: Cannot find the maintenance IRQ");
>      gicv3_info.maintenance_irq = res;
>  
> +    /*
> +     * For GICv3 supporting GICv2, GICC and GICV base address will be
> +     * provided.
> +     */
> +    res = dt_device_get_address(node, 1 + gicv3.rdist_count,
> +                                &cbase, &csize);
> +    if ( res )
> +        return;
> +
> +    res = dt_device_get_address(node, 1 + gicv3.rdist_count + 2,
> +                                &vbase, &vsize);
> +    if ( res )
> +        return;
> +
> +    /*
> +     * We emulate a vGICv2 using a GIC CPU interface of GUEST_GICC_SIZE.
> +     * So only support GICv2 on GICv3 when the virtual CPU interface is
> +     * at least GUEST_GICC_SIZE.
> +     */
> +    if ( vsize < GUEST_GICC_SIZE )
> +    {
> +        printk(XENLOG_WARNING
> +               "GICv3: WARNING: Not enabling support for GICv2 compat mode.\n"
> +               "Size of GICV (%#"PRIpaddr") must at least be %#llx.\n",
> +               vsize, GUEST_GICC_SIZE);
> +        return;
> +    }
> +}
> +
> +/* Set up the GIC */
> +static int __init gicv3_init(void)
> +{
> +    int res, i;
> +
> +    if ( !cpu_has_gicv3 )
> +    {
> +        dprintk(XENLOG_ERR, "GICv3: driver requires system register support\n");
> +        return -ENODEV;
> +    }
> +
> +    dt_gicv3_init();

I think it would be best if we kept iall the ioremap calls here in the
common function, instead of duplicating them in the acpi and dt specific
init functions.

The GICD_PIDR2 check should common too.


>      for ( i = 0; i < gicv3.rdist_count; i++ )
>      {
>          /* map dbase & rdist regions */
> @@ -1277,7 +1284,7 @@ static int __init gicv3_init(void)
>  
>      vgic_v3_setup_hw(dbase, gicv3.rdist_count, gicv3.rdist_regions,
>                       gicv3.rdist_stride);
> -    gicv3_init_v2(node, dbase);
> +    gicv3_init_v2();
>  
>      spin_lock_init(&gicv3.lock);
>  
> @@ -1317,7 +1324,7 @@ static const struct gic_hw_operations gicv3_ops = {
>      .make_hwdom_dt_node  = gicv3_make_hwdom_dt_node,
>  };
>  
> -static int __init gicv3_preinit(struct dt_device_node *node, const void *data)
> +static int __init dt_gicv3_preinit(struct dt_device_node *node, const void *data)
>  {
>      gicv3_info.hw_version = GIC_V3;
>      gicv3_info.node = node;
> @@ -1335,7 +1342,7 @@ static const struct dt_device_match gicv3_dt_match[] __initconst =
>  
>  DT_DEVICE_START(gicv3, "GICv3", DEVICE_GIC)
>          .dt_match = gicv3_dt_match,
> -        .init = gicv3_preinit,
> +        .init = dt_gicv3_preinit,
>  DT_DEVICE_END
>  
>  /*

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

* Re: [PATCH v3 22/62] arm/gic-v3: Refactor gicv3_init into generic and dt specific parts
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-24 10:51   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-24 10:51 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, david.vrabel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Refactor gic-v3 related functions into dt and generic parts. This will be
> helpful when adding acpi support for gic-v3.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/gic-v3.c | 95 +++++++++++++++++++++++++++------------------------
>  1 file changed, 51 insertions(+), 44 deletions(-)
> 
> diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
> index 4fe0c37..bd13010 100644
> --- a/xen/arch/arm/gic-v3.c
> +++ b/xen/arch/arm/gic-v3.c
> @@ -1138,62 +1138,27 @@ static int __init cmp_rdist(const void *a, const void *b)
>      return ( l->base < r->base) ? -1 : 0;
>  }
>  
> +static paddr_t __initdata dbase = 0, cbase = 0, csize = 0, vbase = 0;

It might be best to initialize them to something like INVALID_PADDR
rather then 0, which is actually a possible address value.


>  /* If the GICv3 supports GICv2, initialize it */
> -static void __init gicv3_init_v2(const struct dt_device_node *node,
> -                                 paddr_t dbase)
> +static void __init gicv3_init_v2(void)
>  {
> -    int res;
> -    paddr_t cbase, csize;
> -    paddr_t vbase, vsize;
> -
> -    /*
> -     * For GICv3 supporting GICv2, GICC and GICV base address will be
> -     * provided.
> -     */
> -    res = dt_device_get_address(node, 1 + gicv3.rdist_count,
> -                                &cbase, &csize);
> -    if ( res )
> +    if ( cbase == 0 || vbase == 0 )
>          return;
>  
> -    res = dt_device_get_address(node, 1 + gicv3.rdist_count + 2,
> -                                &vbase, &vsize);
> -    if ( res )
> -        return;
> -
> -    /*
> -     * We emulate a vGICv2 using a GIC CPU interface of GUEST_GICC_SIZE.
> -     * So only support GICv2 on GICv3 when the virtual CPU interface is
> -     * at least GUEST_GICC_SIZE.
> -     */
> -    if ( vsize < GUEST_GICC_SIZE )
> -    {
> -        printk(XENLOG_WARNING
> -               "GICv3: WARNING: Not enabling support for GICv2 compat mode.\n"
> -               "Size of GICV (%#"PRIpaddr") must at least be %#llx.\n",
> -               vsize, GUEST_GICC_SIZE);
> -        return;
> -    }
> -
>      printk("GICv3 compatible with GICv2 cbase %#"PRIpaddr" vbase %#"PRIpaddr"\n",
>             cbase, vbase);
>  
>      vgic_v2_setup_hw(dbase, cbase, csize, vbase, 0);
>  }
>  
> -/* Set up the GIC */
> -static int __init gicv3_init(void)
> +static void __init dt_gicv3_init(void)
>  {
>      struct rdist_region *rdist_regs;
>      int res, i;
>      uint32_t reg;
>      const struct dt_device_node *node = gicv3_info.node;
> -    paddr_t dbase;
> -
> -    if ( !cpu_has_gicv3 )
> -    {
> -        dprintk(XENLOG_ERR, "GICv3: driver requires system register support\n");
> -        return -ENODEV;
> -    }
> +    paddr_t vsize;
>  
>      res = dt_device_get_address(node, 0, &dbase, NULL);
>      if ( res )
> @@ -1248,6 +1213,48 @@ static int __init gicv3_init(void)
>          panic("GICv3: Cannot find the maintenance IRQ");
>      gicv3_info.maintenance_irq = res;
>  
> +    /*
> +     * For GICv3 supporting GICv2, GICC and GICV base address will be
> +     * provided.
> +     */
> +    res = dt_device_get_address(node, 1 + gicv3.rdist_count,
> +                                &cbase, &csize);
> +    if ( res )
> +        return;
> +
> +    res = dt_device_get_address(node, 1 + gicv3.rdist_count + 2,
> +                                &vbase, &vsize);
> +    if ( res )
> +        return;
> +
> +    /*
> +     * We emulate a vGICv2 using a GIC CPU interface of GUEST_GICC_SIZE.
> +     * So only support GICv2 on GICv3 when the virtual CPU interface is
> +     * at least GUEST_GICC_SIZE.
> +     */
> +    if ( vsize < GUEST_GICC_SIZE )
> +    {
> +        printk(XENLOG_WARNING
> +               "GICv3: WARNING: Not enabling support for GICv2 compat mode.\n"
> +               "Size of GICV (%#"PRIpaddr") must at least be %#llx.\n",
> +               vsize, GUEST_GICC_SIZE);
> +        return;
> +    }
> +}
> +
> +/* Set up the GIC */
> +static int __init gicv3_init(void)
> +{
> +    int res, i;
> +
> +    if ( !cpu_has_gicv3 )
> +    {
> +        dprintk(XENLOG_ERR, "GICv3: driver requires system register support\n");
> +        return -ENODEV;
> +    }
> +
> +    dt_gicv3_init();

I think it would be best if we kept iall the ioremap calls here in the
common function, instead of duplicating them in the acpi and dt specific
init functions.

The GICD_PIDR2 check should common too.


>      for ( i = 0; i < gicv3.rdist_count; i++ )
>      {
>          /* map dbase & rdist regions */
> @@ -1277,7 +1284,7 @@ static int __init gicv3_init(void)
>  
>      vgic_v3_setup_hw(dbase, gicv3.rdist_count, gicv3.rdist_regions,
>                       gicv3.rdist_stride);
> -    gicv3_init_v2(node, dbase);
> +    gicv3_init_v2();
>  
>      spin_lock_init(&gicv3.lock);
>  
> @@ -1317,7 +1324,7 @@ static const struct gic_hw_operations gicv3_ops = {
>      .make_hwdom_dt_node  = gicv3_make_hwdom_dt_node,
>  };
>  
> -static int __init gicv3_preinit(struct dt_device_node *node, const void *data)
> +static int __init dt_gicv3_preinit(struct dt_device_node *node, const void *data)
>  {
>      gicv3_info.hw_version = GIC_V3;
>      gicv3_info.node = node;
> @@ -1335,7 +1342,7 @@ static const struct dt_device_match gicv3_dt_match[] __initconst =
>  
>  DT_DEVICE_START(gicv3, "GICv3", DEVICE_GIC)
>          .dt_match = gicv3_dt_match,
> -        .init = gicv3_preinit,
> +        .init = dt_gicv3_preinit,
>  DT_DEVICE_END
>  
>  /*

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

* [Xen-devel] [PATCH v3 24/62] arm: Introduce a generic way to use a device from acpi
  2015-11-17  9:40   ` shannon.zhao
                     ` (2 preceding siblings ...)
  (?)
@ 2015-11-24 11:18   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-24 11:18 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> From: Parth Dixit <parth.dixit@linaro.org>
> 
> Add generic way to use device from acpi similar to the way it is
> supported in device tree.
> 
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/device.c        | 19 +++++++++++++++++++
>  xen/arch/arm/xen.lds.S       |  7 +++++++
>  xen/include/asm-arm/device.h | 30 ++++++++++++++++++++++++++++++
>  3 files changed, 56 insertions(+)
> 
> diff --git a/xen/arch/arm/device.c b/xen/arch/arm/device.c
> index 0b53f6a..5494de0 100644
> --- a/xen/arch/arm/device.c
> +++ b/xen/arch/arm/device.c
> @@ -22,6 +22,7 @@
>  #include <xen/lib.h>
>  
>  extern const struct device_desc _sdevice[], _edevice[];
> +extern const struct acpi_device_desc _asdevice[], _aedevice[];
>  
>  int __init device_init(struct dt_device_node *dev, enum device_class class,
>                         const void *data)
> @@ -50,6 +51,24 @@ int __init device_init(struct dt_device_node *dev, enum device_class class,
>      return -EBADF;
>  }
>  
> +int __init acpi_device_init(enum device_class class, const void *data, int class_type)
> +{
> +    const struct acpi_device_desc *desc;
> +
> +    for ( desc = _asdevice; desc != _aedevice; desc++ )
> +    {
> +        if ( ( desc->class != class ) && ( desc->class_type != class_type ) )
> +            continue;

Shouldn't this be

  if ( ( desc->class != class ) || ( desc->class_type != class_type ) )

?

> +
> +        ASSERT(desc->init != NULL);
> +
> +        return desc->init(data);
> +    }
> +
> +    return -EBADF;
> +}
> +
>  enum device_class device_get_class(const struct dt_device_node *dev)
>  {
>      const struct device_desc *desc;
> diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S
> index 0488f37..60802f6 100644
> --- a/xen/arch/arm/xen.lds.S
> +++ b/xen/arch/arm/xen.lds.S
> @@ -100,6 +100,13 @@ SECTIONS
>        _edevice = .;
>    } :text
>  
> +  . = ALIGN(8);
> +  .adev.info : {
> +      _asdevice = .;
> +      *(.adev.info)
> +      _aedevice = .;
> +  } :text
> +
>    . = ALIGN(PAGE_SIZE);             /* Init code and data */
>    __init_begin = .;
>    .init.text : {
> diff --git a/xen/include/asm-arm/device.h b/xen/include/asm-arm/device.h
> index 5d0a4cd..085f221 100644
> --- a/xen/include/asm-arm/device.h
> +++ b/xen/include/asm-arm/device.h
> @@ -50,6 +50,27 @@ struct device_desc {
>      int (*init)(struct dt_device_node *dev, const void *data);
>  };
>  
> +struct acpi_device_desc {
> +    /* Device name */
> +    const char *name;
> +    /* Device class */
> +    enum device_class class;
> +    /* type of device supported by the driver */
> +    const int class_type;
> +    /* Device initialization */
> +    int (*init)(const void *data);
> +};
> +
> +/**
> + *  acpi_device_init - Initialize a device
> + *  @class: class of the device (serial, network...)
> + *  @data: specific data for initializing the device
> + *
> + *  Return 0 on success.
> + */
> +int __init acpi_device_init(enum device_class class,
> +                            const void *data, int class_type);
> +
>  /**
>   *  device_init - Initialize a device
>   *  @dev: device to initialize
> @@ -78,6 +99,15 @@ __section(".dev.info") = {                                          \
>  #define DT_DEVICE_END                                               \
>  };
>  
> +#define ACPI_DEVICE_START(_name, _namestr, _class)                    \
> +static const struct acpi_device_desc __dev_desc_##_name __used           \
> +__attribute__((__section__(".adev.info"))) = {                       \

why __attribute__?


> +    .name = _namestr,                                               \
> +    .class = _class,                                                \
> +
> +#define ACPI_DEVICE_END                                               \
> +};
> +
>  #endif /* __ASM_ARM_DEVICE_H */
>  
>  /*
> -- 
> 2.1.0
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel at lists.xen.org
> http://lists.xen.org/xen-devel
> 

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

* Re: [PATCH v3 24/62] arm: Introduce a generic way to use a device from acpi
  2015-11-17  9:40   ` shannon.zhao
                     ` (3 preceding siblings ...)
  (?)
@ 2015-11-24 11:18   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-24 11:18 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, david.vrabel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> From: Parth Dixit <parth.dixit@linaro.org>
> 
> Add generic way to use device from acpi similar to the way it is
> supported in device tree.
> 
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/device.c        | 19 +++++++++++++++++++
>  xen/arch/arm/xen.lds.S       |  7 +++++++
>  xen/include/asm-arm/device.h | 30 ++++++++++++++++++++++++++++++
>  3 files changed, 56 insertions(+)
> 
> diff --git a/xen/arch/arm/device.c b/xen/arch/arm/device.c
> index 0b53f6a..5494de0 100644
> --- a/xen/arch/arm/device.c
> +++ b/xen/arch/arm/device.c
> @@ -22,6 +22,7 @@
>  #include <xen/lib.h>
>  
>  extern const struct device_desc _sdevice[], _edevice[];
> +extern const struct acpi_device_desc _asdevice[], _aedevice[];
>  
>  int __init device_init(struct dt_device_node *dev, enum device_class class,
>                         const void *data)
> @@ -50,6 +51,24 @@ int __init device_init(struct dt_device_node *dev, enum device_class class,
>      return -EBADF;
>  }
>  
> +int __init acpi_device_init(enum device_class class, const void *data, int class_type)
> +{
> +    const struct acpi_device_desc *desc;
> +
> +    for ( desc = _asdevice; desc != _aedevice; desc++ )
> +    {
> +        if ( ( desc->class != class ) && ( desc->class_type != class_type ) )
> +            continue;

Shouldn't this be

  if ( ( desc->class != class ) || ( desc->class_type != class_type ) )

?

> +
> +        ASSERT(desc->init != NULL);
> +
> +        return desc->init(data);
> +    }
> +
> +    return -EBADF;
> +}
> +
>  enum device_class device_get_class(const struct dt_device_node *dev)
>  {
>      const struct device_desc *desc;
> diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S
> index 0488f37..60802f6 100644
> --- a/xen/arch/arm/xen.lds.S
> +++ b/xen/arch/arm/xen.lds.S
> @@ -100,6 +100,13 @@ SECTIONS
>        _edevice = .;
>    } :text
>  
> +  . = ALIGN(8);
> +  .adev.info : {
> +      _asdevice = .;
> +      *(.adev.info)
> +      _aedevice = .;
> +  } :text
> +
>    . = ALIGN(PAGE_SIZE);             /* Init code and data */
>    __init_begin = .;
>    .init.text : {
> diff --git a/xen/include/asm-arm/device.h b/xen/include/asm-arm/device.h
> index 5d0a4cd..085f221 100644
> --- a/xen/include/asm-arm/device.h
> +++ b/xen/include/asm-arm/device.h
> @@ -50,6 +50,27 @@ struct device_desc {
>      int (*init)(struct dt_device_node *dev, const void *data);
>  };
>  
> +struct acpi_device_desc {
> +    /* Device name */
> +    const char *name;
> +    /* Device class */
> +    enum device_class class;
> +    /* type of device supported by the driver */
> +    const int class_type;
> +    /* Device initialization */
> +    int (*init)(const void *data);
> +};
> +
> +/**
> + *  acpi_device_init - Initialize a device
> + *  @class: class of the device (serial, network...)
> + *  @data: specific data for initializing the device
> + *
> + *  Return 0 on success.
> + */
> +int __init acpi_device_init(enum device_class class,
> +                            const void *data, int class_type);
> +
>  /**
>   *  device_init - Initialize a device
>   *  @dev: device to initialize
> @@ -78,6 +99,15 @@ __section(".dev.info") = {                                          \
>  #define DT_DEVICE_END                                               \
>  };
>  
> +#define ACPI_DEVICE_START(_name, _namestr, _class)                    \
> +static const struct acpi_device_desc __dev_desc_##_name __used           \
> +__attribute__((__section__(".adev.info"))) = {                       \

why __attribute__?


> +    .name = _namestr,                                               \
> +    .class = _class,                                                \
> +
> +#define ACPI_DEVICE_END                                               \
> +};
> +
>  #endif /* __ASM_ARM_DEVICE_H */
>  
>  /*
> -- 
> 2.1.0
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
> 

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

* [PATCH v3 12/62] ACPICA: ACPI 6.0: Add changes for FADT table
  2015-11-17  9:40   ` shannon.zhao
                     ` (3 preceding siblings ...)
  (?)
@ 2015-11-24 11:29   ` Jan Beulich
  2015-11-25  1:45     ` Shannon Zhao
  2015-11-25  1:45     ` Shannon Zhao
  -1 siblings, 2 replies; 426+ messages in thread
From: Jan Beulich @ 2015-11-24 11:29 UTC (permalink / raw)
  To: linux-arm-kernel

>>> On 17.11.15 at 10:40, <shannon.zhao@linaro.org> wrote:
> From: Bob Moore <robert.moore@intel.com>
> 
> ACPICA commit 72b0b6741990f619f6aaa915302836b7cbb41ac4
> 
> One new 64-bit field at the end of the table.
> FADT version is now 6.
> 
> Link: https://github.com/acpica/acpica/commit/72b0b674 
> Signed-off-by: Bob Moore <robert.moore@intel.com>
> Signed-off-by: Lv Zheng <lv.zheng@intel.com>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> [Linux commit aeb823bbacc2a3aaee29eda5875b58a049fa1f78]
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/include/acpi/actbl.h | 17 ++++++++++-------
>  1 file changed, 10 insertions(+), 7 deletions(-)

So while I applied this one after fixing it up, I'm not going to do any
further fixups to later patches I also meant to apply. I realize the
fixups may have been necessary because of me applying them in
other than the submitted sequence, but then again such general
imports from ACPICA/Linux should have been independent of
earlier changes. I.e. either earlier patches in the series wrongly
touch these headers, or there's a general problem with the series.

Jan

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

* Re: [PATCH v3 12/62] ACPICA: ACPI 6.0: Add changes for FADT table
  2015-11-17  9:40   ` shannon.zhao
                     ` (2 preceding siblings ...)
  (?)
@ 2015-11-24 11:29   ` Jan Beulich
  -1 siblings, 0 replies; 426+ messages in thread
From: Jan Beulich @ 2015-11-24 11:29 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, linux-arm-kernel,
	ard.biesheuvel, andrew.cooper3, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, david.vrabel, zhaoshenglong,
	christoffer.dall, roger.pau

>>> On 17.11.15 at 10:40, <shannon.zhao@linaro.org> wrote:
> From: Bob Moore <robert.moore@intel.com>
> 
> ACPICA commit 72b0b6741990f619f6aaa915302836b7cbb41ac4
> 
> One new 64-bit field at the end of the table.
> FADT version is now 6.
> 
> Link: https://github.com/acpica/acpica/commit/72b0b674 
> Signed-off-by: Bob Moore <robert.moore@intel.com>
> Signed-off-by: Lv Zheng <lv.zheng@intel.com>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> [Linux commit aeb823bbacc2a3aaee29eda5875b58a049fa1f78]
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/include/acpi/actbl.h | 17 ++++++++++-------
>  1 file changed, 10 insertions(+), 7 deletions(-)

So while I applied this one after fixing it up, I'm not going to do any
further fixups to later patches I also meant to apply. I realize the
fixups may have been necessary because of me applying them in
other than the submitted sequence, but then again such general
imports from ACPICA/Linux should have been independent of
earlier changes. I.e. either earlier patches in the series wrongly
touch these headers, or there's a general problem with the series.

Jan

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

* [Xen-devel] [PATCH v3 26/62] arm/gic-v2: Add ACPI boot support for GICv2
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-24 11:54   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-24 11:54 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> From: Parth Dixit <parth.dixit@linaro.org>
> 
> ACPI on Xen hypervisor uses MADT table for proper GIC initialization.
> First get the GIC version from GIC Distributor. Then parse GIC related
> subtables, collect CPU interface and distributor addresses and call
> driver initialization function (which is hardware abstraction agnostic).
> In a similar way, FDT initialize GICv2.
> 
> Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> 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>
> ---
>  xen/arch/arm/gic-v2.c | 122 +++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 121 insertions(+), 1 deletion(-)
> 
> diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
> index e31d38e..9a9fcd5 100644
> --- a/xen/arch/arm/gic-v2.c
> +++ b/xen/arch/arm/gic-v2.c
> @@ -29,6 +29,8 @@
>  #include <xen/device_tree.h>
>  #include <xen/libfdt/libfdt.h>
>  #include <xen/sizes.h>
> +#include <xen/acpi.h>
> +#include <acpi/actables.h>
>  #include <asm/p2m.h>
>  #include <asm/domain.h>
>  #include <asm/platform.h>
> @@ -36,6 +38,7 @@
>  
>  #include <asm/io.h>
>  #include <asm/gic.h>
> +#include <asm/acpi.h>
>  
>  /*
>   * LR register definitions are GIC v2 specific.
> @@ -681,11 +684,113 @@ static void __init dt_gicv2_init(void)
>                 csize, vsize);
>  }
>  
> +#ifdef CONFIG_ACPI
> +static int __init
> +gic_acpi_parse_madt_cpu(struct acpi_subtable_header *header,
> +                        const unsigned long end)
> +{
> +    static int cpu_base_assigned = 0;
> +    struct acpi_madt_generic_interrupt *processor;
> +
> +    processor = (struct acpi_madt_generic_interrupt *)header;

Use container_of to cast


> +    if ( BAD_MADT_ENTRY(processor, end) )
> +        return -EINVAL;
> +
> +    /* Read from APIC table and fill up the GIC variables */
> +    if ( cpu_base_assigned == 0 )
> +    {
> +        cbase = processor->base_address;
> +        csize = SZ_8K;
> +        hbase = processor->gich_base_address;
> +        vbase = processor->gicv_base_address;
> +        gicv2_info.maintenance_irq = processor->vgic_interrupt;
> +
> +        if( processor->flags & ACPI_MADT_VGIC_IRQ_MODE )
> +            irq_set_type(gicv2_info.maintenance_irq, ACPI_IRQ_TYPE_EDGE_BOTH);
> +        else
> +            irq_set_type(gicv2_info.maintenance_irq, ACPI_IRQ_TYPE_LEVEL_MASK);
> +
> +	cpu_base_assigned = 1;

coding style


> +    }
> +    else
> +    {
> +        if ( cbase != processor->base_address
> +             || hbase != processor->gich_base_address
> +             || vbase != processor->gicv_base_address
> +             || gicv2_info.maintenance_irq != processor->vgic_interrupt )
> +        {
> +	    printk("GICv2: GICC entries are not same in MADT table\n");
> +	    return -EINVAL;

coding style


> +        }
> +    }
> +
> +    return 0;
> +}
> +
> +static int __init
> +gic_acpi_parse_madt_distributor(struct acpi_subtable_header *header,
> +                                const unsigned long end)
> +{
> +    struct acpi_madt_generic_distributor *dist;
> +
> +    dist = (struct acpi_madt_generic_distributor *)header;

Same here.

It looks OK aside from these few things.


> +    if ( BAD_MADT_ENTRY(dist, end) )
> +        return -EINVAL;
> +
> +    dbase = dist->base_address;
> +
> +    return 0;
> +}
> +
> +static void __init acpi_gicv2_init(void)
> +{
> +    acpi_status status;
> +    struct acpi_table_header *table;
> +    int count;
> +
> +    status = acpi_get_table(ACPI_SIG_MADT, 0, &table);
> +
> +    if ( ACPI_FAILURE(status) )
> +    {
> +        const char *msg = acpi_format_exception(status);
> +
> +        panic("GICv2: Failed to get MADT table, %s", msg);
> +    }
> +
> +    /* Collect CPU base addresses */
> +    count = acpi_parse_entries(ACPI_SIG_MADT, sizeof(struct acpi_table_madt),
> +                               gic_acpi_parse_madt_cpu, table,
> +                               ACPI_MADT_TYPE_GENERIC_INTERRUPT, 0);
> +    if ( count <= 0 )
> +        panic("GICv2: No valid GICC entries exists");
> +
> +    /*
> +     * Find distributor base address. We expect one distributor entry since
> +     * ACPI 5.0 spec neither support multi-GIC instances nor GIC cascade.
> +     */
> +    count = acpi_parse_entries(ACPI_SIG_MADT, sizeof(struct acpi_table_madt),
> +                               gic_acpi_parse_madt_distributor, table,
> +                               ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR, 0);
> +    if ( count <= 0 )
> +        panic("GICv2: No valid GICD entries exists");
> +}
> +#else
> +static void __init acpi_gicv2_init(void)
> +{
> +/* Should never reach here */
> +}
> +#endif
> +
>  static int __init gicv2_init(void)
>  {
>      uint32_t aliased_offset = 0;
>  
> -    dt_gicv2_init();
> +    if( acpi_disabled )
> +        dt_gicv2_init();
> +    else
> +        acpi_gicv2_init();
>  
>      printk("GICv2 initialization:\n"
>                "        gic_dist_addr=%"PRIpaddr"\n"
> @@ -793,6 +898,21 @@ DT_DEVICE_START(gicv2, "GICv2", DEVICE_GIC)
>          .init = dt_gicv2_preinit,
>  DT_DEVICE_END
>  
> +#ifdef CONFIG_ACPI
> +/* Set up the GIC */
> +static int __init acpi_gicv2_preinit(const void *data)
> +{
> +    gicv2_info.hw_version = GIC_V2;
> +    register_gic_ops(&gicv2_ops);
> +
> +    return 0;
> +}
> +
> +ACPI_DEVICE_START(agicv2, "GICv2", DEVICE_GIC)
> +        .class_type = GIC_V2,
> +        .init = acpi_gicv2_preinit,
> +ACPI_DEVICE_END
> +#endif
>  /*
>   * Local variables:
>   * mode: C

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

* Re: [PATCH v3 26/62] arm/gic-v2: Add ACPI boot support for GICv2
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-24 11:54   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-24 11:54 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, david.vrabel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> From: Parth Dixit <parth.dixit@linaro.org>
> 
> ACPI on Xen hypervisor uses MADT table for proper GIC initialization.
> First get the GIC version from GIC Distributor. Then parse GIC related
> subtables, collect CPU interface and distributor addresses and call
> driver initialization function (which is hardware abstraction agnostic).
> In a similar way, FDT initialize GICv2.
> 
> Signed-off-by: Tomasz Nowicki <tomasz.nowicki@linaro.org>
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> 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>
> ---
>  xen/arch/arm/gic-v2.c | 122 +++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 121 insertions(+), 1 deletion(-)
> 
> diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
> index e31d38e..9a9fcd5 100644
> --- a/xen/arch/arm/gic-v2.c
> +++ b/xen/arch/arm/gic-v2.c
> @@ -29,6 +29,8 @@
>  #include <xen/device_tree.h>
>  #include <xen/libfdt/libfdt.h>
>  #include <xen/sizes.h>
> +#include <xen/acpi.h>
> +#include <acpi/actables.h>
>  #include <asm/p2m.h>
>  #include <asm/domain.h>
>  #include <asm/platform.h>
> @@ -36,6 +38,7 @@
>  
>  #include <asm/io.h>
>  #include <asm/gic.h>
> +#include <asm/acpi.h>
>  
>  /*
>   * LR register definitions are GIC v2 specific.
> @@ -681,11 +684,113 @@ static void __init dt_gicv2_init(void)
>                 csize, vsize);
>  }
>  
> +#ifdef CONFIG_ACPI
> +static int __init
> +gic_acpi_parse_madt_cpu(struct acpi_subtable_header *header,
> +                        const unsigned long end)
> +{
> +    static int cpu_base_assigned = 0;
> +    struct acpi_madt_generic_interrupt *processor;
> +
> +    processor = (struct acpi_madt_generic_interrupt *)header;

Use container_of to cast


> +    if ( BAD_MADT_ENTRY(processor, end) )
> +        return -EINVAL;
> +
> +    /* Read from APIC table and fill up the GIC variables */
> +    if ( cpu_base_assigned == 0 )
> +    {
> +        cbase = processor->base_address;
> +        csize = SZ_8K;
> +        hbase = processor->gich_base_address;
> +        vbase = processor->gicv_base_address;
> +        gicv2_info.maintenance_irq = processor->vgic_interrupt;
> +
> +        if( processor->flags & ACPI_MADT_VGIC_IRQ_MODE )
> +            irq_set_type(gicv2_info.maintenance_irq, ACPI_IRQ_TYPE_EDGE_BOTH);
> +        else
> +            irq_set_type(gicv2_info.maintenance_irq, ACPI_IRQ_TYPE_LEVEL_MASK);
> +
> +	cpu_base_assigned = 1;

coding style


> +    }
> +    else
> +    {
> +        if ( cbase != processor->base_address
> +             || hbase != processor->gich_base_address
> +             || vbase != processor->gicv_base_address
> +             || gicv2_info.maintenance_irq != processor->vgic_interrupt )
> +        {
> +	    printk("GICv2: GICC entries are not same in MADT table\n");
> +	    return -EINVAL;

coding style


> +        }
> +    }
> +
> +    return 0;
> +}
> +
> +static int __init
> +gic_acpi_parse_madt_distributor(struct acpi_subtable_header *header,
> +                                const unsigned long end)
> +{
> +    struct acpi_madt_generic_distributor *dist;
> +
> +    dist = (struct acpi_madt_generic_distributor *)header;

Same here.

It looks OK aside from these few things.


> +    if ( BAD_MADT_ENTRY(dist, end) )
> +        return -EINVAL;
> +
> +    dbase = dist->base_address;
> +
> +    return 0;
> +}
> +
> +static void __init acpi_gicv2_init(void)
> +{
> +    acpi_status status;
> +    struct acpi_table_header *table;
> +    int count;
> +
> +    status = acpi_get_table(ACPI_SIG_MADT, 0, &table);
> +
> +    if ( ACPI_FAILURE(status) )
> +    {
> +        const char *msg = acpi_format_exception(status);
> +
> +        panic("GICv2: Failed to get MADT table, %s", msg);
> +    }
> +
> +    /* Collect CPU base addresses */
> +    count = acpi_parse_entries(ACPI_SIG_MADT, sizeof(struct acpi_table_madt),
> +                               gic_acpi_parse_madt_cpu, table,
> +                               ACPI_MADT_TYPE_GENERIC_INTERRUPT, 0);
> +    if ( count <= 0 )
> +        panic("GICv2: No valid GICC entries exists");
> +
> +    /*
> +     * Find distributor base address. We expect one distributor entry since
> +     * ACPI 5.0 spec neither support multi-GIC instances nor GIC cascade.
> +     */
> +    count = acpi_parse_entries(ACPI_SIG_MADT, sizeof(struct acpi_table_madt),
> +                               gic_acpi_parse_madt_distributor, table,
> +                               ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR, 0);
> +    if ( count <= 0 )
> +        panic("GICv2: No valid GICD entries exists");
> +}
> +#else
> +static void __init acpi_gicv2_init(void)
> +{
> +/* Should never reach here */
> +}
> +#endif
> +
>  static int __init gicv2_init(void)
>  {
>      uint32_t aliased_offset = 0;
>  
> -    dt_gicv2_init();
> +    if( acpi_disabled )
> +        dt_gicv2_init();
> +    else
> +        acpi_gicv2_init();
>  
>      printk("GICv2 initialization:\n"
>                "        gic_dist_addr=%"PRIpaddr"\n"
> @@ -793,6 +898,21 @@ DT_DEVICE_START(gicv2, "GICv2", DEVICE_GIC)
>          .init = dt_gicv2_preinit,
>  DT_DEVICE_END
>  
> +#ifdef CONFIG_ACPI
> +/* Set up the GIC */
> +static int __init acpi_gicv2_preinit(const void *data)
> +{
> +    gicv2_info.hw_version = GIC_V2;
> +    register_gic_ops(&gicv2_ops);
> +
> +    return 0;
> +}
> +
> +ACPI_DEVICE_START(agicv2, "GICv2", DEVICE_GIC)
> +        .class_type = GIC_V2,
> +        .init = acpi_gicv2_preinit,
> +ACPI_DEVICE_END
> +#endif
>  /*
>   * Local variables:
>   * mode: C

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

* [Xen-devel] [PATCH v3 27/62] arm/gic-v3: Add ACPI boot support for GICv3
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-24 12:00   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-24 12:00 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Like GICv2, ACPI on Xen hypervisor uses MADT table for proper GICv3
> initialization. Parse GIC distributor subtable, redistributor subtable
> and interrupt subtable.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/gic-v3.c | 182 +++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 181 insertions(+), 1 deletion(-)
> 
> diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
> index bd13010..fa732d7 100644
> --- a/xen/arch/arm/gic-v3.c
> +++ b/xen/arch/arm/gic-v3.c
> @@ -34,6 +34,8 @@
>  #include <xen/sizes.h>
>  #include <xen/libfdt/libfdt.h>
>  #include <xen/sort.h>
> +#include <xen/acpi.h>
> +#include <acpi/actables.h>
>  #include <asm/p2m.h>
>  #include <asm/domain.h>
>  #include <asm/io.h>
> @@ -41,6 +43,7 @@
>  #include <asm/gic.h>
>  #include <asm/gic_v3_defs.h>
>  #include <asm/cpufeature.h>
> +#include <asm/acpi.h>
>  
>  /* Global state */
>  static struct {
> @@ -1242,6 +1245,164 @@ static void __init dt_gicv3_init(void)
>      }
>  }
>  
> +#ifdef CONFIG_ACPI
> +static int __init
> +gic_acpi_parse_madt_cpu(struct acpi_subtable_header *header,
> +                        const unsigned long end)
> +{
> +    static bool cpu_base_assigned = false;
> +    struct acpi_madt_generic_interrupt *processor;
> +
> +    processor = (struct acpi_madt_generic_interrupt *)header;
> +
> +    if ( BAD_MADT_ENTRY(processor, end) )
> +        return -EINVAL;
> +
> +    /* Read from APIC table and fill up the GIC variables */
> +    if ( !cpu_base_assigned )
> +    {
> +        cbase = processor->base_address;
> +        csize = SZ_8K;
> +        vbase = processor->gicv_base_address;
> +        gicv3_info.maintenance_irq = processor->vgic_interrupt;
> +
> +        if( processor->flags & ACPI_MADT_VGIC_IRQ_MODE )
> +            irq_set_type(gicv3_info.maintenance_irq, ACPI_IRQ_TYPE_EDGE_BOTH);
> +        else
> +            irq_set_type(gicv3_info.maintenance_irq, ACPI_IRQ_TYPE_LEVEL_MASK);
> +
> +	cpu_base_assigned = true;

coding style


> +    }
> +    else
> +    {
> +        if ( cbase != processor->base_address
> +             || vbase != processor->gicv_base_address
> +             || gicv3_info.maintenance_irq != processor->vgic_interrupt )
> +        {
> +	    printk("GICv3: GICC entries are not same in MADT table\n");
> +	    return -EINVAL;

coding style


> +        }
> +    }
> +
> +    return 0;
> +}
> +
> +static int __init
> +gic_acpi_parse_madt_distributor(struct acpi_subtable_header *header,
> +                                const unsigned long end)
> +{
> +    struct acpi_madt_generic_distributor *dist;
> +
> +    dist = (struct acpi_madt_generic_distributor *)header;
> +
> +    if ( BAD_MADT_ENTRY(dist, end) )
> +        return -EINVAL;
> +
> +    dbase = dist->base_address;
> +
> +    return 0;
> +}
> +static int __init
> +gic_acpi_get_madt_redistributor_num(struct acpi_subtable_header *header,
> +                                    const unsigned long end)
> +{
> +    return 0;

I think you should at least add a comment here to explain why we just
return 0 in this case


> +}
> +
> +static void __init acpi_gicv3_init(void)
> +{
> +    struct acpi_table_header *table;
> +    struct rdist_region *rdist_regs;
> +    acpi_status status;
> +    int count, i;
> +    uint32_t reg;
> +
> +    status = acpi_get_table(ACPI_SIG_MADT, 0, &table);
> +
> +    if ( ACPI_FAILURE(status) )
> +    {
> +        const char *msg = acpi_format_exception(status);
> +
> +        panic("GICv3: Failed to get MADT table, %s", msg);
> +    }
> +
> +    /*
> +     * Find distributor base address. We expect one distributor entry since
> +     * ACPI 5.0 spec neither support multi-GIC instances nor GIC cascade.
> +     */
> +    count = acpi_parse_entries(ACPI_SIG_MADT, sizeof(struct acpi_table_madt),
> +                               gic_acpi_parse_madt_distributor, table,
> +                               ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR, 0);
> +
> +    if ( count <= 0 )
> +        panic("GICv3: No valid GICD entries exists");
> +
> +    if ( (dbase & ~PAGE_MASK) )
> +        panic("GICv3: Found unaligned distributor address %"PRIpaddr"",
> +              dbase);
> +
> +    gicv3.map_dbase = ioremap_nocache(dbase, SZ_64K);
> +    if ( !gicv3.map_dbase )
> +        panic("GICv3: Failed to ioremap for GIC distributor\n");
> +
> +    reg = readl_relaxed(GICD + GICD_PIDR2) & GIC_PIDR2_ARCH_MASK;
> +    if ( reg != GIC_PIDR2_ARCH_GICv3 )
> +         panic("GICv3: no distributor detected\n");

I think these should be moved to a common init function


> +    /* Get number of redistributor */
> +    count = acpi_parse_entries(ACPI_SIG_MADT, sizeof(struct acpi_table_madt),
> +                               gic_acpi_get_madt_redistributor_num, table,
> +                               ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR, 0);
> +    if ( count <= 0 )
> +        panic("GICv3: No valid GICR entries exists");
> +
> +    gicv3.rdist_count = count;
> +
> +    if ( gicv3.rdist_count > MAX_RDIST_COUNT )
> +        panic("GICv3: Number of redistributor regions is more than"
> +              "%d (Increase MAX_RDIST_COUNT!!)\n", MAX_RDIST_COUNT);
> +
> +    rdist_regs = xzalloc_array(struct rdist_region, gicv3.rdist_count);
> +    if ( !rdist_regs )
> +        panic("GICv3: Failed to allocate memory for rdist regions\n");
> +
> +    for ( i = 0; i < gicv3.rdist_count; i++ )
> +    {
> +        struct acpi_subtable_header *subtable;
> +        struct acpi_madt_generic_redistributor *gic_rdist;
> +
> +        subtable = acpi_get_entry(ACPI_SIG_MADT, sizeof(struct acpi_table_madt),
> +                                  table, ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR,
> +                                  i);
> +        if ( !subtable )
> +            panic("GICv3: Can't get GICR entry");
> +
> +	gic_rdist = (struct acpi_madt_generic_redistributor *)subtable;

coding style


> +        rdist_regs[i].base = gic_rdist->base_address;
> +        rdist_regs[i].size = gic_rdist->length;
> +    }
> +
> +    /* The vGIC code requires the region to be sorted */
> +    sort(rdist_regs, gicv3.rdist_count, sizeof(*rdist_regs), cmp_rdist, NULL);
> +
> +    gicv3.rdist_regions= rdist_regs;
> +
> +    /* Collect CPU base addresses */
> +    count = acpi_parse_entries(ACPI_SIG_MADT, sizeof(struct acpi_table_madt),
> +                               gic_acpi_parse_madt_cpu, table,
> +                               ACPI_MADT_TYPE_GENERIC_INTERRUPT, 0);
> +    if ( count <= 0 )
> +        panic("GICv3: No valid GICC entries exists");
> +
> +    gicv3.rdist_stride = 0;
> +}
> +#else
> +static void __init acpi_gicv3_init(void)
> +{
> +/* Should never reach here */
> +}
> +#endif
> +
>  /* Set up the GIC */
>  static int __init gicv3_init(void)
>  {
> @@ -1253,7 +1414,10 @@ static int __init gicv3_init(void)
>          return -ENODEV;
>      }
>  
> -    dt_gicv3_init();
> +    if( acpi_disabled )
> +        dt_gicv3_init();
> +    else
> +        acpi_gicv3_init();
>  
>      for ( i = 0; i < gicv3.rdist_count; i++ )
>      {
> @@ -1345,6 +1509,22 @@ DT_DEVICE_START(gicv3, "GICv3", DEVICE_GIC)
>          .init = dt_gicv3_preinit,
>  DT_DEVICE_END
>  
> +#ifdef CONFIG_ACPI
> +/* Set up the GIC */
> +static int __init acpi_gicv3_preinit(const void *data)
> +{
> +    gicv3_info.hw_version = GIC_V3;
> +    register_gic_ops(&gicv3_ops);
> +
> +    return 0;
> +}
> +
> +ACPI_DEVICE_START(agicv3, "GICv3", DEVICE_GIC)
> +        .class_type = GIC_V3,
> +        .init = acpi_gicv3_preinit,
> +ACPI_DEVICE_END
> +#endif
> +
>  /*
>   * Local variables:
>   * mode: C
> -- 
> 2.1.0
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel at lists.xen.org
> http://lists.xen.org/xen-devel
> 

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

* Re: [PATCH v3 27/62] arm/gic-v3: Add ACPI boot support for GICv3
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-24 12:00   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-24 12:00 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, david.vrabel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Like GICv2, ACPI on Xen hypervisor uses MADT table for proper GICv3
> initialization. Parse GIC distributor subtable, redistributor subtable
> and interrupt subtable.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/gic-v3.c | 182 +++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 181 insertions(+), 1 deletion(-)
> 
> diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
> index bd13010..fa732d7 100644
> --- a/xen/arch/arm/gic-v3.c
> +++ b/xen/arch/arm/gic-v3.c
> @@ -34,6 +34,8 @@
>  #include <xen/sizes.h>
>  #include <xen/libfdt/libfdt.h>
>  #include <xen/sort.h>
> +#include <xen/acpi.h>
> +#include <acpi/actables.h>
>  #include <asm/p2m.h>
>  #include <asm/domain.h>
>  #include <asm/io.h>
> @@ -41,6 +43,7 @@
>  #include <asm/gic.h>
>  #include <asm/gic_v3_defs.h>
>  #include <asm/cpufeature.h>
> +#include <asm/acpi.h>
>  
>  /* Global state */
>  static struct {
> @@ -1242,6 +1245,164 @@ static void __init dt_gicv3_init(void)
>      }
>  }
>  
> +#ifdef CONFIG_ACPI
> +static int __init
> +gic_acpi_parse_madt_cpu(struct acpi_subtable_header *header,
> +                        const unsigned long end)
> +{
> +    static bool cpu_base_assigned = false;
> +    struct acpi_madt_generic_interrupt *processor;
> +
> +    processor = (struct acpi_madt_generic_interrupt *)header;
> +
> +    if ( BAD_MADT_ENTRY(processor, end) )
> +        return -EINVAL;
> +
> +    /* Read from APIC table and fill up the GIC variables */
> +    if ( !cpu_base_assigned )
> +    {
> +        cbase = processor->base_address;
> +        csize = SZ_8K;
> +        vbase = processor->gicv_base_address;
> +        gicv3_info.maintenance_irq = processor->vgic_interrupt;
> +
> +        if( processor->flags & ACPI_MADT_VGIC_IRQ_MODE )
> +            irq_set_type(gicv3_info.maintenance_irq, ACPI_IRQ_TYPE_EDGE_BOTH);
> +        else
> +            irq_set_type(gicv3_info.maintenance_irq, ACPI_IRQ_TYPE_LEVEL_MASK);
> +
> +	cpu_base_assigned = true;

coding style


> +    }
> +    else
> +    {
> +        if ( cbase != processor->base_address
> +             || vbase != processor->gicv_base_address
> +             || gicv3_info.maintenance_irq != processor->vgic_interrupt )
> +        {
> +	    printk("GICv3: GICC entries are not same in MADT table\n");
> +	    return -EINVAL;

coding style


> +        }
> +    }
> +
> +    return 0;
> +}
> +
> +static int __init
> +gic_acpi_parse_madt_distributor(struct acpi_subtable_header *header,
> +                                const unsigned long end)
> +{
> +    struct acpi_madt_generic_distributor *dist;
> +
> +    dist = (struct acpi_madt_generic_distributor *)header;
> +
> +    if ( BAD_MADT_ENTRY(dist, end) )
> +        return -EINVAL;
> +
> +    dbase = dist->base_address;
> +
> +    return 0;
> +}
> +static int __init
> +gic_acpi_get_madt_redistributor_num(struct acpi_subtable_header *header,
> +                                    const unsigned long end)
> +{
> +    return 0;

I think you should at least add a comment here to explain why we just
return 0 in this case


> +}
> +
> +static void __init acpi_gicv3_init(void)
> +{
> +    struct acpi_table_header *table;
> +    struct rdist_region *rdist_regs;
> +    acpi_status status;
> +    int count, i;
> +    uint32_t reg;
> +
> +    status = acpi_get_table(ACPI_SIG_MADT, 0, &table);
> +
> +    if ( ACPI_FAILURE(status) )
> +    {
> +        const char *msg = acpi_format_exception(status);
> +
> +        panic("GICv3: Failed to get MADT table, %s", msg);
> +    }
> +
> +    /*
> +     * Find distributor base address. We expect one distributor entry since
> +     * ACPI 5.0 spec neither support multi-GIC instances nor GIC cascade.
> +     */
> +    count = acpi_parse_entries(ACPI_SIG_MADT, sizeof(struct acpi_table_madt),
> +                               gic_acpi_parse_madt_distributor, table,
> +                               ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR, 0);
> +
> +    if ( count <= 0 )
> +        panic("GICv3: No valid GICD entries exists");
> +
> +    if ( (dbase & ~PAGE_MASK) )
> +        panic("GICv3: Found unaligned distributor address %"PRIpaddr"",
> +              dbase);
> +
> +    gicv3.map_dbase = ioremap_nocache(dbase, SZ_64K);
> +    if ( !gicv3.map_dbase )
> +        panic("GICv3: Failed to ioremap for GIC distributor\n");
> +
> +    reg = readl_relaxed(GICD + GICD_PIDR2) & GIC_PIDR2_ARCH_MASK;
> +    if ( reg != GIC_PIDR2_ARCH_GICv3 )
> +         panic("GICv3: no distributor detected\n");

I think these should be moved to a common init function


> +    /* Get number of redistributor */
> +    count = acpi_parse_entries(ACPI_SIG_MADT, sizeof(struct acpi_table_madt),
> +                               gic_acpi_get_madt_redistributor_num, table,
> +                               ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR, 0);
> +    if ( count <= 0 )
> +        panic("GICv3: No valid GICR entries exists");
> +
> +    gicv3.rdist_count = count;
> +
> +    if ( gicv3.rdist_count > MAX_RDIST_COUNT )
> +        panic("GICv3: Number of redistributor regions is more than"
> +              "%d (Increase MAX_RDIST_COUNT!!)\n", MAX_RDIST_COUNT);
> +
> +    rdist_regs = xzalloc_array(struct rdist_region, gicv3.rdist_count);
> +    if ( !rdist_regs )
> +        panic("GICv3: Failed to allocate memory for rdist regions\n");
> +
> +    for ( i = 0; i < gicv3.rdist_count; i++ )
> +    {
> +        struct acpi_subtable_header *subtable;
> +        struct acpi_madt_generic_redistributor *gic_rdist;
> +
> +        subtable = acpi_get_entry(ACPI_SIG_MADT, sizeof(struct acpi_table_madt),
> +                                  table, ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR,
> +                                  i);
> +        if ( !subtable )
> +            panic("GICv3: Can't get GICR entry");
> +
> +	gic_rdist = (struct acpi_madt_generic_redistributor *)subtable;

coding style


> +        rdist_regs[i].base = gic_rdist->base_address;
> +        rdist_regs[i].size = gic_rdist->length;
> +    }
> +
> +    /* The vGIC code requires the region to be sorted */
> +    sort(rdist_regs, gicv3.rdist_count, sizeof(*rdist_regs), cmp_rdist, NULL);
> +
> +    gicv3.rdist_regions= rdist_regs;
> +
> +    /* Collect CPU base addresses */
> +    count = acpi_parse_entries(ACPI_SIG_MADT, sizeof(struct acpi_table_madt),
> +                               gic_acpi_parse_madt_cpu, table,
> +                               ACPI_MADT_TYPE_GENERIC_INTERRUPT, 0);
> +    if ( count <= 0 )
> +        panic("GICv3: No valid GICC entries exists");
> +
> +    gicv3.rdist_stride = 0;
> +}
> +#else
> +static void __init acpi_gicv3_init(void)
> +{
> +/* Should never reach here */
> +}
> +#endif
> +
>  /* Set up the GIC */
>  static int __init gicv3_init(void)
>  {
> @@ -1253,7 +1414,10 @@ static int __init gicv3_init(void)
>          return -ENODEV;
>      }
>  
> -    dt_gicv3_init();
> +    if( acpi_disabled )
> +        dt_gicv3_init();
> +    else
> +        acpi_gicv3_init();
>  
>      for ( i = 0; i < gicv3.rdist_count; i++ )
>      {
> @@ -1345,6 +1509,22 @@ DT_DEVICE_START(gicv3, "GICv3", DEVICE_GIC)
>          .init = dt_gicv3_preinit,
>  DT_DEVICE_END
>  
> +#ifdef CONFIG_ACPI
> +/* Set up the GIC */
> +static int __init acpi_gicv3_preinit(const void *data)
> +{
> +    gicv3_info.hw_version = GIC_V3;
> +    register_gic_ops(&gicv3_ops);
> +
> +    return 0;
> +}
> +
> +ACPI_DEVICE_START(agicv3, "GICv3", DEVICE_GIC)
> +        .class_type = GIC_V3,
> +        .init = acpi_gicv3_preinit,
> +ACPI_DEVICE_END
> +#endif
> +
>  /*
>   * Local variables:
>   * mode: C
> -- 
> 2.1.0
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
> 

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

* [PATCH v3 12/62] ACPICA: ACPI 6.0: Add changes for FADT table
  2015-11-24 11:29   ` Jan Beulich
  2015-11-25  1:45     ` Shannon Zhao
@ 2015-11-25  1:45     ` Shannon Zhao
  1 sibling, 0 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-11-25  1:45 UTC (permalink / raw)
  To: linux-arm-kernel



On 2015/11/24 19:29, Jan Beulich wrote:
>>>> On 17.11.15 at 10:40, <shannon.zhao@linaro.org> wrote:
>> From: Bob Moore <robert.moore@intel.com>
>>
>> ACPICA commit 72b0b6741990f619f6aaa915302836b7cbb41ac4
>>
>> One new 64-bit field at the end of the table.
>> FADT version is now 6.
>>
>> Link: https://github.com/acpica/acpica/commit/72b0b674 
>> Signed-off-by: Bob Moore <robert.moore@intel.com>
>> Signed-off-by: Lv Zheng <lv.zheng@intel.com>
>> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>> [Linux commit aeb823bbacc2a3aaee29eda5875b58a049fa1f78]
>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> ---
>>  xen/include/acpi/actbl.h | 17 ++++++++++-------
>>  1 file changed, 10 insertions(+), 7 deletions(-)
> 
> So while I applied this one after fixing it up, I'm not going to do any
> further fixups to later patches I also meant to apply. I realize the
> fixups may have been necessary because of me applying them in
> other than the submitted sequence, but then again such general
> imports from ACPICA/Linux should have been independent of
> earlier changes. I.e. either earlier patches in the series wrongly
> touch these headers, or there's a general problem with the series.
> 
I will split this patch set in several parts and the first part would be
the changes and updates of ACPI SPEC 5.0~6.0. So maybe you could apply
them at next version.

Thanks,
-- 
Shannon

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

* Re: [PATCH v3 12/62] ACPICA: ACPI 6.0: Add changes for FADT table
  2015-11-24 11:29   ` Jan Beulich
@ 2015-11-25  1:45     ` Shannon Zhao
  2015-11-25  1:45     ` Shannon Zhao
  1 sibling, 0 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-11-25  1:45 UTC (permalink / raw)
  To: Jan Beulich, shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, linux-arm-kernel,
	ard.biesheuvel, andrew.cooper3, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, david.vrabel, christoffer.dall,
	roger.pau



On 2015/11/24 19:29, Jan Beulich wrote:
>>>> On 17.11.15 at 10:40, <shannon.zhao@linaro.org> wrote:
>> From: Bob Moore <robert.moore@intel.com>
>>
>> ACPICA commit 72b0b6741990f619f6aaa915302836b7cbb41ac4
>>
>> One new 64-bit field at the end of the table.
>> FADT version is now 6.
>>
>> Link: https://github.com/acpica/acpica/commit/72b0b674 
>> Signed-off-by: Bob Moore <robert.moore@intel.com>
>> Signed-off-by: Lv Zheng <lv.zheng@intel.com>
>> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>> [Linux commit aeb823bbacc2a3aaee29eda5875b58a049fa1f78]
>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> ---
>>  xen/include/acpi/actbl.h | 17 ++++++++++-------
>>  1 file changed, 10 insertions(+), 7 deletions(-)
> 
> So while I applied this one after fixing it up, I'm not going to do any
> further fixups to later patches I also meant to apply. I realize the
> fixups may have been necessary because of me applying them in
> other than the submitted sequence, but then again such general
> imports from ACPICA/Linux should have been independent of
> earlier changes. I.e. either earlier patches in the series wrongly
> touch these headers, or there's a general problem with the series.
> 
I will split this patch set in several parts and the first part would be
the changes and updates of ACPI SPEC 5.0~6.0. So maybe you could apply
them at next version.

Thanks,
-- 
Shannon

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

* [PATCH v3 28/62] arm/gic: Add ACPI support for GIC preinit
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-26 12:10   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-26 12:10 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Since ACPI 6.0 defines that GIC Distributor Structure contains the GIC
> version filed, it could get GIC version from that. According to the
> version, call different preinit functions.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/gic.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++----
>  1 file changed, 51 insertions(+), 4 deletions(-)
> 
> diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c
> index 1e1e5ba..ac82588 100644
> --- a/xen/arch/arm/gic.c
> +++ b/xen/arch/arm/gic.c
> @@ -27,6 +27,7 @@
>  #include <xen/softirq.h>
>  #include <xen/list.h>
>  #include <xen/device_tree.h>
> +#include <xen/acpi.h>
>  #include <asm/p2m.h>
>  #include <asm/domain.h>
>  #include <asm/platform.h>
> @@ -34,6 +35,7 @@
>  #include <asm/io.h>
>  #include <asm/gic.h>
>  #include <asm/vgic.h>
> +#include <asm/acpi.h>
>  
>  static void gic_restore_pending_irqs(struct vcpu *v);
>  
> @@ -228,10 +230,7 @@ int gic_irq_xlate(const u32 *intspec, unsigned int intsize,
>      return 0;
>  }
>  
> -/* Find the interrupt controller and set up the callback to translate
> - * device tree IRQ.
> - */
> -void __init gic_preinit(void)
> +void __init dt_gic_preinit(void)
>  {
>      int rc;
>      struct dt_device_node *node;
> @@ -261,6 +260,54 @@ void __init gic_preinit(void)
>      dt_device_set_used_by(node, DOMID_XEN);
>  }
>  
> +#ifdef CONFIG_ACPI
> +static void __init acpi_gic_preinit(void)
> +{
> +    int rc = 0;
> +    acpi_status status;
> +    struct acpi_table_header *table;
> +    struct acpi_subtable_header * subtable;
> +    struct acpi_madt_generic_distributor *dist;
> +
> +    status = acpi_get_table(ACPI_SIG_MADT, 0, &table);
> +    if ( ACPI_FAILURE(status) )
> +    {
> +        const char *msg = acpi_format_exception(status);
> +
> +        panic("Failed to get MADT table, %s", msg);
> +    }
> +
> +    subtable = acpi_get_entry(ACPI_SIG_MADT, sizeof(struct acpi_table_madt),
> +                              table, ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR, 0);
> +    if ( !subtable )
> +        panic("No valid GICD entries exists");
> +
> +    dist = (struct acpi_madt_generic_distributor *)subtable;
> +
> +    if ( dist->version == ACPI_MADT_GIC_VERSION_V2 )
> +        rc = acpi_device_init(DEVICE_GIC, NULL, GIC_V2);
> +    else if ( dist->version == ACPI_MADT_GIC_VERSION_V3 )
> +        rc = acpi_device_init(DEVICE_GIC, NULL, GIC_V3);

I agree with your suggestion and Julien's previous comment. Something like:

ACPI_DEVICE_START(agicv2, "GICv2", DEVICE_GIC)
        .class_type = ACPI_MADT_GIC_VERSION_V2,
        .init = acpi_gicv2_preinit,
ACPI_DEVICE_END

would be better.


> +    else
> +        panic("Wrong GIC version or unsupported GIC");
> +    if ( rc )
> +        panic("Unable to find compatible GIC in the ACPI table");
> +}
> +#else
> +static void __init acpi_gic_preinit(void) {}
> +#endif
> +
> +/* Find the interrupt controller and set up the callback to translate
> + * device tree IRQ.
> + */
> +void __init gic_preinit(void)
> +{
> +    if( acpi_disabled )

coding style


> +        dt_gic_preinit();
> +    else
> +        acpi_gic_preinit();
> +}
> +
>  /* Set up the GIC */
>  void __init gic_init(void)
>  {
> -- 
> 2.1.0
> 

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

* Re: [PATCH v3 28/62] arm/gic: Add ACPI support for GIC preinit
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-26 12:10   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-26 12:10 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, linux-arm-kernel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, david.vrabel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Since ACPI 6.0 defines that GIC Distributor Structure contains the GIC
> version filed, it could get GIC version from that. According to the
> version, call different preinit functions.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/gic.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++----
>  1 file changed, 51 insertions(+), 4 deletions(-)
> 
> diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c
> index 1e1e5ba..ac82588 100644
> --- a/xen/arch/arm/gic.c
> +++ b/xen/arch/arm/gic.c
> @@ -27,6 +27,7 @@
>  #include <xen/softirq.h>
>  #include <xen/list.h>
>  #include <xen/device_tree.h>
> +#include <xen/acpi.h>
>  #include <asm/p2m.h>
>  #include <asm/domain.h>
>  #include <asm/platform.h>
> @@ -34,6 +35,7 @@
>  #include <asm/io.h>
>  #include <asm/gic.h>
>  #include <asm/vgic.h>
> +#include <asm/acpi.h>
>  
>  static void gic_restore_pending_irqs(struct vcpu *v);
>  
> @@ -228,10 +230,7 @@ int gic_irq_xlate(const u32 *intspec, unsigned int intsize,
>      return 0;
>  }
>  
> -/* Find the interrupt controller and set up the callback to translate
> - * device tree IRQ.
> - */
> -void __init gic_preinit(void)
> +void __init dt_gic_preinit(void)
>  {
>      int rc;
>      struct dt_device_node *node;
> @@ -261,6 +260,54 @@ void __init gic_preinit(void)
>      dt_device_set_used_by(node, DOMID_XEN);
>  }
>  
> +#ifdef CONFIG_ACPI
> +static void __init acpi_gic_preinit(void)
> +{
> +    int rc = 0;
> +    acpi_status status;
> +    struct acpi_table_header *table;
> +    struct acpi_subtable_header * subtable;
> +    struct acpi_madt_generic_distributor *dist;
> +
> +    status = acpi_get_table(ACPI_SIG_MADT, 0, &table);
> +    if ( ACPI_FAILURE(status) )
> +    {
> +        const char *msg = acpi_format_exception(status);
> +
> +        panic("Failed to get MADT table, %s", msg);
> +    }
> +
> +    subtable = acpi_get_entry(ACPI_SIG_MADT, sizeof(struct acpi_table_madt),
> +                              table, ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR, 0);
> +    if ( !subtable )
> +        panic("No valid GICD entries exists");
> +
> +    dist = (struct acpi_madt_generic_distributor *)subtable;
> +
> +    if ( dist->version == ACPI_MADT_GIC_VERSION_V2 )
> +        rc = acpi_device_init(DEVICE_GIC, NULL, GIC_V2);
> +    else if ( dist->version == ACPI_MADT_GIC_VERSION_V3 )
> +        rc = acpi_device_init(DEVICE_GIC, NULL, GIC_V3);

I agree with your suggestion and Julien's previous comment. Something like:

ACPI_DEVICE_START(agicv2, "GICv2", DEVICE_GIC)
        .class_type = ACPI_MADT_GIC_VERSION_V2,
        .init = acpi_gicv2_preinit,
ACPI_DEVICE_END

would be better.


> +    else
> +        panic("Wrong GIC version or unsupported GIC");
> +    if ( rc )
> +        panic("Unable to find compatible GIC in the ACPI table");
> +}
> +#else
> +static void __init acpi_gic_preinit(void) {}
> +#endif
> +
> +/* Find the interrupt controller and set up the callback to translate
> + * device tree IRQ.
> + */
> +void __init gic_preinit(void)
> +{
> +    if( acpi_disabled )

coding style


> +        dt_gic_preinit();
> +    else
> +        acpi_gic_preinit();
> +}
> +
>  /* Set up the GIC */
>  void __init gic_init(void)
>  {
> -- 
> 2.1.0
> 

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

* [Xen-devel] [PATCH v3 29/62] arm/acpi: Add GTDT support updated by ACPI 5.1
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-26 12:14   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-26 12:14 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> From: Parth Dixit <parth.dixit@linaro.org>
> 
> With ACPI 5.0, we got per-processor timer support in GTDT,
> and ACPI 5.1 introduced the support for platform (memory-mapped)
> timers: GT Block and SBSA watchdog timer, add the code needed
> for the spec change.
> 
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> 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>

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


>  xen/include/acpi/actbl3.h  | 98 +++++++++++++++++++++++++++++++++++++++-------
>  xen/include/asm-arm/acpi.h |  2 +
>  2 files changed, 85 insertions(+), 15 deletions(-)
> 
> diff --git a/xen/include/acpi/actbl3.h b/xen/include/acpi/actbl3.h
> index 8c61b5f..fc96963 100644
> --- a/xen/include/acpi/actbl3.h
> +++ b/xen/include/acpi/actbl3.h
> @@ -241,33 +241,101 @@ struct acpi_s3pt_suspend {
>  
>  /*******************************************************************************
>   *
> - * GTDT - Generic Timer Description Table (ACPI 5.0)
> - *        Version 1
> + * GTDT - Generic Timer Description Table (ACPI 5.1)
> + *        Version 2
>   *
>   ******************************************************************************/
>  
>  struct acpi_table_gtdt {
>  	struct acpi_table_header header;	/* Common ACPI table header */
> -	u64 address;
> -	u32 flags;
> -	u32 secure_pl1_interrupt;
> -	u32 secure_pl1_flags;
> -	u32 non_secure_pl1_interrupt;
> -	u32 non_secure_pl1_flags;
> +	u64 counter_block_addresss;
> +	u32 reserved;
> +	u32 secure_el1_interrupt;
> +	u32 secure_el1_flags;
> +	u32 non_secure_el1_interrupt;
> +	u32 non_secure_el1_flags;
>  	u32 virtual_timer_interrupt;
>  	u32 virtual_timer_flags;
> -	u32 non_secure_pl2_interrupt;
> -	u32 non_secure_pl2_flags;
> +	u32 non_secure_el2_interrupt;
> +	u32 non_secure_el2_flags;
> +	u64 counter_read_block_address;
> +	u32 platform_timer_count;
> +	u32 platform_timer_offset;
>  };
>  
> -/* Values for Flags field above */
> +/* Flag Definitions: Timer Block Physical Timers and Virtual timers */
> +
> +#define ACPI_GTDT_INTERRUPT_MODE        (1)
> +#define ACPI_GTDT_INTERRUPT_POLARITY    (1<<1)
> +#define ACPI_GTDT_ALWAYS_ON             (1<<2)
> +
> +/* Common GTDT subtable header */
> +
> +struct acpi_gtdt_header {
> +	u8 type;
> +	u16 length;
> +};
> +
> +/* Values for GTDT subtable type above */
> +
> +enum acpi_gtdt_type {
> +	ACPI_GTDT_TYPE_TIMER_BLOCK = 0,
> +	ACPI_GTDT_TYPE_WATCHDOG = 1,
> +	ACPI_GTDT_TYPE_RESERVED = 2	/* 2 and greater are reserved */
> +};
> +
> +/* GTDT Subtables, correspond to Type in struct acpi_gtdt_header */
>  
> -#define ACPI_GTDT_MAPPED_BLOCK_PRESENT      1
> +/* 0: Generic Timer Block */
> +
> +struct acpi_gtdt_timer_block {
> +	struct acpi_gtdt_header header;
> +	u8 reserved;
> +	u64 block_address;
> +	u32 timer_count;
> +	u32 timer_offset;
> +};
> +
> +/* Timer Sub-Structure, one per timer */
> +
> +struct acpi_gtdt_timer_entry {
> +	u8 frame_number;
> +	u8 reserved[3];
> +	u64 base_address;
> +	u64 el0_base_address;
> +	u32 timer_interrupt;
> +	u32 timer_flags;
> +	u32 virtual_timer_interrupt;
> +	u32 virtual_timer_flags;
> +	u32 common_flags;
> +};
> +
> +/* Flag Definitions: timer_flags and virtual_timer_flags above */
> +
> +#define ACPI_GTDT_GT_IRQ_MODE               (1)
> +#define ACPI_GTDT_GT_IRQ_POLARITY           (1<<1)
> +
> +/* Flag Definitions: common_flags above */
> +
> +#define ACPI_GTDT_GT_IS_SECURE_TIMER        (1)
> +#define ACPI_GTDT_GT_ALWAYS_ON              (1<<1)
> +
> +/* 1: SBSA Generic Watchdog Structure */
> +
> +struct acpi_gtdt_watchdog {
> +	struct acpi_gtdt_header header;
> +	u8 reserved;
> +	u64 refresh_frame_address;
> +	u64 control_frame_address;
> +	u32 timer_interrupt;
> +	u32 timer_flags;
> +};
>  
> -/* Values for all "TimerFlags" fields above */
> +/* Flag Definitions: timer_flags above */
>  
> -#define ACPI_GTDT_INTERRUPT_MODE            1
> -#define ACPI_GTDT_INTERRUPT_POLARITY        2
> +#define ACPI_GTDT_WATCHDOG_IRQ_MODE         (1)
> +#define ACPI_GTDT_WATCHDOG_IRQ_POLARITY     (1<<1)
> +#define ACPI_GTDT_WATCHDOG_SECURE           (1<<2)
>  
>  /*******************************************************************************
>   *
> diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
> index 1efa29d..714e596 100644
> --- a/xen/include/asm-arm/acpi.h
> +++ b/xen/include/asm-arm/acpi.h
> @@ -46,4 +46,6 @@ static inline void disable_acpi(void)
>      acpi_disabled = 1;
>  }
>  
> +#define ACPI_GTDT_INTR_MASK ( ACPI_GTDT_INTERRUPT_MODE | ACPI_GTDT_INTERRUPT_POLARITY )
> +
>  #endif /*_ASM_ARM_ACPI_H*/
> -- 
> 2.1.0
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel at lists.xen.org
> http://lists.xen.org/xen-devel
> 

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

* Re: [PATCH v3 29/62] arm/acpi: Add GTDT support updated by ACPI 5.1
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-26 12:14   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-26 12:14 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, david.vrabel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> From: Parth Dixit <parth.dixit@linaro.org>
> 
> With ACPI 5.0, we got per-processor timer support in GTDT,
> and ACPI 5.1 introduced the support for platform (memory-mapped)
> timers: GT Block and SBSA watchdog timer, add the code needed
> for the spec change.
> 
> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
> 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>

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


>  xen/include/acpi/actbl3.h  | 98 +++++++++++++++++++++++++++++++++++++++-------
>  xen/include/asm-arm/acpi.h |  2 +
>  2 files changed, 85 insertions(+), 15 deletions(-)
> 
> diff --git a/xen/include/acpi/actbl3.h b/xen/include/acpi/actbl3.h
> index 8c61b5f..fc96963 100644
> --- a/xen/include/acpi/actbl3.h
> +++ b/xen/include/acpi/actbl3.h
> @@ -241,33 +241,101 @@ struct acpi_s3pt_suspend {
>  
>  /*******************************************************************************
>   *
> - * GTDT - Generic Timer Description Table (ACPI 5.0)
> - *        Version 1
> + * GTDT - Generic Timer Description Table (ACPI 5.1)
> + *        Version 2
>   *
>   ******************************************************************************/
>  
>  struct acpi_table_gtdt {
>  	struct acpi_table_header header;	/* Common ACPI table header */
> -	u64 address;
> -	u32 flags;
> -	u32 secure_pl1_interrupt;
> -	u32 secure_pl1_flags;
> -	u32 non_secure_pl1_interrupt;
> -	u32 non_secure_pl1_flags;
> +	u64 counter_block_addresss;
> +	u32 reserved;
> +	u32 secure_el1_interrupt;
> +	u32 secure_el1_flags;
> +	u32 non_secure_el1_interrupt;
> +	u32 non_secure_el1_flags;
>  	u32 virtual_timer_interrupt;
>  	u32 virtual_timer_flags;
> -	u32 non_secure_pl2_interrupt;
> -	u32 non_secure_pl2_flags;
> +	u32 non_secure_el2_interrupt;
> +	u32 non_secure_el2_flags;
> +	u64 counter_read_block_address;
> +	u32 platform_timer_count;
> +	u32 platform_timer_offset;
>  };
>  
> -/* Values for Flags field above */
> +/* Flag Definitions: Timer Block Physical Timers and Virtual timers */
> +
> +#define ACPI_GTDT_INTERRUPT_MODE        (1)
> +#define ACPI_GTDT_INTERRUPT_POLARITY    (1<<1)
> +#define ACPI_GTDT_ALWAYS_ON             (1<<2)
> +
> +/* Common GTDT subtable header */
> +
> +struct acpi_gtdt_header {
> +	u8 type;
> +	u16 length;
> +};
> +
> +/* Values for GTDT subtable type above */
> +
> +enum acpi_gtdt_type {
> +	ACPI_GTDT_TYPE_TIMER_BLOCK = 0,
> +	ACPI_GTDT_TYPE_WATCHDOG = 1,
> +	ACPI_GTDT_TYPE_RESERVED = 2	/* 2 and greater are reserved */
> +};
> +
> +/* GTDT Subtables, correspond to Type in struct acpi_gtdt_header */
>  
> -#define ACPI_GTDT_MAPPED_BLOCK_PRESENT      1
> +/* 0: Generic Timer Block */
> +
> +struct acpi_gtdt_timer_block {
> +	struct acpi_gtdt_header header;
> +	u8 reserved;
> +	u64 block_address;
> +	u32 timer_count;
> +	u32 timer_offset;
> +};
> +
> +/* Timer Sub-Structure, one per timer */
> +
> +struct acpi_gtdt_timer_entry {
> +	u8 frame_number;
> +	u8 reserved[3];
> +	u64 base_address;
> +	u64 el0_base_address;
> +	u32 timer_interrupt;
> +	u32 timer_flags;
> +	u32 virtual_timer_interrupt;
> +	u32 virtual_timer_flags;
> +	u32 common_flags;
> +};
> +
> +/* Flag Definitions: timer_flags and virtual_timer_flags above */
> +
> +#define ACPI_GTDT_GT_IRQ_MODE               (1)
> +#define ACPI_GTDT_GT_IRQ_POLARITY           (1<<1)
> +
> +/* Flag Definitions: common_flags above */
> +
> +#define ACPI_GTDT_GT_IS_SECURE_TIMER        (1)
> +#define ACPI_GTDT_GT_ALWAYS_ON              (1<<1)
> +
> +/* 1: SBSA Generic Watchdog Structure */
> +
> +struct acpi_gtdt_watchdog {
> +	struct acpi_gtdt_header header;
> +	u8 reserved;
> +	u64 refresh_frame_address;
> +	u64 control_frame_address;
> +	u32 timer_interrupt;
> +	u32 timer_flags;
> +};
>  
> -/* Values for all "TimerFlags" fields above */
> +/* Flag Definitions: timer_flags above */
>  
> -#define ACPI_GTDT_INTERRUPT_MODE            1
> -#define ACPI_GTDT_INTERRUPT_POLARITY        2
> +#define ACPI_GTDT_WATCHDOG_IRQ_MODE         (1)
> +#define ACPI_GTDT_WATCHDOG_IRQ_POLARITY     (1<<1)
> +#define ACPI_GTDT_WATCHDOG_SECURE           (1<<2)
>  
>  /*******************************************************************************
>   *
> diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
> index 1efa29d..714e596 100644
> --- a/xen/include/asm-arm/acpi.h
> +++ b/xen/include/asm-arm/acpi.h
> @@ -46,4 +46,6 @@ static inline void disable_acpi(void)
>      acpi_disabled = 1;
>  }
>  
> +#define ACPI_GTDT_INTR_MASK ( ACPI_GTDT_INTERRUPT_MODE | ACPI_GTDT_INTERRUPT_POLARITY )
> +
>  #endif /*_ASM_ARM_ACPI_H*/
> -- 
> 2.1.0
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
> 

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

* [PATCH v3 30/62] arm/irq: Add helper function for setting interrupt type
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-26 12:20   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-26 12:20 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> From: Parth Dixit <parth.dixit@linaro.org>
> 
> Add a helper function to set edge/level type information for an
> interrupt.
> 
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/irq.c        | 22 +++++++++++++++-------
>  xen/include/asm-arm/irq.h |  2 ++
>  2 files changed, 17 insertions(+), 7 deletions(-)
> 
> diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c
> index 1f38605..90b6e58 100644
> --- a/xen/arch/arm/irq.c
> +++ b/xen/arch/arm/irq.c
> @@ -655,6 +655,19 @@ unlock:
>      return ret;
>  }
>  
> +int irq_set_type(unsigned int irq, unsigned int type)
> +{
> +    int res;
> +
> +    /* Setup the IRQ type */
> +    if ( irq < NR_LOCAL_IRQS )
> +        res = irq_local_set_type(irq, type);
> +    else
> +        res = irq_set_spi_type(irq, type);
> +
> +    return res;
> +}
> +
>  int platform_get_irq(const struct dt_device_node *device, int index)
>  {
>      struct dt_irq dt_irq;
> @@ -668,14 +681,9 @@ int platform_get_irq(const struct dt_device_node *device, int index)
>      irq = dt_irq.irq;
>      type = dt_irq.type;
>  
> -    /* Setup the IRQ type */
> -    if ( irq < NR_LOCAL_IRQS )
> -        res = irq_local_set_type(irq, type);
> -    else
> -        res = irq_set_spi_type(irq, type);
> -
> +    res = irq_set_type(irq, type);
>      if ( res )
> -            return -1;
> +        return -1;

I would just as well do:

if ( irq_set_type(irq, type) )
    return -1;

and remove res.

In any case:

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


>      return irq;
>  }
> diff --git a/xen/include/asm-arm/irq.h b/xen/include/asm-arm/irq.h
> index f33c331..493773c 100644
> --- a/xen/include/asm-arm/irq.h
> +++ b/xen/include/asm-arm/irq.h
> @@ -52,6 +52,8 @@ void arch_move_irqs(struct vcpu *v);
>  /* Set IRQ type for an SPI */
>  int irq_set_spi_type(unsigned int spi, unsigned int type);
>  
> +int irq_set_type(unsigned int irq, unsigned int type);
> +
>  int platform_get_irq(const struct dt_device_node *device, int index);
>  
>  void irq_set_affinity(struct irq_desc *desc, const cpumask_t *cpu_mask);
> -- 
> 2.1.0
> 

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

* Re: [PATCH v3 30/62] arm/irq: Add helper function for setting interrupt type
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-26 12:20   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-26 12:20 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, linux-arm-kernel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, david.vrabel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> From: Parth Dixit <parth.dixit@linaro.org>
> 
> Add a helper function to set edge/level type information for an
> interrupt.
> 
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/irq.c        | 22 +++++++++++++++-------
>  xen/include/asm-arm/irq.h |  2 ++
>  2 files changed, 17 insertions(+), 7 deletions(-)
> 
> diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c
> index 1f38605..90b6e58 100644
> --- a/xen/arch/arm/irq.c
> +++ b/xen/arch/arm/irq.c
> @@ -655,6 +655,19 @@ unlock:
>      return ret;
>  }
>  
> +int irq_set_type(unsigned int irq, unsigned int type)
> +{
> +    int res;
> +
> +    /* Setup the IRQ type */
> +    if ( irq < NR_LOCAL_IRQS )
> +        res = irq_local_set_type(irq, type);
> +    else
> +        res = irq_set_spi_type(irq, type);
> +
> +    return res;
> +}
> +
>  int platform_get_irq(const struct dt_device_node *device, int index)
>  {
>      struct dt_irq dt_irq;
> @@ -668,14 +681,9 @@ int platform_get_irq(const struct dt_device_node *device, int index)
>      irq = dt_irq.irq;
>      type = dt_irq.type;
>  
> -    /* Setup the IRQ type */
> -    if ( irq < NR_LOCAL_IRQS )
> -        res = irq_local_set_type(irq, type);
> -    else
> -        res = irq_set_spi_type(irq, type);
> -
> +    res = irq_set_type(irq, type);
>      if ( res )
> -            return -1;
> +        return -1;

I would just as well do:

if ( irq_set_type(irq, type) )
    return -1;

and remove res.

In any case:

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


>      return irq;
>  }
> diff --git a/xen/include/asm-arm/irq.h b/xen/include/asm-arm/irq.h
> index f33c331..493773c 100644
> --- a/xen/include/asm-arm/irq.h
> +++ b/xen/include/asm-arm/irq.h
> @@ -52,6 +52,8 @@ void arch_move_irqs(struct vcpu *v);
>  /* Set IRQ type for an SPI */
>  int irq_set_spi_type(unsigned int spi, unsigned int type);
>  
> +int irq_set_type(unsigned int irq, unsigned int type);
> +
>  int platform_get_irq(const struct dt_device_node *device, int index);
>  
>  void irq_set_affinity(struct irq_desc *desc, const cpumask_t *cpu_mask);
> -- 
> 2.1.0
> 

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

* [Xen-devel] [PATCH v3 31/62] arm/acpi: Add a helper function to get interrupt type
  2015-11-17  9:40   ` shannon.zhao
                     ` (2 preceding siblings ...)
  (?)
@ 2015-11-26 12:33   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-26 12:33 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Add a helper funtion to get the type of interrupts in ACPI table.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/acpi/lib.c    | 27 +++++++++++++++++++++++++++
>  xen/include/asm-arm/acpi.h | 39 +++++++++++++++++++++++++++++++++++++++
>  2 files changed, 66 insertions(+)
> 
> diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c
> index d8b7635..47f4c6a 100644
> --- a/xen/arch/arm/acpi/lib.c
> +++ b/xen/arch/arm/acpi/lib.c
> @@ -43,3 +43,30 @@ bool_t __init acpi_psci_hvc_present(void)
>  {
>      return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_USE_HVC;
>  }
> +
> +unsigned int acpi_get_irq_type(u32 flags)
> +{
> +    int trigger, polarity;
> +
> +    trigger = (flags & ACPI_GTDT_INTERRUPT_MODE) ? ACPI_EDGE_SENSITIVE

                         ^ GTDT? This is not specific to the GTDT table, right?


> +               : ACPI_LEVEL_SENSITIVE;
> +
> +    polarity = (flags & ACPI_GTDT_INTERRUPT_POLARITY) ? ACPI_ACTIVE_LOW

same here


> +                : ACPI_ACTIVE_HIGH;
> +
> +    switch (polarity) {
> +    case ACPI_ACTIVE_LOW:
> +        return trigger == ACPI_EDGE_SENSITIVE ?
> +            ACPI_IRQ_TYPE_EDGE_FALLING :
> +            ACPI_IRQ_TYPE_LEVEL_LOW;
> +    case ACPI_ACTIVE_HIGH:
> +        return trigger == ACPI_EDGE_SENSITIVE ?
> +            ACPI_IRQ_TYPE_EDGE_RISING :
> +            ACPI_IRQ_TYPE_LEVEL_HIGH;
> +    case ACPI_ACTIVE_BOTH:
> +        if (trigger == ACPI_EDGE_SENSITIVE)
> +            return ACPI_IRQ_TYPE_EDGE_BOTH;
> +    default:
> +        return ACPI_IRQ_TYPE_NONE;
> +    }
> +}
> diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
> index 714e596..214fc4e 100644
> --- a/xen/include/asm-arm/acpi.h
> +++ b/xen/include/asm-arm/acpi.h
> @@ -34,10 +34,12 @@ extern bool_t acpi_disabled;
>  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_irq_type(u32 flags);
>  #else
>  static inline bool_t acpi_psci_present(void) { return false; }
>  static inline bool_t acpi_psci_hvc_present(void) {return false; }
>  static inline void acpi_smp_init_cpus(void) { }
> +static inline unsigned int acpi_get_irq_type(u32 flags) { return 0; }
>  #endif /* CONFIG_ACPI */
>  
>  /* Basic configuration for ACPI */
> @@ -48,4 +50,41 @@ static inline void disable_acpi(void)
>  
>  #define ACPI_GTDT_INTR_MASK ( ACPI_GTDT_INTERRUPT_MODE | ACPI_GTDT_INTERRUPT_POLARITY )
>  
> +/* Triggering */
> +
> +#define ACPI_LEVEL_SENSITIVE            (u8) 0x00
> +#define ACPI_EDGE_SENSITIVE             (u8) 0x01
> +
> +/* Polarity */
> +
> +#define ACPI_ACTIVE_HIGH                (u8) 0x00
> +#define ACPI_ACTIVE_LOW                 (u8) 0x01
> +#define ACPI_ACTIVE_BOTH                (u8) 0x02
> +
> +/**
> + * IRQ line type.
> + *
> + * ACPI_IRQ_TYPE_NONE            - default, unspecified type
> + * ACPI_IRQ_TYPE_EDGE_RISING     - rising edge triggered
> + * ACPI_IRQ_TYPE_EDGE_FALLING    - falling edge triggered
> + * ACPI_IRQ_TYPE_EDGE_BOTH       - rising and falling edge triggered
> + * ACPI_IRQ_TYPE_LEVEL_HIGH      - high level triggered
> + * ACPI_IRQ_TYPE_LEVEL_LOW       - low level triggered
> + * ACPI_IRQ_TYPE_LEVEL_MASK      - Mask to filter out the level bits
> + * ACPI_IRQ_TYPE_SENSE_MASK      - Mask for all the above bits
> + * ACPI_IRQ_TYPE_INVALID         - Use to initialize the type
> + */
> +#define ACPI_IRQ_TYPE_NONE           0x00000000
> +#define ACPI_IRQ_TYPE_EDGE_RISING    0x00000001
> +#define ACPI_IRQ_TYPE_EDGE_FALLING   0x00000002
> +#define ACPI_IRQ_TYPE_EDGE_BOTH                           \
> +    (ACPI_IRQ_TYPE_EDGE_FALLING | ACPI_IRQ_TYPE_EDGE_RISING)
> +#define ACPI_IRQ_TYPE_LEVEL_HIGH     0x00000004
> +#define ACPI_IRQ_TYPE_LEVEL_LOW      0x00000008
> +#define ACPI_IRQ_TYPE_LEVEL_MASK                          \
> +    (ACPI_IRQ_TYPE_LEVEL_LOW | ACPI_IRQ_TYPE_LEVEL_HIGH)
> +#define ACPI_IRQ_TYPE_SENSE_MASK     0x0000000f
> +
> +#define ACPI_IRQ_TYPE_INVALID        0x00000010

Given that these are actually physical irq properties, they don't really
depend on ACPI or DT, in fact I believe these are taken from the device
tree definitions and renamed.

Instead of duplicating the irq types, I would make the device tree irq
types generic.

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

* Re: [PATCH v3 31/62] arm/acpi: Add a helper function to get interrupt type
  2015-11-17  9:40   ` shannon.zhao
                     ` (3 preceding siblings ...)
  (?)
@ 2015-11-26 12:33   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-26 12:33 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, david.vrabel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Add a helper funtion to get the type of interrupts in ACPI table.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/acpi/lib.c    | 27 +++++++++++++++++++++++++++
>  xen/include/asm-arm/acpi.h | 39 +++++++++++++++++++++++++++++++++++++++
>  2 files changed, 66 insertions(+)
> 
> diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c
> index d8b7635..47f4c6a 100644
> --- a/xen/arch/arm/acpi/lib.c
> +++ b/xen/arch/arm/acpi/lib.c
> @@ -43,3 +43,30 @@ bool_t __init acpi_psci_hvc_present(void)
>  {
>      return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_USE_HVC;
>  }
> +
> +unsigned int acpi_get_irq_type(u32 flags)
> +{
> +    int trigger, polarity;
> +
> +    trigger = (flags & ACPI_GTDT_INTERRUPT_MODE) ? ACPI_EDGE_SENSITIVE

                         ^ GTDT? This is not specific to the GTDT table, right?


> +               : ACPI_LEVEL_SENSITIVE;
> +
> +    polarity = (flags & ACPI_GTDT_INTERRUPT_POLARITY) ? ACPI_ACTIVE_LOW

same here


> +                : ACPI_ACTIVE_HIGH;
> +
> +    switch (polarity) {
> +    case ACPI_ACTIVE_LOW:
> +        return trigger == ACPI_EDGE_SENSITIVE ?
> +            ACPI_IRQ_TYPE_EDGE_FALLING :
> +            ACPI_IRQ_TYPE_LEVEL_LOW;
> +    case ACPI_ACTIVE_HIGH:
> +        return trigger == ACPI_EDGE_SENSITIVE ?
> +            ACPI_IRQ_TYPE_EDGE_RISING :
> +            ACPI_IRQ_TYPE_LEVEL_HIGH;
> +    case ACPI_ACTIVE_BOTH:
> +        if (trigger == ACPI_EDGE_SENSITIVE)
> +            return ACPI_IRQ_TYPE_EDGE_BOTH;
> +    default:
> +        return ACPI_IRQ_TYPE_NONE;
> +    }
> +}
> diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
> index 714e596..214fc4e 100644
> --- a/xen/include/asm-arm/acpi.h
> +++ b/xen/include/asm-arm/acpi.h
> @@ -34,10 +34,12 @@ extern bool_t acpi_disabled;
>  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_irq_type(u32 flags);
>  #else
>  static inline bool_t acpi_psci_present(void) { return false; }
>  static inline bool_t acpi_psci_hvc_present(void) {return false; }
>  static inline void acpi_smp_init_cpus(void) { }
> +static inline unsigned int acpi_get_irq_type(u32 flags) { return 0; }
>  #endif /* CONFIG_ACPI */
>  
>  /* Basic configuration for ACPI */
> @@ -48,4 +50,41 @@ static inline void disable_acpi(void)
>  
>  #define ACPI_GTDT_INTR_MASK ( ACPI_GTDT_INTERRUPT_MODE | ACPI_GTDT_INTERRUPT_POLARITY )
>  
> +/* Triggering */
> +
> +#define ACPI_LEVEL_SENSITIVE            (u8) 0x00
> +#define ACPI_EDGE_SENSITIVE             (u8) 0x01
> +
> +/* Polarity */
> +
> +#define ACPI_ACTIVE_HIGH                (u8) 0x00
> +#define ACPI_ACTIVE_LOW                 (u8) 0x01
> +#define ACPI_ACTIVE_BOTH                (u8) 0x02
> +
> +/**
> + * IRQ line type.
> + *
> + * ACPI_IRQ_TYPE_NONE            - default, unspecified type
> + * ACPI_IRQ_TYPE_EDGE_RISING     - rising edge triggered
> + * ACPI_IRQ_TYPE_EDGE_FALLING    - falling edge triggered
> + * ACPI_IRQ_TYPE_EDGE_BOTH       - rising and falling edge triggered
> + * ACPI_IRQ_TYPE_LEVEL_HIGH      - high level triggered
> + * ACPI_IRQ_TYPE_LEVEL_LOW       - low level triggered
> + * ACPI_IRQ_TYPE_LEVEL_MASK      - Mask to filter out the level bits
> + * ACPI_IRQ_TYPE_SENSE_MASK      - Mask for all the above bits
> + * ACPI_IRQ_TYPE_INVALID         - Use to initialize the type
> + */
> +#define ACPI_IRQ_TYPE_NONE           0x00000000
> +#define ACPI_IRQ_TYPE_EDGE_RISING    0x00000001
> +#define ACPI_IRQ_TYPE_EDGE_FALLING   0x00000002
> +#define ACPI_IRQ_TYPE_EDGE_BOTH                           \
> +    (ACPI_IRQ_TYPE_EDGE_FALLING | ACPI_IRQ_TYPE_EDGE_RISING)
> +#define ACPI_IRQ_TYPE_LEVEL_HIGH     0x00000004
> +#define ACPI_IRQ_TYPE_LEVEL_LOW      0x00000008
> +#define ACPI_IRQ_TYPE_LEVEL_MASK                          \
> +    (ACPI_IRQ_TYPE_LEVEL_LOW | ACPI_IRQ_TYPE_LEVEL_HIGH)
> +#define ACPI_IRQ_TYPE_SENSE_MASK     0x0000000f
> +
> +#define ACPI_IRQ_TYPE_INVALID        0x00000010

Given that these are actually physical irq properties, they don't really
depend on ACPI or DT, in fact I believe these are taken from the device
tree definitions and renamed.

Instead of duplicating the irq types, I would make the device tree irq
types generic.

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

* [Xen-devel] [PATCH v3 32/62] arm/acpi: Parse GTDT to initialize timer
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-26 12:54   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-26 12:54 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> From: Parth Dixit <parth.dixit@linaro.org>
> 
> Parse GTDT (Generic Timer Descriptor Table) to initialize timer. Using
> the information presented by GTDT to initialize the arch timer (not
> memory-mapped).
> 
> 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>
> ---
>  xen/arch/arm/time.c | 73 +++++++++++++++++++++++++++++++++++++++++++++--------
>  1 file changed, 62 insertions(+), 11 deletions(-)
> 
> diff --git a/xen/arch/arm/time.c b/xen/arch/arm/time.c
> index 5ded30c..adbfc2a 100644
> --- a/xen/arch/arm/time.c
> +++ b/xen/arch/arm/time.c
> @@ -29,6 +29,7 @@
>  #include <xen/time.h>
>  #include <xen/sched.h>
>  #include <xen/event.h>
> +#include <xen/acpi.h>
>  #include <asm/system.h>
>  #include <asm/time.h>
>  #include <asm/gic.h>
> @@ -65,8 +66,45 @@ unsigned int timer_get_irq(enum timer_ppi ppi)
>  
>  static __initdata struct dt_device_node *timer;
>  
> +#ifdef CONFIG_ACPI
> +/* Initialize per-processor generic timer */
> +static int __init arch_timer_acpi_init(struct acpi_table_header *table)
> +{
> +    unsigned int irq_type;
> +    struct acpi_table_gtdt *gtdt;
> +
> +    gtdt = container_of(table, struct acpi_table_gtdt, header);
> +
> +    /* Initialize all the generic timer IRQ variable from GTDT table */
> +    irq_type = acpi_get_irq_type(gtdt->non_secure_el1_flags);
> +    irq_set_type(gtdt->non_secure_el1_interrupt, irq_type);
> +    timer_irq[TIMER_PHYS_NONSECURE_PPI] = gtdt->non_secure_el1_interrupt;
> +
> +    irq_type = acpi_get_irq_type(gtdt->secure_el1_flags);
> +    irq_set_type(gtdt->secure_el1_interrupt, irq_type);
> +    timer_irq[TIMER_PHYS_SECURE_PPI] = gtdt->secure_el1_interrupt;
> +
> +    irq_type = acpi_get_irq_type(gtdt->virtual_timer_flags);
> +    irq_set_type(gtdt->virtual_timer_interrupt, irq_type);
> +    timer_irq[TIMER_VIRT_PPI] = gtdt->virtual_timer_interrupt;
> +
> +    irq_type = acpi_get_irq_type(gtdt->non_secure_el2_flags);
> +    irq_set_type(gtdt->non_secure_el2_interrupt, irq_type);
> +    timer_irq[TIMER_HYP_PPI] = gtdt->non_secure_el2_interrupt;
> +
> +    return 0;
> +}
> +
> +void __init acpi_preinit_xen_time(void)

static?


> +{
> +	acpi_table_parse(ACPI_SIG_GTDT, arch_timer_acpi_init);
> +}
> +#else
> +static inline void acpi_preinit_xen_time(void) { }
> +#endif
> +
>  /* Set up the timer on the boot CPU (early init function) */
> -void __init preinit_xen_time(void)
> +static void __init dt_preinit_xen_time(void)
>  {
>      static const struct dt_device_match timer_ids[] __initconst =
>      {
> @@ -74,7 +112,6 @@ void __init preinit_xen_time(void)
>          { /* sentinel */ },
>      };
>      int res;
> -    u32 rate;
>  
>      timer = dt_find_matching_node(NULL, timer_ids);
>      if ( !timer )
> @@ -86,8 +123,19 @@ void __init preinit_xen_time(void)
>      if ( res )
>          panic("Timer: Cannot initialize platform timer");

Don't we want to call platform_init_time on ARM too? It doesn't look
like something DT specific. I guess we should move the call to the
generic init function?


> -    res = dt_property_read_u32(timer, "clock-frequency", &rate);
> -    if ( res )

I think we should keep the clock-frequency DT read in
dt_preinit_xen_time.


> +}
> +
> +void __init preinit_xen_time(void)
> +{
> +    u32 rate;
> +
> +    /* Initialize all the generic timers presented in GTDT */
> +    if ( acpi_disabled )
> +        dt_preinit_xen_time();
> +    else
> +        acpi_preinit_xen_time();
> +
> +    if( acpi_disabled && dt_property_read_u32(timer, "clock-frequency", &rate) )
>      {
>          cpu_khz = rate / 1000;
>          timer_dt_clock_frequency = rate;

I don't think we want to read a DT property from a generic
initialization function.


> @@ -104,14 +152,17 @@ int __init init_xen_time(void)
>      int res;
>      unsigned int i;
>  
> -    /* Retrieve all IRQs for the timer */
> -    for ( i = TIMER_PHYS_SECURE_PPI; i < MAX_TIMER_PPI; i++ )
> +    if( acpi_disabled )
>      {
> -        res = platform_get_irq(timer, i);
> -
> -        if ( res < 0 )
> -            panic("Timer: Unable to retrieve IRQ %u from the device tree", i);
> -        timer_irq[i] = res;
> +        /* Retrieve all IRQs for the timer */
> +        for ( i = TIMER_PHYS_SECURE_PPI; i < MAX_TIMER_PPI; i++ )
> +        {
> +            res = platform_get_irq(timer, i);
> +
> +            if ( res < 0 )
> +                panic("Timer: Unable to retrieve IRQ %u from the device tree", i);
> +            timer_irq[i] = res;
> +        }
>      }

Can't be just move this into the DT specific init function?


>  
>      /* Check that this CPU supports the Generic Timer interface */
> -- 
> 2.1.0
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel at lists.xen.org
> http://lists.xen.org/xen-devel
> 

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

* Re: [PATCH v3 32/62] arm/acpi: Parse GTDT to initialize timer
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-26 12:54   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-26 12:54 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, david.vrabel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> From: Parth Dixit <parth.dixit@linaro.org>
> 
> Parse GTDT (Generic Timer Descriptor Table) to initialize timer. Using
> the information presented by GTDT to initialize the arch timer (not
> memory-mapped).
> 
> 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>
> ---
>  xen/arch/arm/time.c | 73 +++++++++++++++++++++++++++++++++++++++++++++--------
>  1 file changed, 62 insertions(+), 11 deletions(-)
> 
> diff --git a/xen/arch/arm/time.c b/xen/arch/arm/time.c
> index 5ded30c..adbfc2a 100644
> --- a/xen/arch/arm/time.c
> +++ b/xen/arch/arm/time.c
> @@ -29,6 +29,7 @@
>  #include <xen/time.h>
>  #include <xen/sched.h>
>  #include <xen/event.h>
> +#include <xen/acpi.h>
>  #include <asm/system.h>
>  #include <asm/time.h>
>  #include <asm/gic.h>
> @@ -65,8 +66,45 @@ unsigned int timer_get_irq(enum timer_ppi ppi)
>  
>  static __initdata struct dt_device_node *timer;
>  
> +#ifdef CONFIG_ACPI
> +/* Initialize per-processor generic timer */
> +static int __init arch_timer_acpi_init(struct acpi_table_header *table)
> +{
> +    unsigned int irq_type;
> +    struct acpi_table_gtdt *gtdt;
> +
> +    gtdt = container_of(table, struct acpi_table_gtdt, header);
> +
> +    /* Initialize all the generic timer IRQ variable from GTDT table */
> +    irq_type = acpi_get_irq_type(gtdt->non_secure_el1_flags);
> +    irq_set_type(gtdt->non_secure_el1_interrupt, irq_type);
> +    timer_irq[TIMER_PHYS_NONSECURE_PPI] = gtdt->non_secure_el1_interrupt;
> +
> +    irq_type = acpi_get_irq_type(gtdt->secure_el1_flags);
> +    irq_set_type(gtdt->secure_el1_interrupt, irq_type);
> +    timer_irq[TIMER_PHYS_SECURE_PPI] = gtdt->secure_el1_interrupt;
> +
> +    irq_type = acpi_get_irq_type(gtdt->virtual_timer_flags);
> +    irq_set_type(gtdt->virtual_timer_interrupt, irq_type);
> +    timer_irq[TIMER_VIRT_PPI] = gtdt->virtual_timer_interrupt;
> +
> +    irq_type = acpi_get_irq_type(gtdt->non_secure_el2_flags);
> +    irq_set_type(gtdt->non_secure_el2_interrupt, irq_type);
> +    timer_irq[TIMER_HYP_PPI] = gtdt->non_secure_el2_interrupt;
> +
> +    return 0;
> +}
> +
> +void __init acpi_preinit_xen_time(void)

static?


> +{
> +	acpi_table_parse(ACPI_SIG_GTDT, arch_timer_acpi_init);
> +}
> +#else
> +static inline void acpi_preinit_xen_time(void) { }
> +#endif
> +
>  /* Set up the timer on the boot CPU (early init function) */
> -void __init preinit_xen_time(void)
> +static void __init dt_preinit_xen_time(void)
>  {
>      static const struct dt_device_match timer_ids[] __initconst =
>      {
> @@ -74,7 +112,6 @@ void __init preinit_xen_time(void)
>          { /* sentinel */ },
>      };
>      int res;
> -    u32 rate;
>  
>      timer = dt_find_matching_node(NULL, timer_ids);
>      if ( !timer )
> @@ -86,8 +123,19 @@ void __init preinit_xen_time(void)
>      if ( res )
>          panic("Timer: Cannot initialize platform timer");

Don't we want to call platform_init_time on ARM too? It doesn't look
like something DT specific. I guess we should move the call to the
generic init function?


> -    res = dt_property_read_u32(timer, "clock-frequency", &rate);
> -    if ( res )

I think we should keep the clock-frequency DT read in
dt_preinit_xen_time.


> +}
> +
> +void __init preinit_xen_time(void)
> +{
> +    u32 rate;
> +
> +    /* Initialize all the generic timers presented in GTDT */
> +    if ( acpi_disabled )
> +        dt_preinit_xen_time();
> +    else
> +        acpi_preinit_xen_time();
> +
> +    if( acpi_disabled && dt_property_read_u32(timer, "clock-frequency", &rate) )
>      {
>          cpu_khz = rate / 1000;
>          timer_dt_clock_frequency = rate;

I don't think we want to read a DT property from a generic
initialization function.


> @@ -104,14 +152,17 @@ int __init init_xen_time(void)
>      int res;
>      unsigned int i;
>  
> -    /* Retrieve all IRQs for the timer */
> -    for ( i = TIMER_PHYS_SECURE_PPI; i < MAX_TIMER_PPI; i++ )
> +    if( acpi_disabled )
>      {
> -        res = platform_get_irq(timer, i);
> -
> -        if ( res < 0 )
> -            panic("Timer: Unable to retrieve IRQ %u from the device tree", i);
> -        timer_irq[i] = res;
> +        /* Retrieve all IRQs for the timer */
> +        for ( i = TIMER_PHYS_SECURE_PPI; i < MAX_TIMER_PPI; i++ )
> +        {
> +            res = platform_get_irq(timer, i);
> +
> +            if ( res < 0 )
> +                panic("Timer: Unable to retrieve IRQ %u from the device tree", i);
> +            timer_irq[i] = res;
> +        }
>      }

Can't be just move this into the DT specific init function?


>  
>      /* Check that this CPU supports the Generic Timer interface */
> -- 
> 2.1.0
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
> 

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

* [PATCH v3 34/62] pl011: Refactor pl011 driver to dt and common initialization parts
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-26 15:22   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-26 15:22 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Refactor pl011 driver to dt and common initialization parts. This will
> be useful later when acpi specific uart initialization function is
> introduced.
> 
> 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/drivers/char/pl011.c | 64 ++++++++++++++++++++++++++++--------------------
>  1 file changed, 38 insertions(+), 26 deletions(-)
> 
> diff --git a/xen/drivers/char/pl011.c b/xen/drivers/char/pl011.c
> index 67e6df5..16abaa5 100644
> --- a/xen/drivers/char/pl011.c
> +++ b/xen/drivers/char/pl011.c
> @@ -226,12 +226,42 @@ static struct uart_driver __read_mostly pl011_driver = {
>      .vuart_info   = pl011_vuart,
>  };
>  
> +static int __init pl011_uart_init(int irq, u64 addr, u64 size)
> +{
> +    struct pl011 *uart;
> +
> +    uart = &pl011_com;
> +    uart->irq       = irq;
> +    uart->clock_hz  = 0x16e3600;
> +    uart->baud      = BAUD_AUTO;
> +    uart->data_bits = 8;
> +    uart->parity    = PARITY_NONE;
> +    uart->stop_bits = 1;
> +
> +    uart->regs = ioremap_nocache(addr, size);
> +    if ( !uart->regs )
> +    {
> +        printk("pl011: Unable to map the UART memory\n");
> +        return -ENOMEM;
> +    }
> +
> +    uart->vuart.base_addr = addr;
> +    uart->vuart.size = size;
> +    uart->vuart.data_off = DR;
> +    uart->vuart.status_off = FR;
> +    uart->vuart.status = 0;
> +
> +    /* Register with generic serial driver. */
> +    serial_register_uart(SERHND_DTUART, &pl011_driver, uart);
> +
> +    return 0;
> +}
> +
>  /* TODO: Parse UART config from the command line */
> -static int __init pl011_uart_init(struct dt_device_node *dev,
> -                                  const void *data)
> +static int __init dt_pl011_uart_init(struct dt_device_node *dev,
> +                                     const void *data)
>  {
>      const char *config = data;
> -    struct pl011 *uart;
>      int res;
>      u64 addr, size;
>  
> @@ -240,14 +270,6 @@ static int __init pl011_uart_init(struct dt_device_node *dev,
>          printk("WARNING: UART configuration is not supported\n");
>      }
>  
> -    uart = &pl011_com;
> -
> -    uart->clock_hz  = 0x16e3600;
> -    uart->baud      = BAUD_AUTO;
> -    uart->data_bits = 8;
> -    uart->parity    = PARITY_NONE;
> -    uart->stop_bits = 1;
> -
>      res = dt_device_get_address(dev, 0, &addr, &size);
>      if ( res )
>      {
> @@ -262,24 +284,14 @@ static int __init pl011_uart_init(struct dt_device_node *dev,
>          printk("pl011: Unable to retrieve the IRQ\n");
>          return -EINVAL;
>      }
> -    uart->irq = res;
>  
> -    uart->regs = ioremap_nocache(addr, size);
> -    if ( !uart->regs )
> +    res = pl011_uart_init(res, addr, size);
> +    if ( res < 0 )
>      {
> -        printk("pl011: Unable to map the UART memory\n");
> -        return -ENOMEM;
> +        printk("pl011: Unable to initialize\n");
> +        return res;
>      }
>  
> -    uart->vuart.base_addr = addr;
> -    uart->vuart.size = size;
> -    uart->vuart.data_off = DR;
> -    uart->vuart.status_off = FR;
> -    uart->vuart.status = 0;
> -
> -    /* Register with generic serial driver. */
> -    serial_register_uart(SERHND_DTUART, &pl011_driver, uart);
> -
>      dt_device_set_used_by(dev, DOMID_XEN);
>  
>      return 0;
> @@ -293,7 +305,7 @@ static const struct dt_device_match pl011_dt_match[] __initconst =
>  
>  DT_DEVICE_START(pl011, "PL011 UART", DEVICE_SERIAL)
>          .dt_match = pl011_dt_match,
> -        .init = pl011_uart_init,
> +        .init = dt_pl011_uart_init,
>  DT_DEVICE_END
>  
>  /*
> -- 
> 2.1.0
> 

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

* Re: [PATCH v3 34/62] pl011: Refactor pl011 driver to dt and common initialization parts
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-26 15:22   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-26 15:22 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, linux-arm-kernel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, david.vrabel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Refactor pl011 driver to dt and common initialization parts. This will
> be useful later when acpi specific uart initialization function is
> introduced.
> 
> 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/drivers/char/pl011.c | 64 ++++++++++++++++++++++++++++--------------------
>  1 file changed, 38 insertions(+), 26 deletions(-)
> 
> diff --git a/xen/drivers/char/pl011.c b/xen/drivers/char/pl011.c
> index 67e6df5..16abaa5 100644
> --- a/xen/drivers/char/pl011.c
> +++ b/xen/drivers/char/pl011.c
> @@ -226,12 +226,42 @@ static struct uart_driver __read_mostly pl011_driver = {
>      .vuart_info   = pl011_vuart,
>  };
>  
> +static int __init pl011_uart_init(int irq, u64 addr, u64 size)
> +{
> +    struct pl011 *uart;
> +
> +    uart = &pl011_com;
> +    uart->irq       = irq;
> +    uart->clock_hz  = 0x16e3600;
> +    uart->baud      = BAUD_AUTO;
> +    uart->data_bits = 8;
> +    uart->parity    = PARITY_NONE;
> +    uart->stop_bits = 1;
> +
> +    uart->regs = ioremap_nocache(addr, size);
> +    if ( !uart->regs )
> +    {
> +        printk("pl011: Unable to map the UART memory\n");
> +        return -ENOMEM;
> +    }
> +
> +    uart->vuart.base_addr = addr;
> +    uart->vuart.size = size;
> +    uart->vuart.data_off = DR;
> +    uart->vuart.status_off = FR;
> +    uart->vuart.status = 0;
> +
> +    /* Register with generic serial driver. */
> +    serial_register_uart(SERHND_DTUART, &pl011_driver, uart);
> +
> +    return 0;
> +}
> +
>  /* TODO: Parse UART config from the command line */
> -static int __init pl011_uart_init(struct dt_device_node *dev,
> -                                  const void *data)
> +static int __init dt_pl011_uart_init(struct dt_device_node *dev,
> +                                     const void *data)
>  {
>      const char *config = data;
> -    struct pl011 *uart;
>      int res;
>      u64 addr, size;
>  
> @@ -240,14 +270,6 @@ static int __init pl011_uart_init(struct dt_device_node *dev,
>          printk("WARNING: UART configuration is not supported\n");
>      }
>  
> -    uart = &pl011_com;
> -
> -    uart->clock_hz  = 0x16e3600;
> -    uart->baud      = BAUD_AUTO;
> -    uart->data_bits = 8;
> -    uart->parity    = PARITY_NONE;
> -    uart->stop_bits = 1;
> -
>      res = dt_device_get_address(dev, 0, &addr, &size);
>      if ( res )
>      {
> @@ -262,24 +284,14 @@ static int __init pl011_uart_init(struct dt_device_node *dev,
>          printk("pl011: Unable to retrieve the IRQ\n");
>          return -EINVAL;
>      }
> -    uart->irq = res;
>  
> -    uart->regs = ioremap_nocache(addr, size);
> -    if ( !uart->regs )
> +    res = pl011_uart_init(res, addr, size);
> +    if ( res < 0 )
>      {
> -        printk("pl011: Unable to map the UART memory\n");
> -        return -ENOMEM;
> +        printk("pl011: Unable to initialize\n");
> +        return res;
>      }
>  
> -    uart->vuart.base_addr = addr;
> -    uart->vuart.size = size;
> -    uart->vuart.data_off = DR;
> -    uart->vuart.status_off = FR;
> -    uart->vuart.status = 0;
> -
> -    /* Register with generic serial driver. */
> -    serial_register_uart(SERHND_DTUART, &pl011_driver, uart);
> -
>      dt_device_set_used_by(dev, DOMID_XEN);
>  
>      return 0;
> @@ -293,7 +305,7 @@ static const struct dt_device_match pl011_dt_match[] __initconst =
>  
>  DT_DEVICE_START(pl011, "PL011 UART", DEVICE_SERIAL)
>          .dt_match = pl011_dt_match,
> -        .init = pl011_uart_init,
> +        .init = dt_pl011_uart_init,
>  DT_DEVICE_END
>  
>  /*
> -- 
> 2.1.0
> 

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

* [Xen-devel] [PATCH v3 35/62] serial: Rename SERHND_DTUART to SERHND_UART
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-26 15:32   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-26 15:32 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Rename SERHND_DTUART to SERHND_UART in order to reuse it when booting
> with ACPI.

But actually I fail to see where is it being used with ACPI.


> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/vuart.c               | 2 +-
>  xen/drivers/char/cadence-uart.c    | 2 +-
>  xen/drivers/char/exynos4210-uart.c | 2 +-
>  xen/drivers/char/omap-uart.c       | 2 +-
>  xen/drivers/char/pl011.c           | 2 +-
>  xen/drivers/char/scif-uart.c       | 2 +-
>  xen/drivers/char/serial.c          | 2 +-
>  xen/include/xen/serial.h           | 2 +-
>  8 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/xen/arch/arm/vuart.c b/xen/arch/arm/vuart.c
> index b5c9288..6619b33 100644
> --- a/xen/arch/arm/vuart.c
> +++ b/xen/arch/arm/vuart.c
> @@ -59,7 +59,7 @@ int domain_vuart_init(struct domain *d)
>  {
>      ASSERT( is_hardware_domain(d) );
>  
> -    d->arch.vuart.info = serial_vuart_info(SERHND_DTUART);
> +    d->arch.vuart.info = serial_vuart_info(SERHND_UART);
>      if ( !d->arch.vuart.info )
>          return 0;
>  
> diff --git a/xen/drivers/char/cadence-uart.c b/xen/drivers/char/cadence-uart.c
> index 933672f..ed65004 100644
> --- a/xen/drivers/char/cadence-uart.c
> +++ b/xen/drivers/char/cadence-uart.c
> @@ -196,7 +196,7 @@ static int __init cuart_init(struct dt_device_node *dev, const void *data)
>      uart->vuart.status = UART_SR_INTR_TEMPTY;
>  
>      /* Register with generic serial driver. */
> -    serial_register_uart(SERHND_DTUART, &cuart_driver, uart);
> +    serial_register_uart(SERHND_UART, &cuart_driver, uart);
>  
>      dt_device_set_used_by(dev, DOMID_XEN);
>  
> diff --git a/xen/drivers/char/exynos4210-uart.c b/xen/drivers/char/exynos4210-uart.c
> index bac1c2b..43f5313 100644
> --- a/xen/drivers/char/exynos4210-uart.c
> +++ b/xen/drivers/char/exynos4210-uart.c
> @@ -345,7 +345,7 @@ static int __init exynos4210_uart_init(struct dt_device_node *dev,
>      uart->vuart.status = UTRSTAT_TXE | UTRSTAT_TXFE;
>  
>      /* Register with generic serial driver. */
> -    serial_register_uart(SERHND_DTUART, &exynos4210_uart_driver, uart);
> +    serial_register_uart(SERHND_UART, &exynos4210_uart_driver, uart);
>  
>      dt_device_set_used_by(dev, DOMID_XEN);
>  
> diff --git a/xen/drivers/char/omap-uart.c b/xen/drivers/char/omap-uart.c
> index d8f64ea..98c3892 100644
> --- a/xen/drivers/char/omap-uart.c
> +++ b/xen/drivers/char/omap-uart.c
> @@ -343,7 +343,7 @@ static int __init omap_uart_init(struct dt_device_node *dev,
>      uart->vuart.status = UART_LSR_THRE;
>  
>      /* Register with generic serial driver */
> -    serial_register_uart(SERHND_DTUART, &omap_uart_driver, uart);
> +    serial_register_uart(SERHND_UART, &omap_uart_driver, uart);
>  
>      dt_device_set_used_by(dev, DOMID_XEN);
>  
> diff --git a/xen/drivers/char/pl011.c b/xen/drivers/char/pl011.c
> index 16abaa5..1efb1cf 100644
> --- a/xen/drivers/char/pl011.c
> +++ b/xen/drivers/char/pl011.c
> @@ -252,7 +252,7 @@ static int __init pl011_uart_init(int irq, u64 addr, u64 size)
>      uart->vuart.status = 0;
>  
>      /* Register with generic serial driver. */
> -    serial_register_uart(SERHND_DTUART, &pl011_driver, uart);
> +    serial_register_uart(SERHND_UART, &pl011_driver, uart);
>  
>      return 0;
>  }
> diff --git a/xen/drivers/char/scif-uart.c b/xen/drivers/char/scif-uart.c
> index 51a2233..739317c 100644
> --- a/xen/drivers/char/scif-uart.c
> +++ b/xen/drivers/char/scif-uart.c
> @@ -339,7 +339,7 @@ static int __init scif_uart_init(struct dt_device_node *dev,
>      uart->vuart.status     = SCFSR_TDFE;
>  
>      /* Register with generic serial driver */
> -    serial_register_uart(SERHND_DTUART, &scif_uart_driver, uart);
> +    serial_register_uart(SERHND_UART, &scif_uart_driver, uart);
>  
>      dt_device_set_used_by(dev, DOMID_XEN);
>  
> diff --git a/xen/drivers/char/serial.c b/xen/drivers/char/serial.c
> index c583a48..659e10d 100644
> --- a/xen/drivers/char/serial.c
> +++ b/xen/drivers/char/serial.c
> @@ -312,7 +312,7 @@ int __init serial_parse_handle(char *conf)
>  
>      if ( !strncmp(conf, "dtuart", 5) )
>      {
> -        handle = SERHND_DTUART;
> +        handle = SERHND_UART;
>          goto common;
>      }
>  
> diff --git a/xen/include/xen/serial.h b/xen/include/xen/serial.h
> index 5e1a536..a6e7c22 100644
> --- a/xen/include/xen/serial.h
> +++ b/xen/include/xen/serial.h
> @@ -94,7 +94,7 @@ struct uart_driver {
>  # define SERHND_COM1    (0<<0)
>  # define SERHND_COM2    (1<<0)
>  # define SERHND_DBGP    (2<<0)
> -# define SERHND_DTUART  (0<<0) /* Steal SERHND_COM1 value */
> +# define SERHND_UART    (0<<0) /* Steal SERHND_COM1 value */
>  #define SERHND_HI       (1<<2) /* Mux/demux each transferred char by MSB. */
>  #define SERHND_LO       (1<<3) /* Ditto, except that the MSB is cleared.  */
>  #define SERHND_COOKED   (1<<4) /* Newline/carriage-return translation?    */
> -- 
> 2.1.0
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel at lists.xen.org
> http://lists.xen.org/xen-devel
> 

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

* Re: [PATCH v3 35/62] serial: Rename SERHND_DTUART to SERHND_UART
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-26 15:32   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-26 15:32 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, david.vrabel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Rename SERHND_DTUART to SERHND_UART in order to reuse it when booting
> with ACPI.

But actually I fail to see where is it being used with ACPI.


> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/vuart.c               | 2 +-
>  xen/drivers/char/cadence-uart.c    | 2 +-
>  xen/drivers/char/exynos4210-uart.c | 2 +-
>  xen/drivers/char/omap-uart.c       | 2 +-
>  xen/drivers/char/pl011.c           | 2 +-
>  xen/drivers/char/scif-uart.c       | 2 +-
>  xen/drivers/char/serial.c          | 2 +-
>  xen/include/xen/serial.h           | 2 +-
>  8 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/xen/arch/arm/vuart.c b/xen/arch/arm/vuart.c
> index b5c9288..6619b33 100644
> --- a/xen/arch/arm/vuart.c
> +++ b/xen/arch/arm/vuart.c
> @@ -59,7 +59,7 @@ int domain_vuart_init(struct domain *d)
>  {
>      ASSERT( is_hardware_domain(d) );
>  
> -    d->arch.vuart.info = serial_vuart_info(SERHND_DTUART);
> +    d->arch.vuart.info = serial_vuart_info(SERHND_UART);
>      if ( !d->arch.vuart.info )
>          return 0;
>  
> diff --git a/xen/drivers/char/cadence-uart.c b/xen/drivers/char/cadence-uart.c
> index 933672f..ed65004 100644
> --- a/xen/drivers/char/cadence-uart.c
> +++ b/xen/drivers/char/cadence-uart.c
> @@ -196,7 +196,7 @@ static int __init cuart_init(struct dt_device_node *dev, const void *data)
>      uart->vuart.status = UART_SR_INTR_TEMPTY;
>  
>      /* Register with generic serial driver. */
> -    serial_register_uart(SERHND_DTUART, &cuart_driver, uart);
> +    serial_register_uart(SERHND_UART, &cuart_driver, uart);
>  
>      dt_device_set_used_by(dev, DOMID_XEN);
>  
> diff --git a/xen/drivers/char/exynos4210-uart.c b/xen/drivers/char/exynos4210-uart.c
> index bac1c2b..43f5313 100644
> --- a/xen/drivers/char/exynos4210-uart.c
> +++ b/xen/drivers/char/exynos4210-uart.c
> @@ -345,7 +345,7 @@ static int __init exynos4210_uart_init(struct dt_device_node *dev,
>      uart->vuart.status = UTRSTAT_TXE | UTRSTAT_TXFE;
>  
>      /* Register with generic serial driver. */
> -    serial_register_uart(SERHND_DTUART, &exynos4210_uart_driver, uart);
> +    serial_register_uart(SERHND_UART, &exynos4210_uart_driver, uart);
>  
>      dt_device_set_used_by(dev, DOMID_XEN);
>  
> diff --git a/xen/drivers/char/omap-uart.c b/xen/drivers/char/omap-uart.c
> index d8f64ea..98c3892 100644
> --- a/xen/drivers/char/omap-uart.c
> +++ b/xen/drivers/char/omap-uart.c
> @@ -343,7 +343,7 @@ static int __init omap_uart_init(struct dt_device_node *dev,
>      uart->vuart.status = UART_LSR_THRE;
>  
>      /* Register with generic serial driver */
> -    serial_register_uart(SERHND_DTUART, &omap_uart_driver, uart);
> +    serial_register_uart(SERHND_UART, &omap_uart_driver, uart);
>  
>      dt_device_set_used_by(dev, DOMID_XEN);
>  
> diff --git a/xen/drivers/char/pl011.c b/xen/drivers/char/pl011.c
> index 16abaa5..1efb1cf 100644
> --- a/xen/drivers/char/pl011.c
> +++ b/xen/drivers/char/pl011.c
> @@ -252,7 +252,7 @@ static int __init pl011_uart_init(int irq, u64 addr, u64 size)
>      uart->vuart.status = 0;
>  
>      /* Register with generic serial driver. */
> -    serial_register_uart(SERHND_DTUART, &pl011_driver, uart);
> +    serial_register_uart(SERHND_UART, &pl011_driver, uart);
>  
>      return 0;
>  }
> diff --git a/xen/drivers/char/scif-uart.c b/xen/drivers/char/scif-uart.c
> index 51a2233..739317c 100644
> --- a/xen/drivers/char/scif-uart.c
> +++ b/xen/drivers/char/scif-uart.c
> @@ -339,7 +339,7 @@ static int __init scif_uart_init(struct dt_device_node *dev,
>      uart->vuart.status     = SCFSR_TDFE;
>  
>      /* Register with generic serial driver */
> -    serial_register_uart(SERHND_DTUART, &scif_uart_driver, uart);
> +    serial_register_uart(SERHND_UART, &scif_uart_driver, uart);
>  
>      dt_device_set_used_by(dev, DOMID_XEN);
>  
> diff --git a/xen/drivers/char/serial.c b/xen/drivers/char/serial.c
> index c583a48..659e10d 100644
> --- a/xen/drivers/char/serial.c
> +++ b/xen/drivers/char/serial.c
> @@ -312,7 +312,7 @@ int __init serial_parse_handle(char *conf)
>  
>      if ( !strncmp(conf, "dtuart", 5) )
>      {
> -        handle = SERHND_DTUART;
> +        handle = SERHND_UART;
>          goto common;
>      }
>  
> diff --git a/xen/include/xen/serial.h b/xen/include/xen/serial.h
> index 5e1a536..a6e7c22 100644
> --- a/xen/include/xen/serial.h
> +++ b/xen/include/xen/serial.h
> @@ -94,7 +94,7 @@ struct uart_driver {
>  # define SERHND_COM1    (0<<0)
>  # define SERHND_COM2    (1<<0)
>  # define SERHND_DBGP    (2<<0)
> -# define SERHND_DTUART  (0<<0) /* Steal SERHND_COM1 value */
> +# define SERHND_UART    (0<<0) /* Steal SERHND_COM1 value */
>  #define SERHND_HI       (1<<2) /* Mux/demux each transferred char by MSB. */
>  #define SERHND_LO       (1<<3) /* Ditto, except that the MSB is cleared.  */
>  #define SERHND_COOKED   (1<<4) /* Newline/carriage-return translation?    */
> -- 
> 2.1.0
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
> 

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

* [PATCH v3 36/62] arm/acpi: Initialize serial port from ACPI SPCR table
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-26 15:43   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-26 15:43 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> From: Parth Dixit <parth.dixit@linaro.org>
> 
> Parse ACPI SPCR (Serial Port Console Redirection table) table and
> initialize the serial port pl011.
> 
> 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>
> ---
>  xen/drivers/char/pl011.c  | 37 +++++++++++++++++++++++++++++++++++++
>  xen/include/acpi/actbl2.h |  5 +++++
>  2 files changed, 42 insertions(+)
> 
> diff --git a/xen/drivers/char/pl011.c b/xen/drivers/char/pl011.c
> index 1efb1cf..7106f1c 100644
> --- a/xen/drivers/char/pl011.c
> +++ b/xen/drivers/char/pl011.c
> @@ -27,6 +27,7 @@
>  #include <asm/device.h>
>  #include <xen/mm.h>
>  #include <xen/vmap.h>
> +#include <xen/acpi.h>
>  #include <asm/pl011-uart.h>
>  #include <asm/io.h>
>  
> @@ -308,6 +309,42 @@ DT_DEVICE_START(pl011, "PL011 UART", DEVICE_SERIAL)
>          .init = dt_pl011_uart_init,
>  DT_DEVICE_END
>  
> +#ifdef CONFIG_ACPI
> +static int __init acpi_pl011_uart_init(const void *data)
> +{
> +    acpi_status status;
> +    struct acpi_table_spcr *spcr=NULL;

coding style


> +    int res;
> +
> +    status = acpi_get_table(ACPI_SIG_SPCR, 0,
> +                            (struct acpi_table_header **)&spcr);
> +
> +    if ( ACPI_FAILURE(status) )
> +    {
> +        printk("pl011: Failed to get SPCR table\n");
> +        return -EINVAL;
> +    }
> +
> +    /* trigger/polarity information is not available in spcr */
> +    irq_set_type(spcr->interrupt, ACPI_IRQ_TYPE_EDGE_BOTH);
> +
> +    res = pl011_uart_init(spcr->interrupt, spcr->serial_port.address,
> +                          PAGE_SIZE);
> +    if ( res < 0 )
> +    {
> +        printk("pl011: Unable to initialize\n");
> +        return res;
> +    }
> +
> +    return 0;
> +}
> +
> +ACPI_DEVICE_START(apl011, "PL011 UART", DEVICE_SERIAL)
> +        .class_type = ACPI_SPCR_TYPE_PL011,
> +        .init = acpi_pl011_uart_init,
> +ACPI_DEVICE_END
> +#endif
> +
>  /*
>   * Local variables:
>   * mode: C
> diff --git a/xen/include/acpi/actbl2.h b/xen/include/acpi/actbl2.h
> index 87bc6b3..25be429 100644
> --- a/xen/include/acpi/actbl2.h
> +++ b/xen/include/acpi/actbl2.h
> @@ -815,6 +815,11 @@ struct acpi_table_spcr {
>  
>  #define ACPI_SPCR_DO_NOT_DISABLE    (1)
>  
> +/* UART Interface type */
> +#define ACPI_SPCR_TYPE_16550 0
> +#define ACPI_SPCR_TYPE_16550_SUB 1
> +#define ACPI_SPCR_TYPE_PL011 3

Since you are at it, please also add the other fields as specified in
the DBG2.



>  /*******************************************************************************
>   *
>   * SPMI - Server Platform Management Interface table
> -- 
> 2.1.0
> 

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

* Re: [PATCH v3 36/62] arm/acpi: Initialize serial port from ACPI SPCR table
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-26 15:43   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-26 15:43 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, linux-arm-kernel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, david.vrabel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> From: Parth Dixit <parth.dixit@linaro.org>
> 
> Parse ACPI SPCR (Serial Port Console Redirection table) table and
> initialize the serial port pl011.
> 
> 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>
> ---
>  xen/drivers/char/pl011.c  | 37 +++++++++++++++++++++++++++++++++++++
>  xen/include/acpi/actbl2.h |  5 +++++
>  2 files changed, 42 insertions(+)
> 
> diff --git a/xen/drivers/char/pl011.c b/xen/drivers/char/pl011.c
> index 1efb1cf..7106f1c 100644
> --- a/xen/drivers/char/pl011.c
> +++ b/xen/drivers/char/pl011.c
> @@ -27,6 +27,7 @@
>  #include <asm/device.h>
>  #include <xen/mm.h>
>  #include <xen/vmap.h>
> +#include <xen/acpi.h>
>  #include <asm/pl011-uart.h>
>  #include <asm/io.h>
>  
> @@ -308,6 +309,42 @@ DT_DEVICE_START(pl011, "PL011 UART", DEVICE_SERIAL)
>          .init = dt_pl011_uart_init,
>  DT_DEVICE_END
>  
> +#ifdef CONFIG_ACPI
> +static int __init acpi_pl011_uart_init(const void *data)
> +{
> +    acpi_status status;
> +    struct acpi_table_spcr *spcr=NULL;

coding style


> +    int res;
> +
> +    status = acpi_get_table(ACPI_SIG_SPCR, 0,
> +                            (struct acpi_table_header **)&spcr);
> +
> +    if ( ACPI_FAILURE(status) )
> +    {
> +        printk("pl011: Failed to get SPCR table\n");
> +        return -EINVAL;
> +    }
> +
> +    /* trigger/polarity information is not available in spcr */
> +    irq_set_type(spcr->interrupt, ACPI_IRQ_TYPE_EDGE_BOTH);
> +
> +    res = pl011_uart_init(spcr->interrupt, spcr->serial_port.address,
> +                          PAGE_SIZE);
> +    if ( res < 0 )
> +    {
> +        printk("pl011: Unable to initialize\n");
> +        return res;
> +    }
> +
> +    return 0;
> +}
> +
> +ACPI_DEVICE_START(apl011, "PL011 UART", DEVICE_SERIAL)
> +        .class_type = ACPI_SPCR_TYPE_PL011,
> +        .init = acpi_pl011_uart_init,
> +ACPI_DEVICE_END
> +#endif
> +
>  /*
>   * Local variables:
>   * mode: C
> diff --git a/xen/include/acpi/actbl2.h b/xen/include/acpi/actbl2.h
> index 87bc6b3..25be429 100644
> --- a/xen/include/acpi/actbl2.h
> +++ b/xen/include/acpi/actbl2.h
> @@ -815,6 +815,11 @@ struct acpi_table_spcr {
>  
>  #define ACPI_SPCR_DO_NOT_DISABLE    (1)
>  
> +/* UART Interface type */
> +#define ACPI_SPCR_TYPE_16550 0
> +#define ACPI_SPCR_TYPE_16550_SUB 1
> +#define ACPI_SPCR_TYPE_PL011 3

Since you are at it, please also add the other fields as specified in
the DBG2.



>  /*******************************************************************************
>   *
>   * SPMI - Server Platform Management Interface table
> -- 
> 2.1.0
> 

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

* [PATCH v3 38/62] arm/acpi: Add placeholder for efi and acpi load address
  2015-11-17 12:45     ` Shannon Zhao
                         ` (2 preceding siblings ...)
  2015-11-26 16:02       ` Stefano Stabellini
@ 2015-11-26 16:02       ` Stefano Stabellini
  3 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-26 16:02 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, Shannon Zhao wrote:
> On 2015/11/17 19:58, Julien Grall wrote:
> > Hi Shannon,
> > 
> > On 17/11/15 09:40, shannon.zhao at linaro.org wrote:
> >> From: Shannon Zhao <shannon.zhao@linaro.org>
> >>
> >> EFI table, memory description table and some of acpi tables will be
> >> placed after DOM0 memory space. 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>
> >> ---
> >>  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 1e61f30..91272e5 100644
> >> --- a/xen/include/asm-arm/domain.h
> >> +++ b/xen/include/asm-arm/domain.h
> >> @@ -125,6 +125,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
> > 
> > Why do you need this in the arch_domain? AFAICT those 3 variables should
> > only be used while building DOM0, so a better place would be in struct
> > kernel_info (see xen/arch/arm/kernel.h).
> > 
> 
> Since I use efi_acpi_table to store the allocated pages pointer which
> are used to store newly created ACPI and EFI tables.
> See [PATCH v3 40/62]:
> +    order = get_order_from_bytes(d->arch.efi_acpi_len);
> +    d->arch.efi_acpi_table = alloc_xenheap_pages(order, 0);
> 
> And it free these pages when destroying this domain:
> +#ifdef CONFIG_ACPI
> +    free_xenheap_pages(d->arch.efi_acpi_table,
> +                       get_order_from_bytes(d->arch.efi_acpi_len));
> +#endif
> 
> efi_acpi_gpa might not need.

If you need to free the memory at domain destruction, it could make
sense to store the pointer in struct arch_domain, even if it only
happens for dom0. However you could come up with a single struct and add
a pointer to it in arch_domain to limit the per-domain overhead.

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

* Re: [PATCH v3 38/62] arm/acpi: Add placeholder for efi and acpi load address
  2015-11-17 12:45     ` Shannon Zhao
  2015-11-17 14:23       ` Julien Grall
  2015-11-17 14:23       ` Julien Grall
@ 2015-11-26 16:02       ` Stefano Stabellini
  2015-11-26 16:02       ` Stefano Stabellini
  3 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-26 16:02 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: mark.rutland, hangaohuai, david.vrabel, keir, ian.campbell,
	ard.biesheuvel, andrew.cooper3, peter.huangpeng, xen-devel,
	Julien Grall, stefano.stabellini, shannon.zhao, jbeulich,
	roger.pau, christoffer.dall, linux-arm-kernel

On Tue, 17 Nov 2015, Shannon Zhao wrote:
> On 2015/11/17 19:58, Julien Grall wrote:
> > Hi Shannon,
> > 
> > On 17/11/15 09:40, shannon.zhao@linaro.org wrote:
> >> From: Shannon Zhao <shannon.zhao@linaro.org>
> >>
> >> EFI table, memory description table and some of acpi tables will be
> >> placed after DOM0 memory space. 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>
> >> ---
> >>  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 1e61f30..91272e5 100644
> >> --- a/xen/include/asm-arm/domain.h
> >> +++ b/xen/include/asm-arm/domain.h
> >> @@ -125,6 +125,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
> > 
> > Why do you need this in the arch_domain? AFAICT those 3 variables should
> > only be used while building DOM0, so a better place would be in struct
> > kernel_info (see xen/arch/arm/kernel.h).
> > 
> 
> Since I use efi_acpi_table to store the allocated pages pointer which
> are used to store newly created ACPI and EFI tables.
> See [PATCH v3 40/62]:
> +    order = get_order_from_bytes(d->arch.efi_acpi_len);
> +    d->arch.efi_acpi_table = alloc_xenheap_pages(order, 0);
> 
> And it free these pages when destroying this domain:
> +#ifdef CONFIG_ACPI
> +    free_xenheap_pages(d->arch.efi_acpi_table,
> +                       get_order_from_bytes(d->arch.efi_acpi_len));
> +#endif
> 
> efi_acpi_gpa might not need.

If you need to free the memory at domain destruction, it could make
sense to store the pointer in struct arch_domain, even if it only
happens for dom0. However you could come up with a single struct and add
a pointer to it in arch_domain to limit the per-domain overhead.

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

* [PATCH v3 38/62] arm/acpi: Add placeholder for efi and acpi load address
  2015-11-18 11:56           ` Julien Grall
@ 2015-11-26 16:04             ` Stefano Stabellini
  2015-11-30 15:10                 ` Julien Grall
  2015-11-26 16:04             ` Stefano Stabellini
  1 sibling, 1 reply; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-26 16:04 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, 18 Nov 2015, Julien Grall wrote:
> On 18/11/15 03:01, Shannon Zhao wrote:
> > "All above tables will be mapped to Dom0 non-RAM space. Since when
> > booting through ACPI it doesn't need the grant table region(see below
> > section 3), it could use this region to store the tables or use the same
> > way to find one memory region to store them."
> > 
> > Firstly, as Jan suggested, these tables should not be in RAM space, so
> > we drop the previous way that copying these tables to Dom0 RAM.
> > Then I suggested map these tables to the space after the Dom0 RAM space,
> > but this not right because Dom0 RAM region might be at the edge of
> > physical RAM space and there might be device MMIO regions.
> > Then you suggest it could map these tables to the region which is used
> > for grant table(or the region found by the same way) while it's not used
> > when it boots with ACPI. These regions are not used by Xen and will not
> > be used by Dom0 either currently. But as you say, it will be wrong if
> > Dom0 memory is not 1:1 mapped.
> 
> Will you remember in 6 months why you wrote the code like that?
> 
> My point on the previous mail is you don't describe what you did,
> neither in the code nor in the commit message.
> 
> Most of the place in the code are trying to avoid the assumption that
> DOM0 is using direct mapped. If not, we always have a comment/commit
> message explaining why we are doing like that and the implication (see
> the grant table example [1]).
> 
> > So how about below idea:
> > We still copy these tables to Dom0 RAM space but when we create
> > EFI_MMAP_TABLE, we remove the space occupied by these tables from the
> > EfiConventionalMemory descriptor.
> 
> As you don't need the grant table region, why don't you re-use it fopr
> your tables? It may also be possible that we have some space just after
> for the EFI table.

I think that the current approach is good, please just extend the
in-code comment in patch #40.

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

* Re: [PATCH v3 38/62] arm/acpi: Add placeholder for efi and acpi load address
  2015-11-18 11:56           ` Julien Grall
  2015-11-26 16:04             ` Stefano Stabellini
@ 2015-11-26 16:04             ` Stefano Stabellini
  1 sibling, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-26 16:04 UTC (permalink / raw)
  To: Julien Grall
  Cc: hangaohuai, ian.campbell, peter.huangpeng, xen-devel,
	stefano.stabellini, shannon.zhao, Jan Beulich, Shannon Zhao,
	linux-arm-kernel

On Wed, 18 Nov 2015, Julien Grall wrote:
> On 18/11/15 03:01, Shannon Zhao wrote:
> > "All above tables will be mapped to Dom0 non-RAM space. Since when
> > booting through ACPI it doesn't need the grant table region(see below
> > section 3), it could use this region to store the tables or use the same
> > way to find one memory region to store them."
> > 
> > Firstly, as Jan suggested, these tables should not be in RAM space, so
> > we drop the previous way that copying these tables to Dom0 RAM.
> > Then I suggested map these tables to the space after the Dom0 RAM space,
> > but this not right because Dom0 RAM region might be at the edge of
> > physical RAM space and there might be device MMIO regions.
> > Then you suggest it could map these tables to the region which is used
> > for grant table(or the region found by the same way) while it's not used
> > when it boots with ACPI. These regions are not used by Xen and will not
> > be used by Dom0 either currently. But as you say, it will be wrong if
> > Dom0 memory is not 1:1 mapped.
> 
> Will you remember in 6 months why you wrote the code like that?
> 
> My point on the previous mail is you don't describe what you did,
> neither in the code nor in the commit message.
> 
> Most of the place in the code are trying to avoid the assumption that
> DOM0 is using direct mapped. If not, we always have a comment/commit
> message explaining why we are doing like that and the implication (see
> the grant table example [1]).
> 
> > So how about below idea:
> > We still copy these tables to Dom0 RAM space but when we create
> > EFI_MMAP_TABLE, we remove the space occupied by these tables from the
> > EfiConventionalMemory descriptor.
> 
> As you don't need the grant table region, why don't you re-use it fopr
> your tables? It may also be possible that we have some space just after
> for the EFI table.

I think that the current approach is good, please just extend the
in-code comment in patch #40.

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

* [PATCH v3 39/62] arm/acpi: Read acpi memory info from uefi
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-26 16:18   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-26 16:18 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org 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>


>  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..c58caca 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;
> +#ifdef CONFIG_ACPI
> +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;
>          }
> +#ifdef CONFIG_ACPI
> +        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;
> +#ifdef CONFIG_ACPI
> +    acpi_mem.nr_banks = j;
> +#endif
>      return EFI_SUCCESS;
>  }
>  
> -- 
> 2.1.0
> 

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

* Re: [PATCH v3 39/62] arm/acpi: Read acpi memory info from uefi
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-26 16:18   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-26 16:18 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, linux-arm-kernel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, david.vrabel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org 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>


>  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..c58caca 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;
> +#ifdef CONFIG_ACPI
> +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;
>          }
> +#ifdef CONFIG_ACPI
> +        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;
> +#ifdef CONFIG_ACPI
> +    acpi_mem.nr_banks = j;
> +#endif
>      return EFI_SUCCESS;
>  }
>  
> -- 
> 2.1.0
> 

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

* [PATCH v3 40/62] arm/acpi: Estimate memory required for acpi/efi tables
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-26 16:39   ` Stefano Stabellini
  2015-12-31  9:16     ` Shannon Zhao
  2015-12-31  9:16     ` Shannon Zhao
  -1 siblings, 2 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-26 16:39 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Estimate the memory required for loading acpi/efi tables in Dom0. Alloc
> the pages to store the new created EFI and ACPI tables and free these
> pages when destroying domain.

Could you please explain what you are page aligning exactly and why?


> 
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/domain.c       |  4 +++
>  xen/arch/arm/domain_build.c | 80 ++++++++++++++++++++++++++++++++++++++++++++-
>  xen/common/efi/boot.c       | 21 ++++++++++++
>  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 880d0a6..10c58c4 100644
> --- a/xen/arch/arm/domain.c
> +++ b/xen/arch/arm/domain.c
> @@ -638,6 +638,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 0c3441a..b5ed44c 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,78 @@ 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 += PAGE_ALIGN(sizeof(struct acpi_table_fadt));
> +    acpi_size += PAGE_ALIGN(sizeof(struct acpi_table_stao));
> +
> +    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 += PAGE_ALIGN(madt_size);

are the MADT and FADT tables guaranteed to be on separate pages or is it
just an estimate?


> +    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));
> +    acpi_size += PAGE_ALIGN(table->length + sizeof(u64));
> +    acpi_os_unmap_memory(table, sizeof(struct acpi_table_header));
> +    acpi_os_unmap_memory(rsdp_tbl, sizeof(struct acpi_table_rsdp));
> +
> +    acpi_size += PAGE_ALIGN(sizeof(struct acpi_table_rsdp));
> +    d->arch.efi_acpi_len = PAGE_ALIGN(efi_size) + PAGE_ALIGN(acpi_size);
> +
> +    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 -1;

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 +1614,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..78d8ae9 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,26 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
>      for( ; ; ); /* not reached */
>  }
>  
> +#ifdef CONFIG_ACPI
> +/* 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;
> +    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 = PAGE_ALIGN(est_size + ect_size + fw_vendor_size)
> +           + PAGE_ALIGN(emd_size *
> +                        (mem_nr_banks + acpi_mem.nr_banks + TBL_MMAX));

Why are they on two separate pages? Is it mandated by the EFI spec?
Why are you adding TBL_MMAX to the multiplicand here?

I don't like that we are passing mem_nr_banks as argument but we are
accessing acpi_mem.nr_banks from the global variable. I would prefer if
they were both passed as arguments.


> +    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.1.0
> 

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

* Re: [PATCH v3 40/62] arm/acpi: Estimate memory required for acpi/efi tables
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-26 16:39   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-26 16:39 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, linux-arm-kernel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, david.vrabel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Estimate the memory required for loading acpi/efi tables in Dom0. Alloc
> the pages to store the new created EFI and ACPI tables and free these
> pages when destroying domain.

Could you please explain what you are page aligning exactly and why?


> 
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/domain.c       |  4 +++
>  xen/arch/arm/domain_build.c | 80 ++++++++++++++++++++++++++++++++++++++++++++-
>  xen/common/efi/boot.c       | 21 ++++++++++++
>  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 880d0a6..10c58c4 100644
> --- a/xen/arch/arm/domain.c
> +++ b/xen/arch/arm/domain.c
> @@ -638,6 +638,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 0c3441a..b5ed44c 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,78 @@ 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 += PAGE_ALIGN(sizeof(struct acpi_table_fadt));
> +    acpi_size += PAGE_ALIGN(sizeof(struct acpi_table_stao));
> +
> +    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 += PAGE_ALIGN(madt_size);

are the MADT and FADT tables guaranteed to be on separate pages or is it
just an estimate?


> +    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));
> +    acpi_size += PAGE_ALIGN(table->length + sizeof(u64));
> +    acpi_os_unmap_memory(table, sizeof(struct acpi_table_header));
> +    acpi_os_unmap_memory(rsdp_tbl, sizeof(struct acpi_table_rsdp));
> +
> +    acpi_size += PAGE_ALIGN(sizeof(struct acpi_table_rsdp));
> +    d->arch.efi_acpi_len = PAGE_ALIGN(efi_size) + PAGE_ALIGN(acpi_size);
> +
> +    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 -1;

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 +1614,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..78d8ae9 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,26 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
>      for( ; ; ); /* not reached */
>  }
>  
> +#ifdef CONFIG_ACPI
> +/* 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;
> +    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 = PAGE_ALIGN(est_size + ect_size + fw_vendor_size)
> +           + PAGE_ALIGN(emd_size *
> +                        (mem_nr_banks + acpi_mem.nr_banks + TBL_MMAX));

Why are they on two separate pages? Is it mandated by the EFI spec?
Why are you adding TBL_MMAX to the multiplicand here?

I don't like that we are passing mem_nr_banks as argument but we are
accessing acpi_mem.nr_banks from the global variable. I would prefer if
they were both passed as arguments.


> +    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.1.0
> 

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

* [Xen-devel] [PATCH v3 37/62] arm/acpi: Define a enum for reserved tables
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-26 16:50   ` Stefano Stabellini
  2015-11-26 17:06     ` Stefano Stabellini
  2015-11-26 17:06     ` Stefano Stabellini
  -1 siblings, 2 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-26 16:50 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org 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>
> ---
>  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 214fc4e..f159d51 100644
> --- a/xen/include/asm-arm/acpi.h
> +++ b/xen/include/asm-arm/acpi.h
> @@ -30,6 +30,18 @@
>  
>  extern bool_t acpi_disabled;
>  
> +/* 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;

Given that in later patches you are using the enum as integer, you
should initialize each value explicitly.


>  #ifdef CONFIG_ACPI
>  bool_t __init acpi_psci_present(void);
>  bool_t __init acpi_psci_hvc_present(void);
> -- 
> 2.1.0
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel at lists.xen.org
> http://lists.xen.org/xen-devel
> 

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

* Re: [PATCH v3 37/62] arm/acpi: Define a enum for reserved tables
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-26 16:50   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-26 16:50 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, david.vrabel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org 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>
> ---
>  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 214fc4e..f159d51 100644
> --- a/xen/include/asm-arm/acpi.h
> +++ b/xen/include/asm-arm/acpi.h
> @@ -30,6 +30,18 @@
>  
>  extern bool_t acpi_disabled;
>  
> +/* 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;

Given that in later patches you are using the enum as integer, you
should initialize each value explicitly.


>  #ifdef CONFIG_ACPI
>  bool_t __init acpi_psci_present(void);
>  bool_t __init acpi_psci_hvc_present(void);
> -- 
> 2.1.0
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
> 

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

* [PATCH v3 41/62] arm/acpi: Add a helper function to get the acpi table offset
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-26 17:02   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-26 17:02 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

It should probably be merged with patch #37.

Please add more details on how the offset is calculated, whether it is
bytes, and why all the tables have been page aligned.


>  xen/arch/arm/acpi/lib.c    | 13 +++++++++++++
>  xen/include/asm-arm/acpi.h |  6 ++++++
>  2 files changed, 19 insertions(+)
> 
> diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c
> index 47f4c6a..d6044ef 100644
> --- a/xen/arch/arm/acpi/lib.c
> +++ b/xen/arch/arm/acpi/lib.c
> @@ -70,3 +70,16 @@ unsigned int acpi_get_irq_type(u32 flags)
>          return ACPI_IRQ_TYPE_NONE;
>      }
>  }
> +
> +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++ )
> +    {
> +        offset += PAGE_ALIGN(tbl_add[i].size);
> +    }

Aside from the fact that I don't know if PAGE_ALIGNING each entry here
is correct, the patch looks straightforward.



> +    return offset;
> +}
> diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
> index f159d51..628f3c8 100644
> --- a/xen/include/asm-arm/acpi.h
> +++ b/xen/include/asm-arm/acpi.h
> @@ -24,6 +24,7 @@
>  #define _ASM_ARM_ACPI_H
>  
>  #include <xen/init.h>
> +#include <asm/setup.h>
>  
>  #define COMPILER_DEPENDENT_INT64   long long
>  #define COMPILER_DEPENDENT_UINT64  unsigned long long
> @@ -47,11 +48,16 @@ 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_irq_type(u32 flags);
> +unsigned int acpi_get_table_offset(struct membank tbl_add[], EFI_MEM_RES index);
>  #else
>  static inline bool_t acpi_psci_present(void) { return false; }
>  static inline bool_t acpi_psci_hvc_present(void) {return false; }
>  static inline void acpi_smp_init_cpus(void) { }
>  static inline unsigned int acpi_get_irq_type(u32 flags) { return 0; }
> +unsigned int acpi_get_table_offset(struct membank tbl_add[], EFI_MEM_RES index)
> +{
> +    return 0;
> +}
>  #endif /* CONFIG_ACPI */
>  
>  /* Basic configuration for ACPI */
> -- 
> 2.1.0
> 

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

* Re: [PATCH v3 41/62] arm/acpi: Add a helper function to get the acpi table offset
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-26 17:02   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-26 17:02 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, linux-arm-kernel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, david.vrabel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

It should probably be merged with patch #37.

Please add more details on how the offset is calculated, whether it is
bytes, and why all the tables have been page aligned.


>  xen/arch/arm/acpi/lib.c    | 13 +++++++++++++
>  xen/include/asm-arm/acpi.h |  6 ++++++
>  2 files changed, 19 insertions(+)
> 
> diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c
> index 47f4c6a..d6044ef 100644
> --- a/xen/arch/arm/acpi/lib.c
> +++ b/xen/arch/arm/acpi/lib.c
> @@ -70,3 +70,16 @@ unsigned int acpi_get_irq_type(u32 flags)
>          return ACPI_IRQ_TYPE_NONE;
>      }
>  }
> +
> +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++ )
> +    {
> +        offset += PAGE_ALIGN(tbl_add[i].size);
> +    }

Aside from the fact that I don't know if PAGE_ALIGNING each entry here
is correct, the patch looks straightforward.



> +    return offset;
> +}
> diff --git a/xen/include/asm-arm/acpi.h b/xen/include/asm-arm/acpi.h
> index f159d51..628f3c8 100644
> --- a/xen/include/asm-arm/acpi.h
> +++ b/xen/include/asm-arm/acpi.h
> @@ -24,6 +24,7 @@
>  #define _ASM_ARM_ACPI_H
>  
>  #include <xen/init.h>
> +#include <asm/setup.h>
>  
>  #define COMPILER_DEPENDENT_INT64   long long
>  #define COMPILER_DEPENDENT_UINT64  unsigned long long
> @@ -47,11 +48,16 @@ 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_irq_type(u32 flags);
> +unsigned int acpi_get_table_offset(struct membank tbl_add[], EFI_MEM_RES index);
>  #else
>  static inline bool_t acpi_psci_present(void) { return false; }
>  static inline bool_t acpi_psci_hvc_present(void) {return false; }
>  static inline void acpi_smp_init_cpus(void) { }
>  static inline unsigned int acpi_get_irq_type(u32 flags) { return 0; }
> +unsigned int acpi_get_table_offset(struct membank tbl_add[], EFI_MEM_RES index)
> +{
> +    return 0;
> +}
>  #endif /* CONFIG_ACPI */
>  
>  /* Basic configuration for ACPI */
> -- 
> 2.1.0
> 

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

* [Xen-devel] [PATCH v3 37/62] arm/acpi: Define a enum for reserved tables
  2015-11-26 16:50   ` [Xen-devel] " Stefano Stabellini
@ 2015-11-26 17:06     ` Stefano Stabellini
  2015-11-26 17:06     ` Stefano Stabellini
  1 sibling, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-26 17:06 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, 26 Nov 2015, Stefano Stabellini wrote:
> On Tue, 17 Nov 2015, shannon.zhao at linaro.org 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>
> > ---
> >  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 214fc4e..f159d51 100644
> > --- a/xen/include/asm-arm/acpi.h
> > +++ b/xen/include/asm-arm/acpi.h
> > @@ -30,6 +30,18 @@
> >  
> >  extern bool_t acpi_disabled;
> >  
> > +/* 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;
> 
> Given that in later patches you are using the enum as integer, you
> should initialize each value explicitly.

It turns out that actually enums are guaranteed to start from 0, so
there is no need for an explicit initialization.


> >  #ifdef CONFIG_ACPI
> >  bool_t __init acpi_psci_present(void);
> >  bool_t __init acpi_psci_hvc_present(void);
> > -- 
> > 2.1.0
> > 
> > 
> > _______________________________________________
> > Xen-devel mailing list
> > Xen-devel at lists.xen.org
> > http://lists.xen.org/xen-devel
> > 
> 

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

* Re: [PATCH v3 37/62] arm/acpi: Define a enum for reserved tables
  2015-11-26 16:50   ` [Xen-devel] " Stefano Stabellini
  2015-11-26 17:06     ` Stefano Stabellini
@ 2015-11-26 17:06     ` Stefano Stabellini
  1 sibling, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-26 17:06 UTC (permalink / raw)
  To: Stefano Stabellini
  Cc: mark.rutland, hangaohuai, keir, Ian Campbell, linux-arm-kernel,
	ard.biesheuvel, andrew.cooper3, Ian Jackson, peter.huangpeng,
	xen-devel, julien.grall, stefano.stabellini, shannon.zhao,
	jbeulich, zhaoshenglong, roger.pau, christoffer.dall,
	david.vrabel

On Thu, 26 Nov 2015, Stefano Stabellini wrote:
> On Tue, 17 Nov 2015, shannon.zhao@linaro.org 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>
> > ---
> >  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 214fc4e..f159d51 100644
> > --- a/xen/include/asm-arm/acpi.h
> > +++ b/xen/include/asm-arm/acpi.h
> > @@ -30,6 +30,18 @@
> >  
> >  extern bool_t acpi_disabled;
> >  
> > +/* 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;
> 
> Given that in later patches you are using the enum as integer, you
> should initialize each value explicitly.

It turns out that actually enums are guaranteed to start from 0, so
there is no need for an explicit initialization.


> >  #ifdef CONFIG_ACPI
> >  bool_t __init acpi_psci_present(void);
> >  bool_t __init acpi_psci_hvc_present(void);
> > -- 
> > 2.1.0
> > 
> > 
> > _______________________________________________
> > Xen-devel mailing list
> > Xen-devel@lists.xen.org
> > http://lists.xen.org/xen-devel
> > 
> 

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

* [Xen-devel] [PATCH v3 42/62] arm/acpi: Prepare FADT table for Dom0
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-26 17:19   ` Stefano Stabellini
  2015-11-27  9:50     ` Ian Campbell
  2015-11-27  9:50     ` [Xen-devel] " Ian Campbell
  -1 siblings, 2 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-26 17:19 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org 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>
>
>  xen/arch/arm/domain_build.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 45 insertions(+)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index b5ed44c..5d03dc0 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -1357,6 +1357,46 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
>  }
>  
>  #ifdef CONFIG_ACPI
> +#define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */

This needs to be documented somewhere. A new doc under docs/ might be
enough.


> +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);
> +    fadt->hypervisor_id = XEN_HYPERVISOR_ID;
> +    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;
> @@ -1400,6 +1440,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 )
> @@ -1418,6 +1459,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.1.0
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel at lists.xen.org
> http://lists.xen.org/xen-devel
> 

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

* Re: [PATCH v3 42/62] arm/acpi: Prepare FADT table for Dom0
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-26 17:19   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-26 17:19 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, david.vrabel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org 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>
>
>  xen/arch/arm/domain_build.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 45 insertions(+)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index b5ed44c..5d03dc0 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -1357,6 +1357,46 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
>  }
>  
>  #ifdef CONFIG_ACPI
> +#define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */

This needs to be documented somewhere. A new doc under docs/ might be
enough.


> +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);
> +    fadt->hypervisor_id = XEN_HYPERVISOR_ID;
> +    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;
> @@ -1400,6 +1440,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 )
> @@ -1418,6 +1459,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.1.0
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
> 

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

* [PATCH v3 43/62] arm/acpi: Prepare MADT table for Dom0
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-26 17:48   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-26 17:48 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Copy and modify MADT table before passing it to Dom0. Copy
> dom0_max_vcpus of GICCs and GICD as well.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/domain_build.c | 98 +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 98 insertions(+)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index 5d03dc0..4591955 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -1359,6 +1359,100 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
>  #ifdef CONFIG_ACPI
>  #define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */
>  
> +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_madt_generic_distributor gicd;
> +    u64 table_size = sizeof(struct acpi_table_madt);
> +    acpi_status status;
> +    int i;
> +    u8 *base_ptr;
> +    u8 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
> +               + acpi_get_table_offset(tbl_add, TBL_MADT);
> +    ACPI_MEMCPY(base_ptr, table, table_size);
> +
> +    /* Add Generic Distributor */
> +    memset(&gicd, 0, sizeof(gicd));
> +    gicd.header.type = ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR;
> +    gicd.header.length = sizeof(gicd);
> +    gicd.base_address = d->arch.vgic.dbase;
> +    if ( d->arch.vgic.version == GIC_V2 )
> +        gicd.version = ACPI_MADT_GIC_VERSION_V2;
> +    else if ( d->arch.vgic.version == GIC_V3 )
> +        gicd.version = ACPI_MADT_GIC_VERSION_V3;
> +    else
> +        gicd.version = ACPI_MADT_GIC_VERSION_NONE;
> +    ACPI_MEMCPY(base_ptr + table_size, &gicd, sizeof(gicd));
> +
> +    table_size += sizeof(gicd);
> +
> +    if ( d->arch.vgic.version == GIC_V3 ) {
> +        /* Add Generic Redistributor */
> +        for ( i = 0; i < d->arch.vgic.nr_regions; i++ ) {

Coding style


> +            struct acpi_madt_generic_redistributor gicr;
> +
> +            memset(&gicr, 0, sizeof(gicr));
> +            gicr.header.type = ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR;
> +            gicr.header.length = sizeof(gicr);
> +            gicr.base_address = d->arch.vgic.rdist_regions[i].base;
> +            gicr.length = d->arch.vgic.rdist_regions[i].size;
> +            ACPI_MEMCPY(base_ptr + table_size, &gicr, sizeof(gicr));
> +            table_size += sizeof(gicr);
> +        }
> +    } else {
> +        /* Add Generic Interrupt */
> +        for ( i = 0; i < d->max_vcpus; i++ )
> +        {
> +            struct acpi_madt_generic_interrupt gicc;
> +            u64 mpidr = 0;
> +            u32 id = i, j = 0;
> +
> +            memset(&gicc, 0, sizeof(gicc));
> +            gicc.header.type = ACPI_MADT_TYPE_GENERIC_INTERRUPT;
> +            gicc.header.length = sizeof(gicc);
> +            gicc.cpu_interface_number = i;
> +            gicc.uid = i;
> +            gicc.flags = ACPI_MADT_ENABLED;
> +            gicc.base_address = d->arch.vgic.cbase;
> +
> +            do {
> +                mpidr |= (id % 4) << (8 * j);
> +                j++;
> +                if ( j ==3 )
> +                    j++;
> +                id = id / 4;
> +            } while(id > 0);

You should be able to use vcpuid_to_vaffinity to calculate the vmpidr.


> +            gicc.arm_mpidr = mpidr;

We should probably copy the native value of "Processor Power Efficiency
Class" ?


> +            ACPI_MEMCPY(base_ptr + table_size, &gicc, sizeof(gicc));
> +            table_size += sizeof(gicc);
> +        }
> +    }
> +
> +    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
> +                              + acpi_get_table_offset(tbl_add, TBL_MADT);
> +    tbl_add[TBL_MADT].size = table_size;
> +
> +    return 0;
> +}
> +
>  static int acpi_create_fadt(struct domain *d, struct membank tbl_add[])
>  {
>      struct acpi_table_header *table = NULL;
> @@ -1463,6 +1557,10 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
>      if ( rc != 0 )
>          return rc;
>  
> +    rc = acpi_create_madt(d, tbl_add);
> +    if ( rc != 0 )
> +        return rc;
> +
>      return 0;
>  }
>  #else
> -- 
> 2.1.0
> 

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

* Re: [PATCH v3 43/62] arm/acpi: Prepare MADT table for Dom0
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-26 17:48   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-26 17:48 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, linux-arm-kernel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, david.vrabel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Copy and modify MADT table before passing it to Dom0. Copy
> dom0_max_vcpus of GICCs and GICD as well.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/domain_build.c | 98 +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 98 insertions(+)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index 5d03dc0..4591955 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -1359,6 +1359,100 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
>  #ifdef CONFIG_ACPI
>  #define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */
>  
> +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_madt_generic_distributor gicd;
> +    u64 table_size = sizeof(struct acpi_table_madt);
> +    acpi_status status;
> +    int i;
> +    u8 *base_ptr;
> +    u8 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
> +               + acpi_get_table_offset(tbl_add, TBL_MADT);
> +    ACPI_MEMCPY(base_ptr, table, table_size);
> +
> +    /* Add Generic Distributor */
> +    memset(&gicd, 0, sizeof(gicd));
> +    gicd.header.type = ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR;
> +    gicd.header.length = sizeof(gicd);
> +    gicd.base_address = d->arch.vgic.dbase;
> +    if ( d->arch.vgic.version == GIC_V2 )
> +        gicd.version = ACPI_MADT_GIC_VERSION_V2;
> +    else if ( d->arch.vgic.version == GIC_V3 )
> +        gicd.version = ACPI_MADT_GIC_VERSION_V3;
> +    else
> +        gicd.version = ACPI_MADT_GIC_VERSION_NONE;
> +    ACPI_MEMCPY(base_ptr + table_size, &gicd, sizeof(gicd));
> +
> +    table_size += sizeof(gicd);
> +
> +    if ( d->arch.vgic.version == GIC_V3 ) {
> +        /* Add Generic Redistributor */
> +        for ( i = 0; i < d->arch.vgic.nr_regions; i++ ) {

Coding style


> +            struct acpi_madt_generic_redistributor gicr;
> +
> +            memset(&gicr, 0, sizeof(gicr));
> +            gicr.header.type = ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR;
> +            gicr.header.length = sizeof(gicr);
> +            gicr.base_address = d->arch.vgic.rdist_regions[i].base;
> +            gicr.length = d->arch.vgic.rdist_regions[i].size;
> +            ACPI_MEMCPY(base_ptr + table_size, &gicr, sizeof(gicr));
> +            table_size += sizeof(gicr);
> +        }
> +    } else {
> +        /* Add Generic Interrupt */
> +        for ( i = 0; i < d->max_vcpus; i++ )
> +        {
> +            struct acpi_madt_generic_interrupt gicc;
> +            u64 mpidr = 0;
> +            u32 id = i, j = 0;
> +
> +            memset(&gicc, 0, sizeof(gicc));
> +            gicc.header.type = ACPI_MADT_TYPE_GENERIC_INTERRUPT;
> +            gicc.header.length = sizeof(gicc);
> +            gicc.cpu_interface_number = i;
> +            gicc.uid = i;
> +            gicc.flags = ACPI_MADT_ENABLED;
> +            gicc.base_address = d->arch.vgic.cbase;
> +
> +            do {
> +                mpidr |= (id % 4) << (8 * j);
> +                j++;
> +                if ( j ==3 )
> +                    j++;
> +                id = id / 4;
> +            } while(id > 0);

You should be able to use vcpuid_to_vaffinity to calculate the vmpidr.


> +            gicc.arm_mpidr = mpidr;

We should probably copy the native value of "Processor Power Efficiency
Class" ?


> +            ACPI_MEMCPY(base_ptr + table_size, &gicc, sizeof(gicc));
> +            table_size += sizeof(gicc);
> +        }
> +    }
> +
> +    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
> +                              + acpi_get_table_offset(tbl_add, TBL_MADT);
> +    tbl_add[TBL_MADT].size = table_size;
> +
> +    return 0;
> +}
> +
>  static int acpi_create_fadt(struct domain *d, struct membank tbl_add[])
>  {
>      struct acpi_table_header *table = NULL;
> @@ -1463,6 +1557,10 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
>      if ( rc != 0 )
>          return rc;
>  
> +    rc = acpi_create_madt(d, tbl_add);
> +    if ( rc != 0 )
> +        return rc;
> +
>      return 0;
>  }
>  #else
> -- 
> 2.1.0
> 

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

* [Xen-devel] [PATCH v3 42/62] arm/acpi: Prepare FADT table for Dom0
  2015-11-26 17:19   ` [Xen-devel] " Stefano Stabellini
  2015-11-27  9:50     ` Ian Campbell
@ 2015-11-27  9:50     ` Ian Campbell
  1 sibling, 0 replies; 426+ messages in thread
From: Ian Campbell @ 2015-11-27  9:50 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, 2015-11-26 at 17:19 +0000, Stefano Stabellini wrote:
> On Tue, 17 Nov 2015, shannon.zhao at linaro.org 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>
> > 
> > ?xen/arch/arm/domain_build.c | 45
> > +++++++++++++++++++++++++++++++++++++++++++++
> > ?1 file changed, 45 insertions(+)
> > 
> > diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> > index b5ed44c..5d03dc0 100644
> > --- a/xen/arch/arm/domain_build.c
> > +++ b/xen/arch/arm/domain_build.c
> > @@ -1357,6 +1357,46 @@ static int prepare_dtb(struct domain *d, struct
> > kernel_info *kinfo)
> > ?}
> > ?
> > ?#ifdef CONFIG_ACPI
> > +#define XEN_HYPERVISOR_ID 0x000058656E564D4D??/* "XenVMM" */
> 
> This needs to be documented somewhere. A new doc under docs/ might be
> enough.

Should (also?) probably be in xen/include/public/arch-arm.h in the same
"#if defined(__XEN__) || defined(__XEN_TOOLS__)" as the other guest non-ABI 
stuff[0] which is needed by both Xen and the toolstack.

We don't actually have ACPI guest support today, so the toolstack has no
current interest, but I think that is still a logical place for it do be
defined.

Ian.

[0] That is, stuff which is part of the current implementation but which is
exposed to guests through other means, e.g. DT or ACPI and not through the
use of the arch-arm.h public header.

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

* Re: [PATCH v3 42/62] arm/acpi: Prepare FADT table for Dom0
  2015-11-26 17:19   ` [Xen-devel] " Stefano Stabellini
@ 2015-11-27  9:50     ` Ian Campbell
  2015-11-27  9:50     ` [Xen-devel] " Ian Campbell
  1 sibling, 0 replies; 426+ messages in thread
From: Ian Campbell @ 2015-11-27  9:50 UTC (permalink / raw)
  To: Stefano Stabellini, shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ard.biesheuvel, andrew.cooper3,
	peter.huangpeng, xen-devel, julien.grall, stefano.stabellini,
	david.vrabel, jbeulich, zhaoshenglong, roger.pau,
	christoffer.dall, linux-arm-kernel

On Thu, 2015-11-26 at 17:19 +0000, Stefano Stabellini wrote:
> On Tue, 17 Nov 2015, shannon.zhao@linaro.org 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>
> > 
> >  xen/arch/arm/domain_build.c | 45
> > +++++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 45 insertions(+)
> > 
> > diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> > index b5ed44c..5d03dc0 100644
> > --- a/xen/arch/arm/domain_build.c
> > +++ b/xen/arch/arm/domain_build.c
> > @@ -1357,6 +1357,46 @@ static int prepare_dtb(struct domain *d, struct
> > kernel_info *kinfo)
> >  }
> >  
> >  #ifdef CONFIG_ACPI
> > +#define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */
> 
> This needs to be documented somewhere. A new doc under docs/ might be
> enough.

Should (also?) probably be in xen/include/public/arch-arm.h in the same
"#if defined(__XEN__) || defined(__XEN_TOOLS__)" as the other guest non-ABI 
stuff[0] which is needed by both Xen and the toolstack.

We don't actually have ACPI guest support today, so the toolstack has no
current interest, but I think that is still a logical place for it do be
defined.

Ian.

[0] That is, stuff which is part of the current implementation but which is
exposed to guests through other means, e.g. DT or ACPI and not through the
use of the arch-arm.h public header.


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

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

* [PATCH v3 44/62] ACPICA: ACPI 6.0: Add support for STAO table
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-27 11:15   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-27 11:15 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> From: Bob Moore <robert.moore@intel.com>
> 
> ACPICA commit 532bf402a503061afd9d80a23e1d3c8fd99b052c
> 
> _STA override table.
> 
> Link: https://github.com/acpica/acpica/commit/532bf402
> Signed-off-by: Bob Moore <robert.moore@intel.com>
> Signed-off-by: Lv Zheng <lv.zheng@intel.com>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> [Linux commit 37e12657f8922ebc62f696494c56c81db509053e]
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

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


>  xen/include/acpi/actbl3.h | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/xen/include/acpi/actbl3.h b/xen/include/acpi/actbl3.h
> index fc96963..cb9e1c0 100644
> --- a/xen/include/acpi/actbl3.h
> +++ b/xen/include/acpi/actbl3.h
> @@ -68,6 +68,7 @@
>  #define ACPI_SIG_PCCT           "PCCT"	/* Platform Communications Channel Table */
>  #define ACPI_SIG_PMTT           "PMTT"	/* Platform Memory Topology Table */
>  #define ACPI_SIG_RASF           "RASF"	/* RAS Feature table */
> +#define ACPI_SIG_STAO           "STAO" /* Status Override table */
>  
>  #define ACPI_SIG_S3PT           "S3PT"	/* S3 Performance (sub)Table */
>  #define ACPI_SIG_PCCS           "PCC"	/* PCC Shared Memory Region */
> @@ -618,6 +619,21 @@ enum acpi_rasf_status {
>  #define ACPI_RASF_ERROR                 (1<<2)
>  #define ACPI_RASF_STATUS                (0x1F<<3)
>  
> +/*******************************************************************************
> + *
> + * STAO - Status Override Table (_STA override) - ACPI 6.0
> + *        Version 1
> + *
> + * Conforms to "ACPI Specification for Status Override Table"
> + * 6 January 2015
> + *
> + ******************************************************************************/
> +
> +struct acpi_table_stao {
> +	struct acpi_table_header header;	/* Common ACPI table header */
> +	u8 ignore_uart;
> +};
> +
>  /* Reset to default packing */
>  
>  #pragma pack()
> -- 
> 2.1.0
> 

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

* Re: [PATCH v3 44/62] ACPICA: ACPI 6.0: Add support for STAO table
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-27 11:15   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-27 11:15 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, linux-arm-kernel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, david.vrabel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> From: Bob Moore <robert.moore@intel.com>
> 
> ACPICA commit 532bf402a503061afd9d80a23e1d3c8fd99b052c
> 
> _STA override table.
> 
> Link: https://github.com/acpica/acpica/commit/532bf402
> Signed-off-by: Bob Moore <robert.moore@intel.com>
> Signed-off-by: Lv Zheng <lv.zheng@intel.com>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> [Linux commit 37e12657f8922ebc62f696494c56c81db509053e]
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

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


>  xen/include/acpi/actbl3.h | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/xen/include/acpi/actbl3.h b/xen/include/acpi/actbl3.h
> index fc96963..cb9e1c0 100644
> --- a/xen/include/acpi/actbl3.h
> +++ b/xen/include/acpi/actbl3.h
> @@ -68,6 +68,7 @@
>  #define ACPI_SIG_PCCT           "PCCT"	/* Platform Communications Channel Table */
>  #define ACPI_SIG_PMTT           "PMTT"	/* Platform Memory Topology Table */
>  #define ACPI_SIG_RASF           "RASF"	/* RAS Feature table */
> +#define ACPI_SIG_STAO           "STAO" /* Status Override table */
>  
>  #define ACPI_SIG_S3PT           "S3PT"	/* S3 Performance (sub)Table */
>  #define ACPI_SIG_PCCS           "PCC"	/* PCC Shared Memory Region */
> @@ -618,6 +619,21 @@ enum acpi_rasf_status {
>  #define ACPI_RASF_ERROR                 (1<<2)
>  #define ACPI_RASF_STATUS                (0x1F<<3)
>  
> +/*******************************************************************************
> + *
> + * STAO - Status Override Table (_STA override) - ACPI 6.0
> + *        Version 1
> + *
> + * Conforms to "ACPI Specification for Status Override Table"
> + * 6 January 2015
> + *
> + ******************************************************************************/
> +
> +struct acpi_table_stao {
> +	struct acpi_table_header header;	/* Common ACPI table header */
> +	u8 ignore_uart;
> +};
> +
>  /* Reset to default packing */
>  
>  #pragma pack()
> -- 
> 2.1.0
> 

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

* [Xen-devel] [PATCH v3 45/62] arm/acpi: Prepare STAO table for Dom0
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-27 11:24   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-27 11:24 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org 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 | 43 +++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 43 insertions(+)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index 4591955..fb3f150 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -1359,6 +1359,45 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
>  #ifdef CONFIG_ACPI
>  #define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */
>  
> +static int acpi_create_stao(struct domain *d, struct membank tbl_add[])
> +{
> +    struct acpi_table_header *table = NULL;
> +    struct acpi_table_stao *stao = NULL;
> +    u64 table_size = sizeof(struct acpi_table_stao);
> +    acpi_status status;
> +    u8 *base_ptr;
> +    u8 checksum;
> +
> +    status = acpi_get_table(ACPI_SIG_MADT, 0, &table);

This needs a comment: why are we trying to get the MADT table while this
function is to create the STAO 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
> +               + acpi_get_table_offset(tbl_add, TBL_STAO);
> +    /* Copy header of one table, here use MADT */

Please move the comment above. This is just to copy the OEM fields, I
guess?


> +    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 = stao->header.checksum - checksum;
> +
> +    tbl_add[TBL_STAO].start = d->arch.efi_acpi_gpa
> +                              + acpi_get_table_offset(tbl_add, TBL_STAO);
> +    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;
> @@ -1561,6 +1600,10 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
>      if ( rc != 0 )
>          return rc;
>  
> +    rc = acpi_create_stao(d, tbl_add);
> +    if ( rc != 0 )
> +        return rc;
> +
>      return 0;
>  }
>  #else
> -- 
> 2.1.0
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel at lists.xen.org
> http://lists.xen.org/xen-devel
> 

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

* Re: [PATCH v3 45/62] arm/acpi: Prepare STAO table for Dom0
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-27 11:24   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-27 11:24 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, david.vrabel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org 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 | 43 +++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 43 insertions(+)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index 4591955..fb3f150 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -1359,6 +1359,45 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
>  #ifdef CONFIG_ACPI
>  #define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */
>  
> +static int acpi_create_stao(struct domain *d, struct membank tbl_add[])
> +{
> +    struct acpi_table_header *table = NULL;
> +    struct acpi_table_stao *stao = NULL;
> +    u64 table_size = sizeof(struct acpi_table_stao);
> +    acpi_status status;
> +    u8 *base_ptr;
> +    u8 checksum;
> +
> +    status = acpi_get_table(ACPI_SIG_MADT, 0, &table);

This needs a comment: why are we trying to get the MADT table while this
function is to create the STAO 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
> +               + acpi_get_table_offset(tbl_add, TBL_STAO);
> +    /* Copy header of one table, here use MADT */

Please move the comment above. This is just to copy the OEM fields, I
guess?


> +    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 = stao->header.checksum - checksum;
> +
> +    tbl_add[TBL_STAO].start = d->arch.efi_acpi_gpa
> +                              + acpi_get_table_offset(tbl_add, TBL_STAO);
> +    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;
> @@ -1561,6 +1600,10 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
>      if ( rc != 0 )
>          return rc;
>  
> +    rc = acpi_create_stao(d, tbl_add);
> +    if ( rc != 0 )
> +        return rc;
> +
>      return 0;
>  }
>  #else
> -- 
> 2.1.0
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
> 

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

* [Xen-devel] [PATCH v3 46/62] arm/acpi: Prepare XSDT table for Dom0
  2015-11-17  9:40   ` shannon.zhao
@ 2015-11-27 11:58     ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-27 11:58 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> 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>
> ---
>  xen/arch/arm/domain_build.c | 71 +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 71 insertions(+)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index fb3f150..894328f 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -1359,6 +1359,73 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
>  #ifdef CONFIG_ACPI
>  #define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */
>  
> +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) )

coding style


> +        {
> +            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));
> +
> +    table_size = table->length + sizeof(u64); /* Add place for STAO table */

Please move the comment above the line.
It looks like you took into account this additional u64 in
estimate_acpi_efi_size. Please add a comment there too.

For this patch, provided you fix the minor style issues:

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



> +    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;
> @@ -1604,6 +1671,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

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

* Re: [PATCH v3 46/62] arm/acpi: Prepare XSDT table for Dom0
@ 2015-11-27 11:58     ` Stefano Stabellini
  0 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-27 11:58 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, david.vrabel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> 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>
> ---
>  xen/arch/arm/domain_build.c | 71 +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 71 insertions(+)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index fb3f150..894328f 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -1359,6 +1359,73 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
>  #ifdef CONFIG_ACPI
>  #define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */
>  
> +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) )

coding style


> +        {
> +            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));
> +
> +    table_size = table->length + sizeof(u64); /* Add place for STAO table */

Please move the comment above the line.
It looks like you took into account this additional u64 in
estimate_acpi_efi_size. Please add a comment there too.

For this patch, provided you fix the minor style issues:

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



> +    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;
> @@ -1604,6 +1671,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

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

* [PATCH v3 47/62] arm/p2m: Add helper functions to map memory regions
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-27 12:04   ` Stefano Stabellini
  2015-11-30 15:22     ` Julien Grall
  2015-11-30 15:22     ` Julien Grall
  -1 siblings, 2 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-27 12:04 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> From: Parth Dixit <parth.dixit@linaro.org>
> 
> Create a helper function for mapping with cached attributes.
> 
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

You might be able to use the existing guest_physmap_add_entry and
guest_physmap_remove_page for your purposes.


>  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 e396c40..7a108d8 100644
> --- a/xen/arch/arm/p2m.c
> +++ b/xen/arch/arm/p2m.c
> @@ -1140,6 +1140,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,
> +                             d->arch.p2m.default_access);
> +}
> +
> +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,
> +                             d->arch.p2m.default_access);
> +}
> +
>  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 08bdce3..b6215f9 100644
> --- a/xen/include/asm-arm/p2m.h
> +++ b/xen/include/asm-arm/p2m.h
> @@ -158,6 +158,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.1.0
> 

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

* Re: [PATCH v3 47/62] arm/p2m: Add helper functions to map memory regions
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-27 12:04   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-27 12:04 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, linux-arm-kernel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, david.vrabel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> From: Parth Dixit <parth.dixit@linaro.org>
> 
> Create a helper function for mapping with cached attributes.
> 
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

You might be able to use the existing guest_physmap_add_entry and
guest_physmap_remove_page for your purposes.


>  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 e396c40..7a108d8 100644
> --- a/xen/arch/arm/p2m.c
> +++ b/xen/arch/arm/p2m.c
> @@ -1140,6 +1140,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,
> +                             d->arch.p2m.default_access);
> +}
> +
> +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,
> +                             d->arch.p2m.default_access);
> +}
> +
>  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 08bdce3..b6215f9 100644
> --- a/xen/include/asm-arm/p2m.h
> +++ b/xen/include/asm-arm/p2m.h
> @@ -158,6 +158,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.1.0
> 

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

* [PATCH v3 48/62] arm/acpi: Prepare RSDP table for Dom0
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-27 12:10   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-27 12:10 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> 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 894328f..6ae5761 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -1359,6 +1359,38 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
>  #ifdef CONFIG_ACPI
>  #define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */
>  
> +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;

You always did -= checksum in the other functions, let's keep a
consistent style.


> +
> +    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)
>  {
> @@ -1675,6 +1707,10 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
>      if ( rc != 0 )
>          return rc;
>  
> +    rc = acpi_create_rsdp(d, tbl_add);
> +    if ( rc != 0 )
> +        return rc;
> +
>      return 0;
>  }
>  #else
> -- 
> 2.1.0
> 

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

* Re: [PATCH v3 48/62] arm/acpi: Prepare RSDP table for Dom0
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-27 12:10   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-27 12:10 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, linux-arm-kernel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, david.vrabel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> 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 894328f..6ae5761 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -1359,6 +1359,38 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
>  #ifdef CONFIG_ACPI
>  #define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */
>  
> +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;

You always did -= checksum in the other functions, let's keep a
consistent style.


> +
> +    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)
>  {
> @@ -1675,6 +1707,10 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
>      if ( rc != 0 )
>          return rc;
>  
> +    rc = acpi_create_rsdp(d, tbl_add);
> +    if ( rc != 0 )
> +        return rc;
> +
>      return 0;
>  }
>  #else
> -- 
> 2.1.0
> 

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

* [PATCH v3 49/62] arm/acpi: Map rest tables for Dom0
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-27 12:16   ` Stefano Stabellini
  2015-11-30 15:25       ` Julien Grall
  -1 siblings, 1 reply; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-27 12:16 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Map other reused tables for Dom0.

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


> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/domain_build.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index 6ae5761..da4e271 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -1359,6 +1359,29 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
>  #ifdef CONFIG_ACPI
>  #define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */
>  
> +static void acpi_map_rest_tables(struct domain *d)

The name doesn't sound nice, "acpi_map_other_tables" would be better.
However this function is not actually mapping the other tables, it is
mapping *all* of them, including the original madt and fadt, right? I
think it would be best to avoid mapping the originals.


> +{
> +    int i;
> +    unsigned long res;
> +    u64 addr, size;

Add a comment that they are being mapped 1:1


> +    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[])
>  {
>  
> @@ -1711,6 +1734,8 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
>      if ( rc != 0 )
>          return rc;
>  
> +    acpi_map_rest_tables(d);
> +
>      return 0;
>  }
>  #else

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

* Re: [PATCH v3 49/62] arm/acpi: Map rest tables for Dom0
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-27 12:16   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-27 12:16 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, linux-arm-kernel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, david.vrabel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Map other reused tables for Dom0.

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


> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/domain_build.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index 6ae5761..da4e271 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -1359,6 +1359,29 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
>  #ifdef CONFIG_ACPI
>  #define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */
>  
> +static void acpi_map_rest_tables(struct domain *d)

The name doesn't sound nice, "acpi_map_other_tables" would be better.
However this function is not actually mapping the other tables, it is
mapping *all* of them, including the original madt and fadt, right? I
think it would be best to avoid mapping the originals.


> +{
> +    int i;
> +    unsigned long res;
> +    u64 addr, size;

Add a comment that they are being mapped 1:1


> +    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[])
>  {
>  
> @@ -1711,6 +1734,8 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
>      if ( rc != 0 )
>          return rc;
>  
> +    acpi_map_rest_tables(d);
> +
>      return 0;
>  }
>  #else

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

* [PATCH v3 51/62] arm/acpi: Prepare EFI system table for Dom0
  2015-11-17  9:40   ` shannon.zhao
                     ` (5 preceding siblings ...)
  (?)
@ 2015-11-27 14:13   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-27 14:13 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/domain_build.c |  2 ++
>  xen/common/efi/boot.c       | 64 +++++++++++++++++++++++++++++++++++++++++++++
>  xen/include/asm-arm/setup.h |  3 +++
>  3 files changed, 69 insertions(+)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index da4e271..9d667ea 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -1735,6 +1735,8 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
>          return rc;
>  
>      acpi_map_rest_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 6a48624..75835ae 100644
> --- a/xen/common/efi/boot.c
> +++ b/xen/common/efi/boot.c
> @@ -1192,6 +1192,70 @@ int __init estimate_efi_size(int mem_nr_banks)
>  
>      return size;
>  }
> +
> +static uint32_t __init xz_crc32(uint8_t *buf, size_t size, uint32_t crc)
> +{
> +    uint32_t xz_crc32_table[256];
> +    const uint32_t poly = 0xEDB88320;
> +    uint32_t i;
> +    uint32_t j;
> +    uint32_t r;
> +
> +    for (i = 0; i < 256; ++i) {
> +        r = i;
> +        for (j = 0; j < 8; ++j)
> +            r = (r >> 1) ^ (poly & ~((r & 1) - 1));
> +
> +        xz_crc32_table[i] = r;
> +    }
> +
> +    crc = ~crc;
> +    while (size != 0) {
> +            crc = xz_crc32_table[*buf++ ^ (crc & 0xFF)] ^ (crc >> 8);
> +            --size;
> +    }
> +
> +    return ~crc;
> +}

I agree with Julien that we should reuse the existing functions for this


> +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;
> +    EFI_SYSTEM_TABLE *est = (EFI_SYSTEM_TABLE *)maddr_to_virt(efi.est);
> +
> +    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;
> +
> +    memcpy((EFI_TABLE_HEADER *)&(efi_sys_tbl->Hdr),
> +           (EFI_TABLE_HEADER *)&(est->Hdr), sizeof(EFI_TABLE_HEADER));
> +    efi_sys_tbl->Hdr.HeaderSize = table_size;
> +
> +    efi_sys_tbl->FirmwareRevision = est->FirmwareRevision;
> +    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);
> +    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

I also agree with Julien that acpi_create_efi_system_table shouldn't be
here. You should be able to move the function to
xen/arch/arm/domain_build.c.

The rest is OK.


>  #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.1.0
> 

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

* Re: [PATCH v3 51/62] arm/acpi: Prepare EFI system table for Dom0
  2015-11-17  9:40   ` shannon.zhao
                     ` (4 preceding siblings ...)
  (?)
@ 2015-11-27 14:13   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-27 14:13 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, linux-arm-kernel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, david.vrabel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/domain_build.c |  2 ++
>  xen/common/efi/boot.c       | 64 +++++++++++++++++++++++++++++++++++++++++++++
>  xen/include/asm-arm/setup.h |  3 +++
>  3 files changed, 69 insertions(+)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index da4e271..9d667ea 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -1735,6 +1735,8 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
>          return rc;
>  
>      acpi_map_rest_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 6a48624..75835ae 100644
> --- a/xen/common/efi/boot.c
> +++ b/xen/common/efi/boot.c
> @@ -1192,6 +1192,70 @@ int __init estimate_efi_size(int mem_nr_banks)
>  
>      return size;
>  }
> +
> +static uint32_t __init xz_crc32(uint8_t *buf, size_t size, uint32_t crc)
> +{
> +    uint32_t xz_crc32_table[256];
> +    const uint32_t poly = 0xEDB88320;
> +    uint32_t i;
> +    uint32_t j;
> +    uint32_t r;
> +
> +    for (i = 0; i < 256; ++i) {
> +        r = i;
> +        for (j = 0; j < 8; ++j)
> +            r = (r >> 1) ^ (poly & ~((r & 1) - 1));
> +
> +        xz_crc32_table[i] = r;
> +    }
> +
> +    crc = ~crc;
> +    while (size != 0) {
> +            crc = xz_crc32_table[*buf++ ^ (crc & 0xFF)] ^ (crc >> 8);
> +            --size;
> +    }
> +
> +    return ~crc;
> +}

I agree with Julien that we should reuse the existing functions for this


> +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;
> +    EFI_SYSTEM_TABLE *est = (EFI_SYSTEM_TABLE *)maddr_to_virt(efi.est);
> +
> +    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;
> +
> +    memcpy((EFI_TABLE_HEADER *)&(efi_sys_tbl->Hdr),
> +           (EFI_TABLE_HEADER *)&(est->Hdr), sizeof(EFI_TABLE_HEADER));
> +    efi_sys_tbl->Hdr.HeaderSize = table_size;
> +
> +    efi_sys_tbl->FirmwareRevision = est->FirmwareRevision;
> +    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);
> +    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

I also agree with Julien that acpi_create_efi_system_table shouldn't be
here. You should be able to move the function to
xen/arch/arm/domain_build.c.

The rest is OK.


>  #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.1.0
> 

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

* [PATCH v3 52/62] arm/acpi: Prepare EFI memory descriptor for Dom0
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-27 14:30   ` Stefano Stabellini
  2015-12-31  7:40       ` Shannon Zhao
  -1 siblings, 1 reply; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-27 14:30 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org 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.
> 
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/domain_build.c |  2 ++
>  xen/common/efi/boot.c       | 48 +++++++++++++++++++++++++++++++++++++++++++++
>  xen/include/asm-arm/setup.h |  4 ++++
>  3 files changed, 54 insertions(+)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index 9d667ea..073c634 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -1737,6 +1737,8 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
>      acpi_map_rest_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_table,
> +                               &kinfo->mem, tbl_add);
>  
>      return 0;
>  }
> diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
> index 75835ae..ff2faed 100644
> --- a/xen/common/efi/boot.c
> +++ b/xen/common/efi/boot.c
> @@ -1256,6 +1256,54 @@ 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, void *efi_acpi_table,
> +                                       const struct meminfo *mem,
> +                                       struct membank tbl_add[])

This function shouldn't be in this file.



> +{
> +    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 + TBL_MMAX);
> +
> +    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 = mem->bank[i].size/PAGE_SIZE;

Use PAGE_SHIFT throughout the function.


> +        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 = acpi_mem.bank[i].size/PAGE_SIZE;
> +        memory_map[offset].Attribute = EFI_MEMORY_WB;
> +    }
> +
> +    for( i = 0; i < TBL_EFIT; i++, offset++ )
> +    {
> +        memory_map[offset].Type = EfiACPIReclaimMemory;
> +        memory_map[offset].PhysicalStart = tbl_add[i].start;
> +        memory_map[offset].NumberOfPages =tbl_add[i].size/PAGE_SIZE;
> +        memory_map[offset].Attribute = EFI_MEMORY_WB;
> +    }

Can't we just use a single EFI_MEMORY_DESCRIPTOR (or maybe 2, to cover
EfiACPIReclaimMemory and EfiReservedMemoryType regions) to describe the
whole efi_acpi_gpa region? Using one EFI_MEMORY_DESCRIPTOR per table,
and PAGE_ALIGNing each of them, looks like a waste of memory to me.
Unless it's an ACPI or EFI spec requirement.


> +    for( i = TBL_EFIT; i < TBL_MMAX; i++, offset++ )
> +    {
> +        memory_map[offset].Type = EfiReservedMemoryType;
> +        memory_map[offset].PhysicalStart = tbl_add[i].start;
> +        memory_map[offset].NumberOfPages =tbl_add[i].size/PAGE_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..35447ee 100644
> --- a/xen/include/asm-arm/setup.h
> +++ b/xen/include/asm-arm/setup.h
> @@ -56,6 +56,10 @@ 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, void *efi_acpi_table,
> +                                const struct meminfo *mem,
> +                                struct membank tbl_add[]);
> +
>  int construct_dom0(struct domain *d);
>  
>  void discard_initial_modules(void);
> -- 
> 2.1.0
> 

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

* Re: [PATCH v3 52/62] arm/acpi: Prepare EFI memory descriptor for Dom0
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-27 14:30   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-27 14:30 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, linux-arm-kernel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, david.vrabel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org 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.
> 
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/domain_build.c |  2 ++
>  xen/common/efi/boot.c       | 48 +++++++++++++++++++++++++++++++++++++++++++++
>  xen/include/asm-arm/setup.h |  4 ++++
>  3 files changed, 54 insertions(+)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index 9d667ea..073c634 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -1737,6 +1737,8 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
>      acpi_map_rest_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_table,
> +                               &kinfo->mem, tbl_add);
>  
>      return 0;
>  }
> diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
> index 75835ae..ff2faed 100644
> --- a/xen/common/efi/boot.c
> +++ b/xen/common/efi/boot.c
> @@ -1256,6 +1256,54 @@ 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, void *efi_acpi_table,
> +                                       const struct meminfo *mem,
> +                                       struct membank tbl_add[])

This function shouldn't be in this file.



> +{
> +    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 + TBL_MMAX);
> +
> +    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 = mem->bank[i].size/PAGE_SIZE;

Use PAGE_SHIFT throughout the function.


> +        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 = acpi_mem.bank[i].size/PAGE_SIZE;
> +        memory_map[offset].Attribute = EFI_MEMORY_WB;
> +    }
> +
> +    for( i = 0; i < TBL_EFIT; i++, offset++ )
> +    {
> +        memory_map[offset].Type = EfiACPIReclaimMemory;
> +        memory_map[offset].PhysicalStart = tbl_add[i].start;
> +        memory_map[offset].NumberOfPages =tbl_add[i].size/PAGE_SIZE;
> +        memory_map[offset].Attribute = EFI_MEMORY_WB;
> +    }

Can't we just use a single EFI_MEMORY_DESCRIPTOR (or maybe 2, to cover
EfiACPIReclaimMemory and EfiReservedMemoryType regions) to describe the
whole efi_acpi_gpa region? Using one EFI_MEMORY_DESCRIPTOR per table,
and PAGE_ALIGNing each of them, looks like a waste of memory to me.
Unless it's an ACPI or EFI spec requirement.


> +    for( i = TBL_EFIT; i < TBL_MMAX; i++, offset++ )
> +    {
> +        memory_map[offset].Type = EfiReservedMemoryType;
> +        memory_map[offset].PhysicalStart = tbl_add[i].start;
> +        memory_map[offset].NumberOfPages =tbl_add[i].size/PAGE_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..35447ee 100644
> --- a/xen/include/asm-arm/setup.h
> +++ b/xen/include/asm-arm/setup.h
> @@ -56,6 +56,10 @@ 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, void *efi_acpi_table,
> +                                const struct meminfo *mem,
> +                                struct membank tbl_add[]);
> +
>  int construct_dom0(struct domain *d);
>  
>  void discard_initial_modules(void);
> -- 
> 2.1.0
> 

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

* [PATCH v3 53/62] arm/acpi: Map the new created EFI and ACPI tables to Dom0
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-27 14:34   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-27 14:34 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Here we map these new created EFI and ACPI tables to the non-RAM space
> of Dom0. Then Dom0 could visit them.

"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 073c634..55f85b4 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -1740,6 +1740,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_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),
> +                     DIV_ROUND_UP(d->arch.efi_acpi_len, PAGE_SIZE),

PFN_UP


> +                     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.1.0
> 

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

* Re: [PATCH v3 53/62] arm/acpi: Map the new created EFI and ACPI tables to Dom0
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-27 14:34   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-27 14:34 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, linux-arm-kernel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, david.vrabel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Here we map these new created EFI and ACPI tables to the non-RAM space
> of Dom0. Then Dom0 could visit them.

"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 073c634..55f85b4 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -1740,6 +1740,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_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),
> +                     DIV_ROUND_UP(d->arch.efi_acpi_len, PAGE_SIZE),

PFN_UP


> +                     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.1.0
> 

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

* [Xen-devel] [PATCH v3 54/62] arm/acpi: Create min DT stub for Dom0
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-27 14:44   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-27 14:44 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org 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.
> 
> 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>

We should add a document under docs/misc/arm/device-tree for these
bindings.  This is an external interface maintained by Xen for
compatibility.


>  xen/arch/arm/domain_build.c | 142 ++++++++++++++++++++++++++++++++++++++++++++
>  xen/common/efi/boot.c       |  47 +++++++++++++++
>  xen/include/asm-arm/setup.h |   2 +
>  3 files changed, 191 insertions(+)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index 55f85b4..6d8536b 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -1358,6 +1358,144 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
>  
>  #ifdef CONFIG_ACPI
>  #define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */
> +#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_rest_tables(struct domain *d)
>  {
> @@ -1755,6 +1893,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 ff2faed..d233cef 100644
> --- a/xen/common/efi/boot.c
> +++ b/xen/common/efi/boot.c
> @@ -1304,6 +1304,53 @@ void __init acpi_create_efi_mmap_table(paddr_t paddr, void *efi_acpi_table,
>          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 shouldn't be in this file.


>  #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 35447ee..c4cf5ea 100644
> --- a/xen/include/asm-arm/setup.h
> +++ b/xen/include/asm-arm/setup.h
> @@ -60,6 +60,8 @@ void acpi_create_efi_mmap_table(paddr_t paddr, void *efi_acpi_table,
>                                  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.1.0
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel at lists.xen.org
> http://lists.xen.org/xen-devel
> 

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

* Re: [PATCH v3 54/62] arm/acpi: Create min DT stub for Dom0
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-27 14:44   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-27 14:44 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, david.vrabel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org 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.
> 
> 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>

We should add a document under docs/misc/arm/device-tree for these
bindings.  This is an external interface maintained by Xen for
compatibility.


>  xen/arch/arm/domain_build.c | 142 ++++++++++++++++++++++++++++++++++++++++++++
>  xen/common/efi/boot.c       |  47 +++++++++++++++
>  xen/include/asm-arm/setup.h |   2 +
>  3 files changed, 191 insertions(+)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index 55f85b4..6d8536b 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -1358,6 +1358,144 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
>  
>  #ifdef CONFIG_ACPI
>  #define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */
> +#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_rest_tables(struct domain *d)
>  {
> @@ -1755,6 +1893,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 ff2faed..d233cef 100644
> --- a/xen/common/efi/boot.c
> +++ b/xen/common/efi/boot.c
> @@ -1304,6 +1304,53 @@ void __init acpi_create_efi_mmap_table(paddr_t paddr, void *efi_acpi_table,
>          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 shouldn't be in this file.


>  #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 35447ee..c4cf5ea 100644
> --- a/xen/include/asm-arm/setup.h
> +++ b/xen/include/asm-arm/setup.h
> @@ -60,6 +60,8 @@ void acpi_create_efi_mmap_table(paddr_t paddr, void *efi_acpi_table,
>                                  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.1.0
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
> 

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

* [PATCH v3 56/62] arm/acpi: Deny MMIO access of UART
  2015-11-17 13:10     ` Shannon Zhao
@ 2015-11-27 14:50       ` Stefano Stabellini
  2015-11-27 14:50       ` Stefano Stabellini
                         ` (2 subsequent siblings)
  3 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-27 14:50 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, Shannon Zhao wrote:
> On 2015/11/17 20:04, Julien Grall wrote:
> > On 17/11/15 09:40, shannon.zhao at linaro.org wrote:
> >> From: Shannon Zhao <shannon.zhao@linaro.org>
> >>
> >> Firstly it permits full MMIO capabilities for Dom0. Then deny MMIO
> >> access of UART device.
> > 
> > I'm nearly sure we want to deny other MMIO such as the GIC regions and SMMU.
> > 
> But Dom0 will not know the real GIC hardware MMIO space, how would it
> map these regions? In case of wrong use?

It could try regions at random or by mistake.
I know that Dom0 is "trusted", but the less we trust it, the better.


> Regarding SMMU, since it doesn't support now, so I didn't add it but it
> could be added later.

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

* Re: [PATCH v3 56/62] arm/acpi: Deny MMIO access of UART
  2015-11-17 13:10     ` Shannon Zhao
  2015-11-27 14:50       ` Stefano Stabellini
@ 2015-11-27 14:50       ` Stefano Stabellini
  2015-11-30 15:30       ` Julien Grall
  2015-11-30 15:30       ` Julien Grall
  3 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-27 14:50 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: mark.rutland, hangaohuai, david.vrabel, keir, ian.campbell,
	ard.biesheuvel, andrew.cooper3, peter.huangpeng, xen-devel,
	Julien Grall, stefano.stabellini, shannon.zhao, jbeulich,
	roger.pau, christoffer.dall, linux-arm-kernel

On Tue, 17 Nov 2015, Shannon Zhao wrote:
> On 2015/11/17 20:04, Julien Grall wrote:
> > On 17/11/15 09:40, shannon.zhao@linaro.org wrote:
> >> From: Shannon Zhao <shannon.zhao@linaro.org>
> >>
> >> Firstly it permits full MMIO capabilities for Dom0. Then deny MMIO
> >> access of UART device.
> > 
> > I'm nearly sure we want to deny other MMIO such as the GIC regions and SMMU.
> > 
> But Dom0 will not know the real GIC hardware MMIO space, how would it
> map these regions? In case of wrong use?

It could try regions at random or by mistake.
I know that Dom0 is "trusted", but the less we trust it, the better.


> Regarding SMMU, since it doesn't support now, so I didn't add it but it
> could be added later.

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

* [PATCH v3 55/62] arm/acpi: Route all Xen unused SPIs to Dom0
  2015-11-17  9:40   ` shannon.zhao
                     ` (3 preceding siblings ...)
  (?)
@ 2015-11-27 15:04   ` Stefano Stabellini
  2015-11-30 15:41     ` Julien Grall
  2015-11-30 15:41     ` [Xen-devel] " Julien Grall
  -1 siblings, 2 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-27 15:04 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:

> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Route all SPIs to Dom0 except the interrupts that Xen uses. Since Xen
> already uses the uart interrupt, the desc->action will not be NULL, so
> it will skip it.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/domain_build.c | 33 +++++++++++++++++++++++++++++++++
>  1 file changed, 33 insertions(+)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index 6d8536b..6945f89 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -1360,6 +1360,35 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
>  #define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */
>  #define ACPI_DOM0_FDT_MIN_SIZE 4096
>  
> +static int acpi_route_spi(struct domain *d)
> +{
> +    int i, res;
> +    struct irq_desc *desc;
> +
> +    /* Don't route Xen used interrupt to Dom0. Since Xen already uses the uart
> +     * interrupt, the desc->action will not be NULL, so it will skip it.
> +     */
> +    for( i = NR_LOCAL_IRQS; i < vgic_num_irqs(d); i++ )
> +    {
> +        /* Don't route uart interrupt to Dom0 */
> +        desc = irq_to_desc(i);
> +        if( desc->action != NULL)
> +            continue;

Don't you need to call irq_permit_access too?


> +        vgic_reserve_virq(d, i);
> +        irq_set_type(i, ACPI_IRQ_TYPE_NONE);

I don't know if there is any point in setting the type to NONE. It's the
default, isn't it?


> +        res = route_irq_to_guest(d, i, i, NULL);
> +        if ( res )
> +        {
> +            printk(XENLOG_ERR "Unable to route IRQ %u to domain %u\n",
> +                   i, d->domain_id);
> +            continue;
> +        }
> +    }
> +
> +    return 0;
> +}
> +
>  static int make_chosen_node(const struct kernel_info *kinfo,
>                              struct membank tbl_add[])
>  {
> @@ -1897,6 +1926,10 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
>      if ( rc != 0 )
>          return rc;
>  
> +    rc = acpi_route_spi(d);
> +    if ( rc != 0 )
> +        return rc;
> +
>      return 0;
>  }
>  #else
> -- 
> 2.1.0
> 

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

* Re: [PATCH v3 55/62] arm/acpi: Route all Xen unused SPIs to Dom0
  2015-11-17  9:40   ` shannon.zhao
                     ` (2 preceding siblings ...)
  (?)
@ 2015-11-27 15:04   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-27 15:04 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, linux-arm-kernel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, david.vrabel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:

> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Route all SPIs to Dom0 except the interrupts that Xen uses. Since Xen
> already uses the uart interrupt, the desc->action will not be NULL, so
> it will skip it.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/domain_build.c | 33 +++++++++++++++++++++++++++++++++
>  1 file changed, 33 insertions(+)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index 6d8536b..6945f89 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -1360,6 +1360,35 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
>  #define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */
>  #define ACPI_DOM0_FDT_MIN_SIZE 4096
>  
> +static int acpi_route_spi(struct domain *d)
> +{
> +    int i, res;
> +    struct irq_desc *desc;
> +
> +    /* Don't route Xen used interrupt to Dom0. Since Xen already uses the uart
> +     * interrupt, the desc->action will not be NULL, so it will skip it.
> +     */
> +    for( i = NR_LOCAL_IRQS; i < vgic_num_irqs(d); i++ )
> +    {
> +        /* Don't route uart interrupt to Dom0 */
> +        desc = irq_to_desc(i);
> +        if( desc->action != NULL)
> +            continue;

Don't you need to call irq_permit_access too?


> +        vgic_reserve_virq(d, i);
> +        irq_set_type(i, ACPI_IRQ_TYPE_NONE);

I don't know if there is any point in setting the type to NONE. It's the
default, isn't it?


> +        res = route_irq_to_guest(d, i, i, NULL);
> +        if ( res )
> +        {
> +            printk(XENLOG_ERR "Unable to route IRQ %u to domain %u\n",
> +                   i, d->domain_id);
> +            continue;
> +        }
> +    }
> +
> +    return 0;
> +}
> +
>  static int make_chosen_node(const struct kernel_info *kinfo,
>                              struct membank tbl_add[])
>  {
> @@ -1897,6 +1926,10 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
>      if ( rc != 0 )
>          return rc;
>  
> +    rc = acpi_route_spi(d);
> +    if ( rc != 0 )
> +        return rc;
> +
>      return 0;
>  }
>  #else
> -- 
> 2.1.0
> 

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

* [PATCH v3 58/62] xen/acpi: Fix event-channel interrupt when booting with ACPI
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-27 15:12   ` Stefano Stabellini
  2015-11-30 15:30       ` Julien Grall
  -1 siblings, 1 reply; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-27 15:12 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> When booting with ACPI, 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>
> ---
>  xen/arch/arm/domain_build.c | 45 ++++++++++++++++++++++++++++-----------------
>  1 file changed, 28 insertions(+), 17 deletions(-)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index 9532807..36917be 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -2067,23 +2067,34 @@ static void evtchn_fixup(struct domain *d, struct kernel_info *kinfo)
>      printk("Allocating PPI %u for event channel interrupt\n",
>             d->arch.evtchn_irq);
>  
> -    /* Fix up "interrupts" in /hypervisor node */
> -    node = fdt_path_offset(kinfo->fdt, "/hypervisor");
> -    if ( node < 0 )
> -        panic("Cannot find the /hypervisor node");
> -
> -    /* Interrupt event channel upcall:
> -     *  - Active-low level-sensitive
> -     *  - All CPUs
> -     *
> -     *  TODO: Handle properly the cpumask
> -     */
> -    set_interrupt_ppi(intr, d->arch.evtchn_irq, 0xf,
> -                      DT_IRQ_TYPE_LEVEL_LOW);
> -    res = fdt_setprop_inplace(kinfo->fdt, node, "interrupts",
> -                              &intr, sizeof(intr));
> -    if ( res )
> -        panic("Cannot fix up \"interrupts\" property of the hypervisor node");
> +    if ( acpi_disabled )
> +    {
> +        /* Fix up "interrupts" in /hypervisor node */
> +        node = fdt_path_offset(kinfo->fdt, "/hypervisor");
> +        if ( node < 0 )
> +            panic("Cannot find the /hypervisor node");
> +
> +        /* Interrupt event channel upcall:
> +         *  - Active-low level-sensitive
> +         *  - All CPUs
> +         *
> +         *  TODO: Handle properly the cpumask
> +         */
> +        set_interrupt_ppi(intr, d->arch.evtchn_irq, 0xf,
> +                          DT_IRQ_TYPE_LEVEL_LOW);
> +        res = fdt_setprop_inplace(kinfo->fdt, node, "interrupts",
> +                                  &intr, sizeof(intr));
> +        if ( res )
> +            panic("Cannot fix up \"interrupts\" property of the hypervisor node");

This code could be moved out to a dt_set_evtchn_irq function


> +    }
> +    else
> +    {
> +        int type = 3;
> +        int flag = 2; /* Active-low level-sensitive  */
> +        d->arch.hvm_domain.params[HVM_PARAM_CALLBACK_IRQ] = (u64)type << 56
> +                                                            | flag << 8
> +                                                            | d->arch.evtchn_irq;
> +    }
>  }

Actually there is no point in setting HVM_PARAM_CALLBACK_IRQ only on
ACPI: I would just set it on all cases.

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

* Re: [PATCH v3 58/62] xen/acpi: Fix event-channel interrupt when booting with ACPI
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-27 15:12   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-27 15:12 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, linux-arm-kernel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, david.vrabel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> When booting with ACPI, 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>
> ---
>  xen/arch/arm/domain_build.c | 45 ++++++++++++++++++++++++++++-----------------
>  1 file changed, 28 insertions(+), 17 deletions(-)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index 9532807..36917be 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -2067,23 +2067,34 @@ static void evtchn_fixup(struct domain *d, struct kernel_info *kinfo)
>      printk("Allocating PPI %u for event channel interrupt\n",
>             d->arch.evtchn_irq);
>  
> -    /* Fix up "interrupts" in /hypervisor node */
> -    node = fdt_path_offset(kinfo->fdt, "/hypervisor");
> -    if ( node < 0 )
> -        panic("Cannot find the /hypervisor node");
> -
> -    /* Interrupt event channel upcall:
> -     *  - Active-low level-sensitive
> -     *  - All CPUs
> -     *
> -     *  TODO: Handle properly the cpumask
> -     */
> -    set_interrupt_ppi(intr, d->arch.evtchn_irq, 0xf,
> -                      DT_IRQ_TYPE_LEVEL_LOW);
> -    res = fdt_setprop_inplace(kinfo->fdt, node, "interrupts",
> -                              &intr, sizeof(intr));
> -    if ( res )
> -        panic("Cannot fix up \"interrupts\" property of the hypervisor node");
> +    if ( acpi_disabled )
> +    {
> +        /* Fix up "interrupts" in /hypervisor node */
> +        node = fdt_path_offset(kinfo->fdt, "/hypervisor");
> +        if ( node < 0 )
> +            panic("Cannot find the /hypervisor node");
> +
> +        /* Interrupt event channel upcall:
> +         *  - Active-low level-sensitive
> +         *  - All CPUs
> +         *
> +         *  TODO: Handle properly the cpumask
> +         */
> +        set_interrupt_ppi(intr, d->arch.evtchn_irq, 0xf,
> +                          DT_IRQ_TYPE_LEVEL_LOW);
> +        res = fdt_setprop_inplace(kinfo->fdt, node, "interrupts",
> +                                  &intr, sizeof(intr));
> +        if ( res )
> +            panic("Cannot fix up \"interrupts\" property of the hypervisor node");

This code could be moved out to a dt_set_evtchn_irq function


> +    }
> +    else
> +    {
> +        int type = 3;
> +        int flag = 2; /* Active-low level-sensitive  */
> +        d->arch.hvm_domain.params[HVM_PARAM_CALLBACK_IRQ] = (u64)type << 56
> +                                                            | flag << 8
> +                                                            | d->arch.evtchn_irq;
> +    }
>  }

Actually there is no point in setting HVM_PARAM_CALLBACK_IRQ only on
ACPI: I would just set it on all cases.

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

* [Xen-devel] [PATCH v3 62/62] xen/arm64: Add ACPI support
  2015-11-17  9:41   ` shannon.zhao
@ 2015-11-27 15:16     ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-27 15:16 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org 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>
> ---
>  config/arm64.mk              | 1 +
>  xen/common/efi/runtime.c     | 2 +-
>  xen/include/asm-arm/config.h | 5 +++++
>  3 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/config/arm64.mk b/config/arm64.mk
> index c5deb4e..c6a040b 100644
> --- a/config/arm64.mk
> +++ b/config/arm64.mk
> @@ -11,6 +11,7 @@ HAS_CADENCE_UART := y
>  HAS_NS16550 := y
>  HAS_MEM_ACCESS := y
>  HAS_GICV3 := y
> +HAS_ACPI := y
>  
>  # Use only if calling $(LD) directly.
>  LDFLAGS_DIRECT += -EL
> diff --git a/xen/common/efi/runtime.c b/xen/common/efi/runtime.c
> index ae87557..7748056 100644
> --- a/xen/common/efi/runtime.c
> +++ b/xen/common/efi/runtime.c
> @@ -11,7 +11,7 @@ DEFINE_XEN_GUEST_HANDLE(CHAR16);
>  #ifndef COMPAT
>  
>  #ifdef CONFIG_ARM  /* Disabled until runtime services implemented */
> -const bool_t efi_enabled = 0;
> +const bool_t efi_enabled = 1;

Don't we want to remove the comment at least?
We should also document under docs/ what is the supported interface to
access runtime services.


>  #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 817c216..e87fd27 100644
> --- a/xen/include/asm-arm/config.h
> +++ b/xen/include/asm-arm/config.h
> @@ -33,6 +33,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.1.0
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel at lists.xen.org
> http://lists.xen.org/xen-devel
> 

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

* Re: [PATCH v3 62/62] xen/arm64: Add ACPI support
@ 2015-11-27 15:16     ` Stefano Stabellini
  0 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-27 15:16 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, david.vrabel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org 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>
> ---
>  config/arm64.mk              | 1 +
>  xen/common/efi/runtime.c     | 2 +-
>  xen/include/asm-arm/config.h | 5 +++++
>  3 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/config/arm64.mk b/config/arm64.mk
> index c5deb4e..c6a040b 100644
> --- a/config/arm64.mk
> +++ b/config/arm64.mk
> @@ -11,6 +11,7 @@ HAS_CADENCE_UART := y
>  HAS_NS16550 := y
>  HAS_MEM_ACCESS := y
>  HAS_GICV3 := y
> +HAS_ACPI := y
>  
>  # Use only if calling $(LD) directly.
>  LDFLAGS_DIRECT += -EL
> diff --git a/xen/common/efi/runtime.c b/xen/common/efi/runtime.c
> index ae87557..7748056 100644
> --- a/xen/common/efi/runtime.c
> +++ b/xen/common/efi/runtime.c
> @@ -11,7 +11,7 @@ DEFINE_XEN_GUEST_HANDLE(CHAR16);
>  #ifndef COMPAT
>  
>  #ifdef CONFIG_ARM  /* Disabled until runtime services implemented */
> -const bool_t efi_enabled = 0;
> +const bool_t efi_enabled = 1;

Don't we want to remove the comment at least?
We should also document under docs/ what is the supported interface to
access runtime services.


>  #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 817c216..e87fd27 100644
> --- a/xen/include/asm-arm/config.h
> +++ b/xen/include/asm-arm/config.h
> @@ -33,6 +33,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.1.0
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
> 

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

* [PATCH v3 60/62] arm/acpi: Configure interrupts dynamically
  2015-11-17  9:40   ` shannon.zhao
  (?)
  (?)
@ 2015-11-27 16:13   ` Stefano Stabellini
  2015-11-27 16:19     ` Stefano Stabellini
  2015-11-27 16:19     ` Stefano Stabellini
  -1 siblings, 2 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-27 16:13 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> From: Parth Dixit <parth.dixit@linaro.org>
> 
> Interrupt information is described in DSDT and is not available at
> the time of booting. Configure the interrupts dynamically when requested
> by Dom0
> 
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/vgic.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c
> index 7bb4570..d05abde 100644
> --- a/xen/arch/arm/vgic.c
> +++ b/xen/arch/arm/vgic.c
> @@ -25,6 +25,7 @@
>  #include <xen/irq.h>
>  #include <xen/sched.h>
>  #include <xen/perfc.h>
> +#include <xen/acpi.h>
>  
>  #include <asm/current.h>
>  
> @@ -310,6 +311,8 @@ void vgic_disable_irqs(struct vcpu *v, uint32_t r, int n)
>      }
>  }
>  
> +#define VGIC_ICFG_MASK(intr) ( 1 << ( ( 2 * ( intr % 16 ) ) + 1 ) )

Coding style.


>  void vgic_enable_irqs(struct vcpu *v, uint32_t r, int n)
>  {
>      struct domain *d = v->domain;
> @@ -321,7 +324,23 @@ void vgic_enable_irqs(struct vcpu *v, uint32_t r, int n)
>      struct vcpu *v_target;
>  
>      while ( (i = find_next_bit(&mask, 32, i)) < 32 ) {
> +#ifdef CONFIG_ACPI
> +        struct vgic_irq_rank *vr = vgic_get_rank(v, n);

The rank is always the same, you can move this out of the while loop.


> +        uint32_t tr;
> +
>          irq = i + (32 * n);
> +        if( ( !acpi_disabled ) && ( n != 0 ) && is_hardware_domain(d) )

Instead of n != 0, I would prefer a more obvious irq >= 32 check


> +        {
> +            tr = vr->icfg[i >> 4] ;
> +
> +            if( ( tr & VGIC_ICFG_MASK(i) ) )

Coding style.


> +                irq_set_type(irq, ACPI_IRQ_TYPE_EDGE_BOTH);
> +            else
> +                irq_set_type(irq, ACPI_IRQ_TYPE_LEVEL_MASK);

Instead of this ad-hoc ACPI code, I would prefer if we get the irq type
and, if it is set to NONE or INVALID, we set it to what is in the
r->icfg (only for the hardware_domain of course). If it is set to
something other than NONE or INVALID, and it doesn't match what is on
r->icfg, then we could print out a warning.


> +        }
> +#else
> +        irq = i + (32 * n);
> +#endif

Please leave the irq = i + (32 * n) out of the #ifdef.


>          v_target = d->arch.vgic.handler->get_target_vcpu(v, irq);
>          p = irq_to_pending(v_target, irq);
>          set_bit(GIC_IRQ_GUEST_ENABLED, &p->status);
> -- 
> 2.1.0
> 

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

* Re: [PATCH v3 60/62] arm/acpi: Configure interrupts dynamically
  2015-11-17  9:40   ` shannon.zhao
  (?)
@ 2015-11-27 16:13   ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-27 16:13 UTC (permalink / raw)
  To: shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, linux-arm-kernel, jbeulich, zhaoshenglong,
	roger.pau, christoffer.dall, david.vrabel

On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> From: Parth Dixit <parth.dixit@linaro.org>
> 
> Interrupt information is described in DSDT and is not available at
> the time of booting. Configure the interrupts dynamically when requested
> by Dom0
> 
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/vgic.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c
> index 7bb4570..d05abde 100644
> --- a/xen/arch/arm/vgic.c
> +++ b/xen/arch/arm/vgic.c
> @@ -25,6 +25,7 @@
>  #include <xen/irq.h>
>  #include <xen/sched.h>
>  #include <xen/perfc.h>
> +#include <xen/acpi.h>
>  
>  #include <asm/current.h>
>  
> @@ -310,6 +311,8 @@ void vgic_disable_irqs(struct vcpu *v, uint32_t r, int n)
>      }
>  }
>  
> +#define VGIC_ICFG_MASK(intr) ( 1 << ( ( 2 * ( intr % 16 ) ) + 1 ) )

Coding style.


>  void vgic_enable_irqs(struct vcpu *v, uint32_t r, int n)
>  {
>      struct domain *d = v->domain;
> @@ -321,7 +324,23 @@ void vgic_enable_irqs(struct vcpu *v, uint32_t r, int n)
>      struct vcpu *v_target;
>  
>      while ( (i = find_next_bit(&mask, 32, i)) < 32 ) {
> +#ifdef CONFIG_ACPI
> +        struct vgic_irq_rank *vr = vgic_get_rank(v, n);

The rank is always the same, you can move this out of the while loop.


> +        uint32_t tr;
> +
>          irq = i + (32 * n);
> +        if( ( !acpi_disabled ) && ( n != 0 ) && is_hardware_domain(d) )

Instead of n != 0, I would prefer a more obvious irq >= 32 check


> +        {
> +            tr = vr->icfg[i >> 4] ;
> +
> +            if( ( tr & VGIC_ICFG_MASK(i) ) )

Coding style.


> +                irq_set_type(irq, ACPI_IRQ_TYPE_EDGE_BOTH);
> +            else
> +                irq_set_type(irq, ACPI_IRQ_TYPE_LEVEL_MASK);

Instead of this ad-hoc ACPI code, I would prefer if we get the irq type
and, if it is set to NONE or INVALID, we set it to what is in the
r->icfg (only for the hardware_domain of course). If it is set to
something other than NONE or INVALID, and it doesn't match what is on
r->icfg, then we could print out a warning.


> +        }
> +#else
> +        irq = i + (32 * n);
> +#endif

Please leave the irq = i + (32 * n) out of the #ifdef.


>          v_target = d->arch.vgic.handler->get_target_vcpu(v, irq);
>          p = irq_to_pending(v_target, irq);
>          set_bit(GIC_IRQ_GUEST_ENABLED, &p->status);
> -- 
> 2.1.0
> 

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

* [PATCH v3 60/62] arm/acpi: Configure interrupts dynamically
  2015-11-27 16:13   ` Stefano Stabellini
  2015-11-27 16:19     ` Stefano Stabellini
@ 2015-11-27 16:19     ` Stefano Stabellini
  1 sibling, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-27 16:19 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, 27 Nov 2015, Stefano Stabellini wrote:
> On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> > From: Parth Dixit <parth.dixit@linaro.org>
> > 
> > Interrupt information is described in DSDT and is not available at
> > the time of booting. Configure the interrupts dynamically when requested
> > by Dom0

Actually wouldn't it make more sense to configure the physical
interrupts when dom0 writes to the virtual ICFG registers?


> > Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> > ---
> >  xen/arch/arm/vgic.c | 19 +++++++++++++++++++
> >  1 file changed, 19 insertions(+)
> > 
> > diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c
> > index 7bb4570..d05abde 100644
> > --- a/xen/arch/arm/vgic.c
> > +++ b/xen/arch/arm/vgic.c
> > @@ -25,6 +25,7 @@
> >  #include <xen/irq.h>
> >  #include <xen/sched.h>
> >  #include <xen/perfc.h>
> > +#include <xen/acpi.h>
> >  
> >  #include <asm/current.h>
> >  
> > @@ -310,6 +311,8 @@ void vgic_disable_irqs(struct vcpu *v, uint32_t r, int n)
> >      }
> >  }
> >  
> > +#define VGIC_ICFG_MASK(intr) ( 1 << ( ( 2 * ( intr % 16 ) ) + 1 ) )
> 
> Coding style.
> 
> 
> >  void vgic_enable_irqs(struct vcpu *v, uint32_t r, int n)
> >  {
> >      struct domain *d = v->domain;
> > @@ -321,7 +324,23 @@ void vgic_enable_irqs(struct vcpu *v, uint32_t r, int n)
> >      struct vcpu *v_target;
> >  
> >      while ( (i = find_next_bit(&mask, 32, i)) < 32 ) {
> > +#ifdef CONFIG_ACPI
> > +        struct vgic_irq_rank *vr = vgic_get_rank(v, n);
> 
> The rank is always the same, you can move this out of the while loop.
> 
> 
> > +        uint32_t tr;
> > +
> >          irq = i + (32 * n);
> > +        if( ( !acpi_disabled ) && ( n != 0 ) && is_hardware_domain(d) )
> 
> Instead of n != 0, I would prefer a more obvious irq >= 32 check
> 
> 
> > +        {
> > +            tr = vr->icfg[i >> 4] ;
> > +
> > +            if( ( tr & VGIC_ICFG_MASK(i) ) )
> 
> Coding style.
> 
> 
> > +                irq_set_type(irq, ACPI_IRQ_TYPE_EDGE_BOTH);
> > +            else
> > +                irq_set_type(irq, ACPI_IRQ_TYPE_LEVEL_MASK);
> 
> Instead of this ad-hoc ACPI code, I would prefer if we get the irq type
> and, if it is set to NONE or INVALID, we set it to what is in the
> r->icfg (only for the hardware_domain of course). If it is set to
> something other than NONE or INVALID, and it doesn't match what is on
> r->icfg, then we could print out a warning.
> 
> 
> > +        }
> > +#else
> > +        irq = i + (32 * n);
> > +#endif
> 
> Please leave the irq = i + (32 * n) out of the #ifdef.
> 
> 
> >          v_target = d->arch.vgic.handler->get_target_vcpu(v, irq);
> >          p = irq_to_pending(v_target, irq);
> >          set_bit(GIC_IRQ_GUEST_ENABLED, &p->status);
> > -- 
> > 2.1.0
> > 
> 

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

* Re: [PATCH v3 60/62] arm/acpi: Configure interrupts dynamically
  2015-11-27 16:13   ` Stefano Stabellini
@ 2015-11-27 16:19     ` Stefano Stabellini
  2015-11-27 16:19     ` Stefano Stabellini
  1 sibling, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2015-11-27 16:19 UTC (permalink / raw)
  To: Stefano Stabellini
  Cc: mark.rutland, hangaohuai, david.vrabel, keir, ian.campbell,
	ard.biesheuvel, andrew.cooper3, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, shannon.zhao, jbeulich,
	zhaoshenglong, roger.pau, christoffer.dall, linux-arm-kernel

On Fri, 27 Nov 2015, Stefano Stabellini wrote:
> On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> > From: Parth Dixit <parth.dixit@linaro.org>
> > 
> > Interrupt information is described in DSDT and is not available at
> > the time of booting. Configure the interrupts dynamically when requested
> > by Dom0

Actually wouldn't it make more sense to configure the physical
interrupts when dom0 writes to the virtual ICFG registers?


> > Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> > ---
> >  xen/arch/arm/vgic.c | 19 +++++++++++++++++++
> >  1 file changed, 19 insertions(+)
> > 
> > diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c
> > index 7bb4570..d05abde 100644
> > --- a/xen/arch/arm/vgic.c
> > +++ b/xen/arch/arm/vgic.c
> > @@ -25,6 +25,7 @@
> >  #include <xen/irq.h>
> >  #include <xen/sched.h>
> >  #include <xen/perfc.h>
> > +#include <xen/acpi.h>
> >  
> >  #include <asm/current.h>
> >  
> > @@ -310,6 +311,8 @@ void vgic_disable_irqs(struct vcpu *v, uint32_t r, int n)
> >      }
> >  }
> >  
> > +#define VGIC_ICFG_MASK(intr) ( 1 << ( ( 2 * ( intr % 16 ) ) + 1 ) )
> 
> Coding style.
> 
> 
> >  void vgic_enable_irqs(struct vcpu *v, uint32_t r, int n)
> >  {
> >      struct domain *d = v->domain;
> > @@ -321,7 +324,23 @@ void vgic_enable_irqs(struct vcpu *v, uint32_t r, int n)
> >      struct vcpu *v_target;
> >  
> >      while ( (i = find_next_bit(&mask, 32, i)) < 32 ) {
> > +#ifdef CONFIG_ACPI
> > +        struct vgic_irq_rank *vr = vgic_get_rank(v, n);
> 
> The rank is always the same, you can move this out of the while loop.
> 
> 
> > +        uint32_t tr;
> > +
> >          irq = i + (32 * n);
> > +        if( ( !acpi_disabled ) && ( n != 0 ) && is_hardware_domain(d) )
> 
> Instead of n != 0, I would prefer a more obvious irq >= 32 check
> 
> 
> > +        {
> > +            tr = vr->icfg[i >> 4] ;
> > +
> > +            if( ( tr & VGIC_ICFG_MASK(i) ) )
> 
> Coding style.
> 
> 
> > +                irq_set_type(irq, ACPI_IRQ_TYPE_EDGE_BOTH);
> > +            else
> > +                irq_set_type(irq, ACPI_IRQ_TYPE_LEVEL_MASK);
> 
> Instead of this ad-hoc ACPI code, I would prefer if we get the irq type
> and, if it is set to NONE or INVALID, we set it to what is in the
> r->icfg (only for the hardware_domain of course). If it is set to
> something other than NONE or INVALID, and it doesn't match what is on
> r->icfg, then we could print out a warning.
> 
> 
> > +        }
> > +#else
> > +        irq = i + (32 * n);
> > +#endif
> 
> Please leave the irq = i + (32 * n) out of the #ifdef.
> 
> 
> >          v_target = d->arch.vgic.handler->get_target_vcpu(v, irq);
> >          p = irq_to_pending(v_target, irq);
> >          set_bit(GIC_IRQ_GUEST_ENABLED, &p->status);
> > -- 
> > 2.1.0
> > 
> 

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

* [Xen-devel] [PATCH v3 07/62] arm/acpi: Add arch_acpi_os_map_memory helper function for ARM
  2015-11-23 11:37   ` Stefano Stabellini
  2015-11-30 14:47     ` Julien Grall
@ 2015-11-30 14:47     ` Julien Grall
  2015-12-07  8:58         ` Shannon Zhao
  1 sibling, 1 reply; 426+ messages in thread
From: Julien Grall @ 2015-11-30 14:47 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

On 23/11/15 11:37, Stefano Stabellini wrote:
> On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
>> From: Shannon Zhao <shannon.zhao@linaro.org>

> could you please add a couple of lines to the commit message mentioning
> why __va(phys) is an acceptable implementation of arch_acpi_os_map_memory?

FWIW, I already asked this question multiple time on the previous series
without clear answer.

__va should only be used when the memory is direct-mapped to Xen (i.e
accessible directly). On ARM64, this is only the case for the RAM. Can
someone confirm the ACPI will always reside to the RAM?

Regards,

-- 
Julien Grall

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

* Re: [PATCH v3 07/62] arm/acpi: Add arch_acpi_os_map_memory helper function for ARM
  2015-11-23 11:37   ` Stefano Stabellini
@ 2015-11-30 14:47     ` Julien Grall
  2015-11-30 14:47     ` [Xen-devel] " Julien Grall
  1 sibling, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-30 14:47 UTC (permalink / raw)
  To: Stefano Stabellini, shannon.zhao
  Cc: mark.rutland, hangaohuai, david.vrabel, keir, ian.campbell,
	ard.biesheuvel, andrew.cooper3, peter.huangpeng, xen-devel,
	stefano.stabellini, christoffer.dall, jbeulich, zhaoshenglong,
	linux-arm-kernel, roger.pau

Hi,

On 23/11/15 11:37, Stefano Stabellini wrote:
> On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
>> From: Shannon Zhao <shannon.zhao@linaro.org>

> could you please add a couple of lines to the commit message mentioning
> why __va(phys) is an acceptable implementation of arch_acpi_os_map_memory?

FWIW, I already asked this question multiple time on the previous series
without clear answer.

__va should only be used when the memory is direct-mapped to Xen (i.e
accessible directly). On ARM64, this is only the case for the RAM. Can
someone confirm the ACPI will always reside to the RAM?

Regards,

-- 
Julien Grall

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

* [Xen-devel] [PATCH v3 20/62] arm/acpi: Add ACPI support for SMP initialization
  2015-11-17  9:40   ` shannon.zhao
                     ` (3 preceding siblings ...)
  (?)
@ 2015-11-30 14:57   ` Julien Grall
  2015-12-30  3:11     ` Shannon Zhao
  2015-12-30  3:11     ` Shannon Zhao
  -1 siblings, 2 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-30 14:57 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Shannon,

On 17/11/15 09:40, shannon.zhao at linaro.org wrote:
> diff --git a/xen/arch/arm/psci.c b/xen/arch/arm/psci.c
> index d800cb6..dede0e1 100644
> --- a/xen/arch/arm/psci.c
> +++ b/xen/arch/arm/psci.c
> @@ -22,6 +22,7 @@
>  #include <xen/mm.h>
>  #include <xen/smp.h>
>  #include <asm/psci.h>
> +#include <asm/acpi.h>
>  
>  /*
>   * While a 64-bit OS can make calls with SMC32 calling conventions, for
> @@ -86,6 +87,9 @@ int __init psci_init_0_1(void)
>      int ret;
>      const struct dt_device_node *psci;
>  
> +    if ( !acpi_disabled )
> +        return -EINVAL;

Please explain in the commit message why PSCI 0.1 is not supported on ACPI.


Regards,

-- 
Julien Grall

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

* Re: [PATCH v3 20/62] arm/acpi: Add ACPI support for SMP initialization
  2015-11-17  9:40   ` shannon.zhao
                     ` (2 preceding siblings ...)
  (?)
@ 2015-11-30 14:57   ` Julien Grall
  -1 siblings, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-30 14:57 UTC (permalink / raw)
  To: shannon.zhao, ian.campbell, stefano.stabellini, keir, jbeulich,
	andrew.cooper3, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, peter.huangpeng,
	david.vrabel, zhaoshenglong, roger.pau, christoffer.dall,
	linux-arm-kernel

Hi Shannon,

On 17/11/15 09:40, shannon.zhao@linaro.org wrote:
> diff --git a/xen/arch/arm/psci.c b/xen/arch/arm/psci.c
> index d800cb6..dede0e1 100644
> --- a/xen/arch/arm/psci.c
> +++ b/xen/arch/arm/psci.c
> @@ -22,6 +22,7 @@
>  #include <xen/mm.h>
>  #include <xen/smp.h>
>  #include <asm/psci.h>
> +#include <asm/acpi.h>
>  
>  /*
>   * While a 64-bit OS can make calls with SMC32 calling conventions, for
> @@ -86,6 +87,9 @@ int __init psci_init_0_1(void)
>      int ret;
>      const struct dt_device_node *psci;
>  
> +    if ( !acpi_disabled )
> +        return -EINVAL;

Please explain in the commit message why PSCI 0.1 is not supported on ACPI.


Regards,

-- 
Julien Grall

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

* [Xen-devel] [PATCH v3 22/62] arm/gic-v3: Refactor gicv3_init into generic and dt specific parts
  2015-11-24 10:51   ` [Xen-devel] " Stefano Stabellini
  2015-11-30 15:01     ` Julien Grall
@ 2015-11-30 15:01     ` Julien Grall
  1 sibling, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-30 15:01 UTC (permalink / raw)
  To: linux-arm-kernel

On 24/11/15 10:51, Stefano Stabellini wrote:
> On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>
>> Refactor gic-v3 related functions into dt and generic parts. This will be
>> helpful when adding acpi support for gic-v3.
>>
>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> ---
>>  xen/arch/arm/gic-v3.c | 95 +++++++++++++++++++++++++++------------------------
>>  1 file changed, 51 insertions(+), 44 deletions(-)
>>
>> diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
>> index 4fe0c37..bd13010 100644
>> --- a/xen/arch/arm/gic-v3.c
>> +++ b/xen/arch/arm/gic-v3.c
>> @@ -1138,62 +1138,27 @@ static int __init cmp_rdist(const void *a, const void *b)
>>      return ( l->base < r->base) ? -1 : 0;
>>  }
>>  
>> +static paddr_t __initdata dbase = 0, cbase = 0, csize = 0, vbase = 0;
> 
> It might be best to initialize them to something like INVALID_PADDR
> rather then 0, which is actually a possible address value.

It's even mandatory, we had a patch [1] to allow base address to be 0
and there is no point to re-introduce this restriction.

Regards,

[1] c1fde0dcd4ecb78378ffe8b3e263d28dc3b9c0eb "xen/arm: gic: Allow the
base address to be 0"

-- 
Julien Grall

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

* Re: [PATCH v3 22/62] arm/gic-v3: Refactor gicv3_init into generic and dt specific parts
  2015-11-24 10:51   ` [Xen-devel] " Stefano Stabellini
@ 2015-11-30 15:01     ` Julien Grall
  2015-11-30 15:01     ` [Xen-devel] " Julien Grall
  1 sibling, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-30 15:01 UTC (permalink / raw)
  To: Stefano Stabellini, shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, linux-arm-kernel,
	ard.biesheuvel, andrew.cooper3, peter.huangpeng, xen-devel,
	stefano.stabellini, david.vrabel, jbeulich, zhaoshenglong,
	christoffer.dall, roger.pau

On 24/11/15 10:51, Stefano Stabellini wrote:
> On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>
>> Refactor gic-v3 related functions into dt and generic parts. This will be
>> helpful when adding acpi support for gic-v3.
>>
>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> ---
>>  xen/arch/arm/gic-v3.c | 95 +++++++++++++++++++++++++++------------------------
>>  1 file changed, 51 insertions(+), 44 deletions(-)
>>
>> diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
>> index 4fe0c37..bd13010 100644
>> --- a/xen/arch/arm/gic-v3.c
>> +++ b/xen/arch/arm/gic-v3.c
>> @@ -1138,62 +1138,27 @@ static int __init cmp_rdist(const void *a, const void *b)
>>      return ( l->base < r->base) ? -1 : 0;
>>  }
>>  
>> +static paddr_t __initdata dbase = 0, cbase = 0, csize = 0, vbase = 0;
> 
> It might be best to initialize them to something like INVALID_PADDR
> rather then 0, which is actually a possible address value.

It's even mandatory, we had a patch [1] to allow base address to be 0
and there is no point to re-introduce this restriction.

Regards,

[1] c1fde0dcd4ecb78378ffe8b3e263d28dc3b9c0eb "xen/arm: gic: Allow the
base address to be 0"

-- 
Julien Grall

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

* [PATCH v3 38/62] arm/acpi: Add placeholder for efi and acpi load address
  2015-11-26 16:04             ` Stefano Stabellini
@ 2015-11-30 15:10                 ` Julien Grall
  0 siblings, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-30 15:10 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Stefano,

On 26/11/15 16:04, Stefano Stabellini wrote:
> On Wed, 18 Nov 2015, Julien Grall wrote:
>> On 18/11/15 03:01, Shannon Zhao wrote:
>>> "All above tables will be mapped to Dom0 non-RAM space. Since when
>>> booting through ACPI it doesn't need the grant table region(see below
>>> section 3), it could use this region to store the tables or use the same
>>> way to find one memory region to store them."
>>>
>>> Firstly, as Jan suggested, these tables should not be in RAM space, so
>>> we drop the previous way that copying these tables to Dom0 RAM.
>>> Then I suggested map these tables to the space after the Dom0 RAM space,
>>> but this not right because Dom0 RAM region might be at the edge of
>>> physical RAM space and there might be device MMIO regions.
>>> Then you suggest it could map these tables to the region which is used
>>> for grant table(or the region found by the same way) while it's not used
>>> when it boots with ACPI. These regions are not used by Xen and will not
>>> be used by Dom0 either currently. But as you say, it will be wrong if
>>> Dom0 memory is not 1:1 mapped.
>>
>> Will you remember in 6 months why you wrote the code like that?
>>
>> My point on the previous mail is you don't describe what you did,
>> neither in the code nor in the commit message.
>>
>> Most of the place in the code are trying to avoid the assumption that
>> DOM0 is using direct mapped. If not, we always have a comment/commit
>> message explaining why we are doing like that and the implication (see
>> the grant table example [1]).
>>
>>> So how about below idea:
>>> We still copy these tables to Dom0 RAM space but when we create
>>> EFI_MMAP_TABLE, we remove the space occupied by these tables from the
>>> EfiConventionalMemory descriptor.
>>
>> As you don't need the grant table region, why don't you re-use it fopr
>> your tables? It may also be possible that we have some space just after
>> for the EFI table.
> 
> I think that the current approach is good, please just extend the
> in-code comment in patch #40.

In fact my suggestion was wrong :/. We need real memory for EFI/ACPI
placeholder.

Regards,

-- 
Julien Grall

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

* Re: [PATCH v3 38/62] arm/acpi: Add placeholder for efi and acpi load address
@ 2015-11-30 15:10                 ` Julien Grall
  0 siblings, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-30 15:10 UTC (permalink / raw)
  To: Stefano Stabellini
  Cc: hangaohuai, ian.campbell, peter.huangpeng, xen-devel,
	stefano.stabellini, shannon.zhao, Jan Beulich, Shannon Zhao,
	linux-arm-kernel

Hi Stefano,

On 26/11/15 16:04, Stefano Stabellini wrote:
> On Wed, 18 Nov 2015, Julien Grall wrote:
>> On 18/11/15 03:01, Shannon Zhao wrote:
>>> "All above tables will be mapped to Dom0 non-RAM space. Since when
>>> booting through ACPI it doesn't need the grant table region(see below
>>> section 3), it could use this region to store the tables or use the same
>>> way to find one memory region to store them."
>>>
>>> Firstly, as Jan suggested, these tables should not be in RAM space, so
>>> we drop the previous way that copying these tables to Dom0 RAM.
>>> Then I suggested map these tables to the space after the Dom0 RAM space,
>>> but this not right because Dom0 RAM region might be at the edge of
>>> physical RAM space and there might be device MMIO regions.
>>> Then you suggest it could map these tables to the region which is used
>>> for grant table(or the region found by the same way) while it's not used
>>> when it boots with ACPI. These regions are not used by Xen and will not
>>> be used by Dom0 either currently. But as you say, it will be wrong if
>>> Dom0 memory is not 1:1 mapped.
>>
>> Will you remember in 6 months why you wrote the code like that?
>>
>> My point on the previous mail is you don't describe what you did,
>> neither in the code nor in the commit message.
>>
>> Most of the place in the code are trying to avoid the assumption that
>> DOM0 is using direct mapped. If not, we always have a comment/commit
>> message explaining why we are doing like that and the implication (see
>> the grant table example [1]).
>>
>>> So how about below idea:
>>> We still copy these tables to Dom0 RAM space but when we create
>>> EFI_MMAP_TABLE, we remove the space occupied by these tables from the
>>> EfiConventionalMemory descriptor.
>>
>> As you don't need the grant table region, why don't you re-use it fopr
>> your tables? It may also be possible that we have some space just after
>> for the EFI table.
> 
> I think that the current approach is good, please just extend the
> in-code comment in patch #40.

In fact my suggestion was wrong :/. We need real memory for EFI/ACPI
placeholder.

Regards,

-- 
Julien Grall

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

* [Xen-devel] [PATCH v3 40/62] arm/acpi: Estimate memory required for acpi/efi tables
  2015-11-17  9:40   ` shannon.zhao
@ 2015-11-30 15:14     ` Julien Grall
  -1 siblings, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-30 15:14 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Shannon,

On 17/11/15 09:40, shannon.zhao at linaro.org wrote:
> diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
> index 53c7452..78d8ae9 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,26 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
>      for( ; ; ); /* not reached */
>  }
>  
> +#ifdef CONFIG_ACPI
> +/* 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;
> +    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 = PAGE_ALIGN(est_size + ect_size + fw_vendor_size)
> +           + PAGE_ALIGN(emd_size *
> +                        (mem_nr_banks + acpi_mem.nr_banks + TBL_MMAX));
> +
> +    return size;
> +}
> +#endif
> +

efi/boot.c only contains code related to the stub EFI. This is not the
case of this code.

Moreover, this code won't compile on x86 because acpi_mem is only
defined for ARM.

Regards,

-- 
Julien Grall

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

* Re: [PATCH v3 40/62] arm/acpi: Estimate memory required for acpi/efi tables
@ 2015-11-30 15:14     ` Julien Grall
  0 siblings, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-30 15:14 UTC (permalink / raw)
  To: shannon.zhao, ian.campbell, stefano.stabellini, keir, jbeulich,
	andrew.cooper3, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, peter.huangpeng,
	david.vrabel, zhaoshenglong, roger.pau, christoffer.dall,
	linux-arm-kernel

Hi Shannon,

On 17/11/15 09:40, shannon.zhao@linaro.org wrote:
> diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
> index 53c7452..78d8ae9 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,26 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
>      for( ; ; ); /* not reached */
>  }
>  
> +#ifdef CONFIG_ACPI
> +/* 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;
> +    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 = PAGE_ALIGN(est_size + ect_size + fw_vendor_size)
> +           + PAGE_ALIGN(emd_size *
> +                        (mem_nr_banks + acpi_mem.nr_banks + TBL_MMAX));
> +
> +    return size;
> +}
> +#endif
> +

efi/boot.c only contains code related to the stub EFI. This is not the
case of this code.

Moreover, this code won't compile on x86 because acpi_mem is only
defined for ARM.

Regards,

-- 
Julien Grall

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

* [PATCH v3 47/62] arm/p2m: Add helper functions to map memory regions
  2015-11-27 12:04   ` Stefano Stabellini
  2015-11-30 15:22     ` Julien Grall
@ 2015-11-30 15:22     ` Julien Grall
  2016-01-05  3:50       ` Shannon Zhao
  2016-01-05  3:50       ` Shannon Zhao
  1 sibling, 2 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-30 15:22 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

On 27/11/15 12:04, Stefano Stabellini wrote:
> On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
>> From: Parth Dixit <parth.dixit@linaro.org>
>>
>> Create a helper function for mapping with cached attributes.
>>
>> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> 
> You might be able to use the existing guest_physmap_add_entry and
> guest_physmap_remove_page for your purposes.

I would rather avoid to do that, those function use the type p2m_ram_rw
which imply the memory is executable.

Regards,

-- 
Julien Grall

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

* Re: [PATCH v3 47/62] arm/p2m: Add helper functions to map memory regions
  2015-11-27 12:04   ` Stefano Stabellini
@ 2015-11-30 15:22     ` Julien Grall
  2015-11-30 15:22     ` Julien Grall
  1 sibling, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-30 15:22 UTC (permalink / raw)
  To: Stefano Stabellini, shannon.zhao
  Cc: mark.rutland, hangaohuai, david.vrabel, keir, ian.campbell,
	ard.biesheuvel, andrew.cooper3, peter.huangpeng, xen-devel,
	stefano.stabellini, christoffer.dall, jbeulich, zhaoshenglong,
	linux-arm-kernel, roger.pau

Hi,

On 27/11/15 12:04, Stefano Stabellini wrote:
> On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
>> From: Parth Dixit <parth.dixit@linaro.org>
>>
>> Create a helper function for mapping with cached attributes.
>>
>> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> 
> You might be able to use the existing guest_physmap_add_entry and
> guest_physmap_remove_page for your purposes.

I would rather avoid to do that, those function use the type p2m_ram_rw
which imply the memory is executable.

Regards,

-- 
Julien Grall

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

* [Xen-devel] [PATCH v3 47/62] arm/p2m: Add helper functions to map memory regions
  2015-11-17  9:40   ` shannon.zhao
                     ` (2 preceding siblings ...)
  (?)
@ 2015-11-30 15:23   ` Julien Grall
  -1 siblings, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-30 15:23 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Shannon,

On 17/11/15 09:40, shannon.zhao at linaro.org wrote:
> From: Parth Dixit <parth.dixit@linaro.org>
> 
> Create a helper function for mapping with cached attributes.

You are using those helpers to map the ACPI table in the guest. Do we
really need them to be mapped read-write?

Regards,

-- 
Julien Grall

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

* Re: [PATCH v3 47/62] arm/p2m: Add helper functions to map memory regions
  2015-11-17  9:40   ` shannon.zhao
                     ` (3 preceding siblings ...)
  (?)
@ 2015-11-30 15:23   ` Julien Grall
  -1 siblings, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-30 15:23 UTC (permalink / raw)
  To: shannon.zhao, ian.campbell, stefano.stabellini, keir, jbeulich,
	andrew.cooper3, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, peter.huangpeng,
	david.vrabel, zhaoshenglong, roger.pau, christoffer.dall,
	linux-arm-kernel

Hi Shannon,

On 17/11/15 09:40, shannon.zhao@linaro.org wrote:
> From: Parth Dixit <parth.dixit@linaro.org>
> 
> Create a helper function for mapping with cached attributes.

You are using those helpers to map the ACPI table in the guest. Do we
really need them to be mapped read-write?

Regards,

-- 
Julien Grall

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

* [PATCH v3 49/62] arm/acpi: Map rest tables for Dom0
  2015-11-27 12:16   ` Stefano Stabellini
@ 2015-11-30 15:25       ` Julien Grall
  0 siblings, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-30 15:25 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

On 27/11/15 12:16, Stefano Stabellini wrote:
> On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>
>> Map other reused tables for Dom0.
> 
> "Map all other tables to Dom0 using 1:1 mappings."
> 
> 
>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> ---
>>  xen/arch/arm/domain_build.c | 25 +++++++++++++++++++++++++
>>  1 file changed, 25 insertions(+)
>>
>> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
>> index 6ae5761..da4e271 100644
>> --- a/xen/arch/arm/domain_build.c
>> +++ b/xen/arch/arm/domain_build.c
>> @@ -1359,6 +1359,29 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
>>  #ifdef CONFIG_ACPI
>>  #define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */
>>  
>> +static void acpi_map_rest_tables(struct domain *d)
> 
> The name doesn't sound nice, "acpi_map_other_tables" would be better.
> However this function is not actually mapping the other tables, it is
> mapping *all* of them, including the original madt and fadt, right? I
> think it would be best to avoid mapping the originals.
> 
> 
>> +{
>> +    int i;
>> +    unsigned long res;
>> +    u64 addr, size;
> 
> Add a comment that they are being mapped 1:1

I don't like the fact that we begin to assume domain is mapped 1:1 in so
many places.

If we decide one day to drop the 1:1 mapping it would be more difficult.

Can we try to rationalize the place where the 1:1 mapping is added?

Some ASSERT(is_domain_direct_mapped(..)) would be useful too.

Regards,

-- 
Julien Grall

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

* Re: [PATCH v3 49/62] arm/acpi: Map rest tables for Dom0
@ 2015-11-30 15:25       ` Julien Grall
  0 siblings, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-30 15:25 UTC (permalink / raw)
  To: Stefano Stabellini, shannon.zhao
  Cc: mark.rutland, hangaohuai, david.vrabel, keir, ian.campbell,
	ard.biesheuvel, andrew.cooper3, peter.huangpeng, xen-devel,
	stefano.stabellini, christoffer.dall, jbeulich, zhaoshenglong,
	linux-arm-kernel, roger.pau

Hi,

On 27/11/15 12:16, Stefano Stabellini wrote:
> On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>
>> Map other reused tables for Dom0.
> 
> "Map all other tables to Dom0 using 1:1 mappings."
> 
> 
>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> ---
>>  xen/arch/arm/domain_build.c | 25 +++++++++++++++++++++++++
>>  1 file changed, 25 insertions(+)
>>
>> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
>> index 6ae5761..da4e271 100644
>> --- a/xen/arch/arm/domain_build.c
>> +++ b/xen/arch/arm/domain_build.c
>> @@ -1359,6 +1359,29 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
>>  #ifdef CONFIG_ACPI
>>  #define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */
>>  
>> +static void acpi_map_rest_tables(struct domain *d)
> 
> The name doesn't sound nice, "acpi_map_other_tables" would be better.
> However this function is not actually mapping the other tables, it is
> mapping *all* of them, including the original madt and fadt, right? I
> think it would be best to avoid mapping the originals.
> 
> 
>> +{
>> +    int i;
>> +    unsigned long res;
>> +    u64 addr, size;
> 
> Add a comment that they are being mapped 1:1

I don't like the fact that we begin to assume domain is mapped 1:1 in so
many places.

If we decide one day to drop the 1:1 mapping it would be more difficult.

Can we try to rationalize the place where the 1:1 mapping is added?

Some ASSERT(is_domain_direct_mapped(..)) would be useful too.

Regards,

-- 
Julien Grall

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

* [PATCH v3 56/62] arm/acpi: Deny MMIO access of UART
  2015-11-17 13:10     ` Shannon Zhao
                         ` (2 preceding siblings ...)
  2015-11-30 15:30       ` Julien Grall
@ 2015-11-30 15:30       ` Julien Grall
  3 siblings, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-30 15:30 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Shannon,

On 17/11/15 13:10, Shannon Zhao wrote:
> Regarding SMMU, since it doesn't support now, so I didn't add it but it
> could be added later.

Then please add a TODO, otherwise it's a call to forget it.

Regards,

-- 
Julien Grall

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

* Re: [PATCH v3 56/62] arm/acpi: Deny MMIO access of UART
  2015-11-17 13:10     ` Shannon Zhao
  2015-11-27 14:50       ` Stefano Stabellini
  2015-11-27 14:50       ` Stefano Stabellini
@ 2015-11-30 15:30       ` Julien Grall
  2015-11-30 15:30       ` Julien Grall
  3 siblings, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-30 15:30 UTC (permalink / raw)
  To: Shannon Zhao, shannon.zhao, ian.campbell, stefano.stabellini,
	keir, jbeulich, andrew.cooper3, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, peter.huangpeng,
	david.vrabel, roger.pau, christoffer.dall, linux-arm-kernel

Hi Shannon,

On 17/11/15 13:10, Shannon Zhao wrote:
> Regarding SMMU, since it doesn't support now, so I didn't add it but it
> could be added later.

Then please add a TODO, otherwise it's a call to forget it.

Regards,

-- 
Julien Grall

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

* [PATCH v3 58/62] xen/acpi: Fix event-channel interrupt when booting with ACPI
  2015-11-27 15:12   ` Stefano Stabellini
@ 2015-11-30 15:30       ` Julien Grall
  0 siblings, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-30 15:30 UTC (permalink / raw)
  To: linux-arm-kernel

On 27/11/15 15:12, Stefano Stabellini wrote:
>> +    }
>> +    else
>> +    {
>> +        int type = 3;
>> +        int flag = 2; /* Active-low level-sensitive  */
>> +        d->arch.hvm_domain.params[HVM_PARAM_CALLBACK_IRQ] = (u64)type << 56
>> +                                                            | flag << 8
>> +                                                            | d->arch.evtchn_irq;
>> +    }
>>  }
> 
> Actually there is no point in setting HVM_PARAM_CALLBACK_IRQ only on
> ACPI: I would just set it on all cases.

+1

Regards,

-- 
Julien Grall

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

* Re: [PATCH v3 58/62] xen/acpi: Fix event-channel interrupt when booting with ACPI
@ 2015-11-30 15:30       ` Julien Grall
  0 siblings, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-30 15:30 UTC (permalink / raw)
  To: Stefano Stabellini, shannon.zhao
  Cc: mark.rutland, hangaohuai, david.vrabel, keir, ian.campbell,
	ard.biesheuvel, andrew.cooper3, peter.huangpeng, xen-devel,
	stefano.stabellini, christoffer.dall, jbeulich, zhaoshenglong,
	linux-arm-kernel, roger.pau

On 27/11/15 15:12, Stefano Stabellini wrote:
>> +    }
>> +    else
>> +    {
>> +        int type = 3;
>> +        int flag = 2; /* Active-low level-sensitive  */
>> +        d->arch.hvm_domain.params[HVM_PARAM_CALLBACK_IRQ] = (u64)type << 56
>> +                                                            | flag << 8
>> +                                                            | d->arch.evtchn_irq;
>> +    }
>>  }
> 
> Actually there is no point in setting HVM_PARAM_CALLBACK_IRQ only on
> ACPI: I would just set it on all cases.

+1

Regards,

-- 
Julien Grall

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

* [Xen-devel] [PATCH v3 55/62] arm/acpi: Route all Xen unused SPIs to Dom0
  2015-11-27 15:04   ` Stefano Stabellini
  2015-11-30 15:41     ` Julien Grall
@ 2015-11-30 15:41     ` Julien Grall
  1 sibling, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-30 15:41 UTC (permalink / raw)
  To: linux-arm-kernel

On 27/11/15 15:04, Stefano Stabellini wrote:
>> +        vgic_reserve_virq(d, i);
>> +        irq_set_type(i, ACPI_IRQ_TYPE_NONE);
> 
> I don't know if there is any point in setting the type to NONE. It's the
> default, isn't it?

No, the default is *_IRQ_TYPE_INVALID.

Regards,

-- 
Julien Grall

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

* Re: [PATCH v3 55/62] arm/acpi: Route all Xen unused SPIs to Dom0
  2015-11-27 15:04   ` Stefano Stabellini
@ 2015-11-30 15:41     ` Julien Grall
  2015-11-30 15:41     ` [Xen-devel] " Julien Grall
  1 sibling, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-30 15:41 UTC (permalink / raw)
  To: Stefano Stabellini, shannon.zhao
  Cc: mark.rutland, hangaohuai, david.vrabel, keir, ian.campbell,
	ard.biesheuvel, andrew.cooper3, peter.huangpeng, xen-devel,
	stefano.stabellini, christoffer.dall, jbeulich, zhaoshenglong,
	linux-arm-kernel, roger.pau

On 27/11/15 15:04, Stefano Stabellini wrote:
>> +        vgic_reserve_virq(d, i);
>> +        irq_set_type(i, ACPI_IRQ_TYPE_NONE);
> 
> I don't know if there is any point in setting the type to NONE. It's the
> default, isn't it?

No, the default is *_IRQ_TYPE_INVALID.

Regards,

-- 
Julien Grall

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

* [Xen-devel] [PATCH v3 60/62] arm/acpi: Configure interrupts dynamically
  2015-11-17  9:40   ` shannon.zhao
@ 2015-11-30 15:42     ` Julien Grall
  -1 siblings, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-30 15:42 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Shannon,

On 17/11/15 09:40, shannon.zhao at linaro.org wrote:
> From: Parth Dixit <parth.dixit@linaro.org>
> 
> Interrupt information is described in DSDT and is not available at
> the time of booting. Configure the interrupts dynamically when requested
> by Dom0

Missing ".".

As said on a previous version of this patch [1], I'd like to keep the
ACPI changes very contained to Xen boot. Your change is not ACPI
specific and could be used for DT.

> 
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/vgic.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c
> index 7bb4570..d05abde 100644
> --- a/xen/arch/arm/vgic.c
> +++ b/xen/arch/arm/vgic.c
> @@ -25,6 +25,7 @@
>  #include <xen/irq.h>
>  #include <xen/sched.h>
>  #include <xen/perfc.h>
> +#include <xen/acpi.h>
>  
>  #include <asm/current.h>
>  
> @@ -310,6 +311,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)
>  {
>      struct domain *d = v->domain;
> @@ -321,7 +324,23 @@ void vgic_enable_irqs(struct vcpu *v, uint32_t r, int n)
>      struct vcpu *v_target;
>  
>      while ( (i = find_next_bit(&mask, 32, i)) < 32 ) {
> +#ifdef CONFIG_ACPI
> +        struct vgic_irq_rank *vr = vgic_get_rank(v, n);
> +        uint32_t tr;
> +
>          irq = i + (32 * n);
> +        if( ( !acpi_disabled ) && ( n != 0 ) && is_hardware_domain(d) )

You need to add a comment explaining the ( n != 0 ) i.e we don't SGIs
and PPIs are RO. It's implementation defined for PPI but it's preferable
to let Xen take care of it.

Also, we should set the type only for IRQ assigned to DOM0 (i.e p->desc
!= NULL). With your current solution, DOM0 may change the configuration
of the serial IRQ by mistake and take down Xen because the physical IRQ
is enabled and the behavior will be unpredictable.

> +        {
> +            tr = vr->icfg[i >> 4] ;
> +
> +            if( ( tr & VGIC_ICFG_MASK(i) ) )
> +                irq_set_type(irq, ACPI_IRQ_TYPE_EDGE_BOTH);
> +            else
> +                irq_set_type(irq, ACPI_IRQ_TYPE_LEVEL_MASK);

Given that only SPI can be configured it would have been better to call
irq_set_type.

Although, those 2 functions don't do what you think. They are setting
the type internally in Xen but don't change the GIC interrupt
configuration register.

Lastly, they will fail because the configuration has been set earlier
(as you did in patch #55)

> +        }
> +#else
> +        irq = i + (32 * n);
> +#endif
>          v_target = d->arch.vgic.handler->get_target_vcpu(v, irq);
>          p = irq_to_pending(v_target, irq);
>          set_bit(GIC_IRQ_GUEST_ENABLED, &p->status);
> 

Regards,

[1] http://lists.xen.org/archives/html/xen-devel/2015-06/msg01128.html

-- 
Julien Grall

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

* Re: [PATCH v3 60/62] arm/acpi: Configure interrupts dynamically
@ 2015-11-30 15:42     ` Julien Grall
  0 siblings, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-30 15:42 UTC (permalink / raw)
  To: shannon.zhao, ian.campbell, stefano.stabellini, keir, jbeulich,
	andrew.cooper3, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, peter.huangpeng,
	david.vrabel, zhaoshenglong, roger.pau, christoffer.dall,
	linux-arm-kernel

Hi Shannon,

On 17/11/15 09:40, shannon.zhao@linaro.org wrote:
> From: Parth Dixit <parth.dixit@linaro.org>
> 
> Interrupt information is described in DSDT and is not available at
> the time of booting. Configure the interrupts dynamically when requested
> by Dom0

Missing ".".

As said on a previous version of this patch [1], I'd like to keep the
ACPI changes very contained to Xen boot. Your change is not ACPI
specific and could be used for DT.

> 
> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/vgic.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c
> index 7bb4570..d05abde 100644
> --- a/xen/arch/arm/vgic.c
> +++ b/xen/arch/arm/vgic.c
> @@ -25,6 +25,7 @@
>  #include <xen/irq.h>
>  #include <xen/sched.h>
>  #include <xen/perfc.h>
> +#include <xen/acpi.h>
>  
>  #include <asm/current.h>
>  
> @@ -310,6 +311,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)
>  {
>      struct domain *d = v->domain;
> @@ -321,7 +324,23 @@ void vgic_enable_irqs(struct vcpu *v, uint32_t r, int n)
>      struct vcpu *v_target;
>  
>      while ( (i = find_next_bit(&mask, 32, i)) < 32 ) {
> +#ifdef CONFIG_ACPI
> +        struct vgic_irq_rank *vr = vgic_get_rank(v, n);
> +        uint32_t tr;
> +
>          irq = i + (32 * n);
> +        if( ( !acpi_disabled ) && ( n != 0 ) && is_hardware_domain(d) )

You need to add a comment explaining the ( n != 0 ) i.e we don't SGIs
and PPIs are RO. It's implementation defined for PPI but it's preferable
to let Xen take care of it.

Also, we should set the type only for IRQ assigned to DOM0 (i.e p->desc
!= NULL). With your current solution, DOM0 may change the configuration
of the serial IRQ by mistake and take down Xen because the physical IRQ
is enabled and the behavior will be unpredictable.

> +        {
> +            tr = vr->icfg[i >> 4] ;
> +
> +            if( ( tr & VGIC_ICFG_MASK(i) ) )
> +                irq_set_type(irq, ACPI_IRQ_TYPE_EDGE_BOTH);
> +            else
> +                irq_set_type(irq, ACPI_IRQ_TYPE_LEVEL_MASK);

Given that only SPI can be configured it would have been better to call
irq_set_type.

Although, those 2 functions don't do what you think. They are setting
the type internally in Xen but don't change the GIC interrupt
configuration register.

Lastly, they will fail because the configuration has been set earlier
(as you did in patch #55)

> +        }
> +#else
> +        irq = i + (32 * n);
> +#endif
>          v_target = d->arch.vgic.handler->get_target_vcpu(v, irq);
>          p = irq_to_pending(v_target, irq);
>          set_bit(GIC_IRQ_GUEST_ENABLED, &p->status);
> 

Regards,

[1] http://lists.xen.org/archives/html/xen-devel/2015-06/msg01128.html

-- 
Julien Grall

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

* [Xen-devel] [PATCH v3 62/62] xen/arm64: Add ACPI support
  2015-11-17  9:41   ` shannon.zhao
  (?)
  (?)
@ 2015-11-30 15:44   ` Julien Grall
  -1 siblings, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-30 15:44 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Shannon,

On 17/11/15 09:41, shannon.zhao at linaro.org 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>
> ---
>  config/arm64.mk              | 1 +
>  xen/common/efi/runtime.c     | 2 +-
>  xen/include/asm-arm/config.h | 5 +++++
>  3 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/config/arm64.mk b/config/arm64.mk
> index c5deb4e..c6a040b 100644
> --- a/config/arm64.mk
> +++ b/config/arm64.mk
> @@ -11,6 +11,7 @@ HAS_CADENCE_UART := y
>  HAS_NS16550 := y
>  HAS_MEM_ACCESS := y
>  HAS_GICV3 := y
> +HAS_ACPI := y
>  
>  # Use only if calling $(LD) directly.
>  LDFLAGS_DIRECT += -EL
> diff --git a/xen/common/efi/runtime.c b/xen/common/efi/runtime.c
> index ae87557..7748056 100644
> --- a/xen/common/efi/runtime.c
> +++ b/xen/common/efi/runtime.c
> @@ -11,7 +11,7 @@ DEFINE_XEN_GUEST_HANDLE(CHAR16);
>  #ifndef COMPAT
>  
>  #ifdef CONFIG_ARM  /* Disabled until runtime services implemented */
> -const bool_t efi_enabled = 0;
> +const bool_t efi_enabled = 1;

Can you explained why efi_enabled is set unconditionally? Xen may have
boot without EFI.

Regards,

-- 
Julien Grall

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

* Re: [PATCH v3 62/62] xen/arm64: Add ACPI support
  2015-11-17  9:41   ` shannon.zhao
                     ` (2 preceding siblings ...)
  (?)
@ 2015-11-30 15:44   ` Julien Grall
  -1 siblings, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-11-30 15:44 UTC (permalink / raw)
  To: shannon.zhao, ian.campbell, stefano.stabellini, keir, jbeulich,
	andrew.cooper3, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, peter.huangpeng,
	david.vrabel, zhaoshenglong, roger.pau, christoffer.dall,
	linux-arm-kernel

Hi Shannon,

On 17/11/15 09:41, shannon.zhao@linaro.org 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>
> ---
>  config/arm64.mk              | 1 +
>  xen/common/efi/runtime.c     | 2 +-
>  xen/include/asm-arm/config.h | 5 +++++
>  3 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/config/arm64.mk b/config/arm64.mk
> index c5deb4e..c6a040b 100644
> --- a/config/arm64.mk
> +++ b/config/arm64.mk
> @@ -11,6 +11,7 @@ HAS_CADENCE_UART := y
>  HAS_NS16550 := y
>  HAS_MEM_ACCESS := y
>  HAS_GICV3 := y
> +HAS_ACPI := y
>  
>  # Use only if calling $(LD) directly.
>  LDFLAGS_DIRECT += -EL
> diff --git a/xen/common/efi/runtime.c b/xen/common/efi/runtime.c
> index ae87557..7748056 100644
> --- a/xen/common/efi/runtime.c
> +++ b/xen/common/efi/runtime.c
> @@ -11,7 +11,7 @@ DEFINE_XEN_GUEST_HANDLE(CHAR16);
>  #ifndef COMPAT
>  
>  #ifdef CONFIG_ARM  /* Disabled until runtime services implemented */
> -const bool_t efi_enabled = 0;
> +const bool_t efi_enabled = 1;

Can you explained why efi_enabled is set unconditionally? Xen may have
boot without EFI.

Regards,

-- 
Julien Grall

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

* [Xen-devel] [PATCH v3 07/62] arm/acpi: Add arch_acpi_os_map_memory helper function for ARM
  2015-11-30 14:47     ` [Xen-devel] " Julien Grall
@ 2015-12-07  8:58         ` Shannon Zhao
  0 siblings, 0 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-12-07  8:58 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

On 2015/11/30 22:47, Julien Grall wrote:
> Hi,
> 
> On 23/11/15 11:37, Stefano Stabellini wrote:
>> > On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
>>> >> From: Shannon Zhao <shannon.zhao@linaro.org>
>> > could you please add a couple of lines to the commit message mentioning
>> > why __va(phys) is an acceptable implementation of arch_acpi_os_map_memory?
> FWIW, I already asked this question multiple time on the previous series
> without clear answer.
> 
> __va should only be used when the memory is direct-mapped to Xen (i.e
> accessible directly). On ARM64, this is only the case for the RAM. Can
> someone confirm the ACPI will always reside to the RAM?
I checked this with the UEFI SPEC. It says in 2.3.6 AArch64 Platforms:
"If ACPI is supported :
? ACPI Tables loaded at boot time can be contained in memory of type
EfiACPIReclaimMemory (recommended) or EfiACPIMemoryNVS."

So I think it means the ACPI tables will always reside in RAM.

Thanks,
-- 
Shannon

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

* Re: [PATCH v3 07/62] arm/acpi: Add arch_acpi_os_map_memory helper function for ARM
@ 2015-12-07  8:58         ` Shannon Zhao
  0 siblings, 0 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-12-07  8:58 UTC (permalink / raw)
  To: Julien Grall, Stefano Stabellini, shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	peter.huangpeng, xen-devel, stefano.stabellini, jbeulich,
	linux-arm-kernel

Hi,

On 2015/11/30 22:47, Julien Grall wrote:
> Hi,
> 
> On 23/11/15 11:37, Stefano Stabellini wrote:
>> > On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
>>> >> From: Shannon Zhao <shannon.zhao@linaro.org>
>> > could you please add a couple of lines to the commit message mentioning
>> > why __va(phys) is an acceptable implementation of arch_acpi_os_map_memory?
> FWIW, I already asked this question multiple time on the previous series
> without clear answer.
> 
> __va should only be used when the memory is direct-mapped to Xen (i.e
> accessible directly). On ARM64, this is only the case for the RAM. Can
> someone confirm the ACPI will always reside to the RAM?
I checked this with the UEFI SPEC. It says in 2.3.6 AArch64 Platforms:
"If ACPI is supported :
• ACPI Tables loaded at boot time can be contained in memory of type
EfiACPIReclaimMemory (recommended) or EfiACPIMemoryNVS."

So I think it means the ACPI tables will always reside in RAM.

Thanks,
-- 
Shannon

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

* [Xen-devel] [PATCH v3 07/62] arm/acpi: Add arch_acpi_os_map_memory helper function for ARM
  2015-12-07  8:58         ` Shannon Zhao
  (?)
  (?)
@ 2015-12-07 10:32         ` Jan Beulich
  2015-12-07 10:38           ` Ian Campbell
  2015-12-07 10:38           ` [Xen-devel] " Ian Campbell
  -1 siblings, 2 replies; 426+ messages in thread
From: Jan Beulich @ 2015-12-07 10:32 UTC (permalink / raw)
  To: linux-arm-kernel

>>> On 07.12.15 at 09:58, <zhaoshenglong@huawei.com> wrote:
> On 2015/11/30 22:47, Julien Grall wrote:
>> On 23/11/15 11:37, Stefano Stabellini wrote:
>>> > On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
>>>> >> From: Shannon Zhao <shannon.zhao@linaro.org>
>>> > could you please add a couple of lines to the commit message mentioning
>>> > why __va(phys) is an acceptable implementation of arch_acpi_os_map_memory?
>> FWIW, I already asked this question multiple time on the previous series
>> without clear answer.
>> 
>> __va should only be used when the memory is direct-mapped to Xen (i.e
>> accessible directly). On ARM64, this is only the case for the RAM. Can
>> someone confirm the ACPI will always reside to the RAM?
> I checked this with the UEFI SPEC. It says in 2.3.6 AArch64 Platforms:
> "If ACPI is supported :
> ? ACPI Tables loaded at boot time can be contained in memory of type
> EfiACPIReclaimMemory (recommended) or EfiACPIMemoryNVS."
> 
> So I think it means the ACPI tables will always reside in RAM.

I think NVS doesn't necessarily mean RAM.

Jan

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

* Re: [PATCH v3 07/62] arm/acpi: Add arch_acpi_os_map_memory helper function for ARM
  2015-12-07  8:58         ` Shannon Zhao
  (?)
@ 2015-12-07 10:32         ` Jan Beulich
  -1 siblings, 0 replies; 426+ messages in thread
From: Jan Beulich @ 2015-12-07 10:32 UTC (permalink / raw)
  To: Shannon Zhao, shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, Stefano Stabellini,
	ard.biesheuvel, peter.huangpeng, xen-devel, Julien Grall,
	stefano.stabellini, linux-arm-kernel

>>> On 07.12.15 at 09:58, <zhaoshenglong@huawei.com> wrote:
> On 2015/11/30 22:47, Julien Grall wrote:
>> On 23/11/15 11:37, Stefano Stabellini wrote:
>>> > On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
>>>> >> From: Shannon Zhao <shannon.zhao@linaro.org>
>>> > could you please add a couple of lines to the commit message mentioning
>>> > why __va(phys) is an acceptable implementation of arch_acpi_os_map_memory?
>> FWIW, I already asked this question multiple time on the previous series
>> without clear answer.
>> 
>> __va should only be used when the memory is direct-mapped to Xen (i.e
>> accessible directly). On ARM64, this is only the case for the RAM. Can
>> someone confirm the ACPI will always reside to the RAM?
> I checked this with the UEFI SPEC. It says in 2.3.6 AArch64 Platforms:
> "If ACPI is supported :
> ● ACPI Tables loaded at boot time can be contained in memory of type
> EfiACPIReclaimMemory (recommended) or EfiACPIMemoryNVS."
> 
> So I think it means the ACPI tables will always reside in RAM.

I think NVS doesn't necessarily mean RAM.

Jan

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

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

* [Xen-devel] [PATCH v3 07/62] arm/acpi: Add arch_acpi_os_map_memory helper function for ARM
  2015-12-07 10:32         ` [Xen-devel] " Jan Beulich
  2015-12-07 10:38           ` Ian Campbell
@ 2015-12-07 10:38           ` Ian Campbell
  2015-12-07 12:02             ` Julien Grall
  2015-12-07 12:02             ` Julien Grall
  1 sibling, 2 replies; 426+ messages in thread
From: Ian Campbell @ 2015-12-07 10:38 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, 2015-12-07 at 03:32 -0700, Jan Beulich wrote:
> > > > On 07.12.15 at 09:58, <zhaoshenglong@huawei.com> wrote:
> > On 2015/11/30 22:47, Julien Grall wrote:
> > > On 23/11/15 11:37, Stefano Stabellini wrote:
> > > > > On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> > > > > > > From: Shannon Zhao <shannon.zhao@linaro.org>
> > > > > could you please add a couple of lines to the commit message
> > > > > mentioning
> > > > > why __va(phys) is an acceptable implementation of
> > > > > arch_acpi_os_map_memory?
> > > FWIW, I already asked this question multiple time on the previous
> > > series
> > > without clear answer.
> > > 
> > > __va should only be used when the memory is direct-mapped to Xen (i.e
> > > accessible directly). On ARM64, this is only the case for the RAM.
> > > Can
> > > someone confirm the ACPI will always reside to the RAM?
> > I checked this with the UEFI SPEC. It says in 2.3.6 AArch64 Platforms:
> > "If ACPI is supported :
> > ? ACPI Tables loaded at boot time can be contained in memory of type
> > EfiACPIReclaimMemory (recommended) or EfiACPIMemoryNVS."
> > 
> > So I think it means the ACPI tables will always reside in RAM.
> 
> I think NVS doesn't necessarily mean RAM.

That's what I thought/expected too (sounds like it could be flash, CMOS,
ROM etc), but looking at the ACPI 6.0 spec ("16.3.2 BIOS Initialization of
Memory") it says:

    Memory identified by the BIOS as being?    reserved by the BIOS for its use.
    OSPM is required to tag this memory as cacheable, and to save     and
    restore its image before entering an S4 state.

IOW, if I'm reading that correctly, it actually is "memory", and it is only
"NV" by virtue of requiring the OSPM to save/restore it over suspend (so
not at all "NV" in the usual sense).

Ian.

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

* Re: [PATCH v3 07/62] arm/acpi: Add arch_acpi_os_map_memory helper function for ARM
  2015-12-07 10:32         ` [Xen-devel] " Jan Beulich
@ 2015-12-07 10:38           ` Ian Campbell
  2015-12-07 10:38           ` [Xen-devel] " Ian Campbell
  1 sibling, 0 replies; 426+ messages in thread
From: Ian Campbell @ 2015-12-07 10:38 UTC (permalink / raw)
  To: Jan Beulich, Shannon Zhao, shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, Stefano Stabellini,
	ard.biesheuvel, peter.huangpeng, xen-devel, Julien Grall,
	stefano.stabellini, linux-arm-kernel

On Mon, 2015-12-07 at 03:32 -0700, Jan Beulich wrote:
> > > > On 07.12.15 at 09:58, <zhaoshenglong@huawei.com> wrote:
> > On 2015/11/30 22:47, Julien Grall wrote:
> > > On 23/11/15 11:37, Stefano Stabellini wrote:
> > > > > On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> > > > > > > From: Shannon Zhao <shannon.zhao@linaro.org>
> > > > > could you please add a couple of lines to the commit message
> > > > > mentioning
> > > > > why __va(phys) is an acceptable implementation of
> > > > > arch_acpi_os_map_memory?
> > > FWIW, I already asked this question multiple time on the previous
> > > series
> > > without clear answer.
> > > 
> > > __va should only be used when the memory is direct-mapped to Xen (i.e
> > > accessible directly). On ARM64, this is only the case for the RAM.
> > > Can
> > > someone confirm the ACPI will always reside to the RAM?
> > I checked this with the UEFI SPEC. It says in 2.3.6 AArch64 Platforms:
> > "If ACPI is supported :
> > ● ACPI Tables loaded at boot time can be contained in memory of type
> > EfiACPIReclaimMemory (recommended) or EfiACPIMemoryNVS."
> > 
> > So I think it means the ACPI tables will always reside in RAM.
> 
> I think NVS doesn't necessarily mean RAM.

That's what I thought/expected too (sounds like it could be flash, CMOS,
ROM etc), but looking at the ACPI 6.0 spec ("16.3.2 BIOS Initialization of
Memory") it says:

    Memory identified by the BIOS as being     reserved by the BIOS for its use.
    OSPM is required to tag this memory as cacheable, and to save     and
    restore its image before entering an S4 state.

IOW, if I'm reading that correctly, it actually is "memory", and it is only
"NV" by virtue of requiring the OSPM to save/restore it over suspend (so
not at all "NV" in the usual sense).

Ian.

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

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

* [Xen-devel] [PATCH v3 06/62] acpi: Refactor acpi_os_map_memory to be architecturally independent
  2015-11-17  9:40   ` shannon.zhao
                     ` (3 preceding siblings ...)
  (?)
@ 2015-12-07 12:00   ` Julien Grall
  -1 siblings, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-12-07 12:00 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Shannon,

On 17/11/15 09:40, shannon.zhao at linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Current acpi_os_map_memory is specific to x86. Refactor it to be
> architecturally independent.

The function acpi_os_unmap_memory should also be arch-independent.

Otherwise, with the implementation you did on ARM (see patch #7), you
will destroy by mistake the mapping in the page table for those regions.

Regards,

-- 
Julien Grall

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

* Re: [PATCH v3 06/62] acpi: Refactor acpi_os_map_memory to be architecturally independent
  2015-11-17  9:40   ` shannon.zhao
                     ` (2 preceding siblings ...)
  (?)
@ 2015-12-07 12:00   ` Julien Grall
  -1 siblings, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-12-07 12:00 UTC (permalink / raw)
  To: shannon.zhao, ian.campbell, stefano.stabellini, keir, jbeulich,
	andrew.cooper3, xen-devel
  Cc: mark.rutland, hangaohuai, ard.biesheuvel, peter.huangpeng,
	david.vrabel, zhaoshenglong, roger.pau, christoffer.dall,
	linux-arm-kernel

Hi Shannon,

On 17/11/15 09:40, shannon.zhao@linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Current acpi_os_map_memory is specific to x86. Refactor it to be
> architecturally independent.

The function acpi_os_unmap_memory should also be arch-independent.

Otherwise, with the implementation you did on ARM (see patch #7), you
will destroy by mistake the mapping in the page table for those regions.

Regards,

-- 
Julien Grall

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

* [Xen-devel] [PATCH v3 07/62] arm/acpi: Add arch_acpi_os_map_memory helper function for ARM
  2015-12-07 10:38           ` [Xen-devel] " Ian Campbell
@ 2015-12-07 12:02             ` Julien Grall
  2015-12-29 12:01               ` Shannon Zhao
  2015-12-07 12:02             ` Julien Grall
  1 sibling, 1 reply; 426+ messages in thread
From: Julien Grall @ 2015-12-07 12:02 UTC (permalink / raw)
  To: linux-arm-kernel

On 07/12/15 10:38, Ian Campbell wrote:
> On Mon, 2015-12-07 at 03:32 -0700, Jan Beulich wrote:
>>>>> On 07.12.15 at 09:58, <zhaoshenglong@huawei.com> wrote:
>>> On 2015/11/30 22:47, Julien Grall wrote:
>>>> On 23/11/15 11:37, Stefano Stabellini wrote:
>>>>>> On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
>>>>>>>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>>>>> could you please add a couple of lines to the commit message
>>>>>> mentioning
>>>>>> why __va(phys) is an acceptable implementation of
>>>>>> arch_acpi_os_map_memory?
>>>> FWIW, I already asked this question multiple time on the previous
>>>> series
>>>> without clear answer.
>>>>
>>>> __va should only be used when the memory is direct-mapped to Xen (i.e
>>>> accessible directly). On ARM64, this is only the case for the RAM.
>>>> Can
>>>> someone confirm the ACPI will always reside to the RAM?
>>> I checked this with the UEFI SPEC. It says in 2.3.6 AArch64 Platforms:
>>> "If ACPI is supported :
>>> ? ACPI Tables loaded at boot time can be contained in memory of type
>>> EfiACPIReclaimMemory (recommended) or EfiACPIMemoryNVS."
>>>
>>> So I think it means the ACPI tables will always reside in RAM.
>>
>> I think NVS doesn't necessarily mean RAM.
> 
> That's what I thought/expected too (sounds like it could be flash, CMOS,
> ROM etc), but looking at the ACPI 6.0 spec ("16.3.2 BIOS Initialization of
> Memory") it says:
> 
>     Memory identified by the BIOS as being     reserved by the BIOS for its use.
>     OSPM is required to tag this memory as cacheable, and to save     and
>     restore its image before entering an S4 state.
> 
> IOW, if I'm reading that correctly, it actually is "memory", and it is only
> "NV" by virtue of requiring the OSPM to save/restore it over suspend (so
> not at all "NV" in the usual sense).

I think it would be safer to use vmap. It won't impact much Xen as the
mapping are mostly used during Xen boot and DOM0 creation.

Regards,

-- 
Julien Grall

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

* Re: [PATCH v3 07/62] arm/acpi: Add arch_acpi_os_map_memory helper function for ARM
  2015-12-07 10:38           ` [Xen-devel] " Ian Campbell
  2015-12-07 12:02             ` Julien Grall
@ 2015-12-07 12:02             ` Julien Grall
  1 sibling, 0 replies; 426+ messages in thread
From: Julien Grall @ 2015-12-07 12:02 UTC (permalink / raw)
  To: Ian Campbell, Jan Beulich, Shannon Zhao, shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ard.biesheuvel,
	Stefano Stabellini, peter.huangpeng, xen-devel,
	stefano.stabellini, linux-arm-kernel

On 07/12/15 10:38, Ian Campbell wrote:
> On Mon, 2015-12-07 at 03:32 -0700, Jan Beulich wrote:
>>>>> On 07.12.15 at 09:58, <zhaoshenglong@huawei.com> wrote:
>>> On 2015/11/30 22:47, Julien Grall wrote:
>>>> On 23/11/15 11:37, Stefano Stabellini wrote:
>>>>>> On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
>>>>>>>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>>>>> could you please add a couple of lines to the commit message
>>>>>> mentioning
>>>>>> why __va(phys) is an acceptable implementation of
>>>>>> arch_acpi_os_map_memory?
>>>> FWIW, I already asked this question multiple time on the previous
>>>> series
>>>> without clear answer.
>>>>
>>>> __va should only be used when the memory is direct-mapped to Xen (i.e
>>>> accessible directly). On ARM64, this is only the case for the RAM.
>>>> Can
>>>> someone confirm the ACPI will always reside to the RAM?
>>> I checked this with the UEFI SPEC. It says in 2.3.6 AArch64 Platforms:
>>> "If ACPI is supported :
>>> ● ACPI Tables loaded at boot time can be contained in memory of type
>>> EfiACPIReclaimMemory (recommended) or EfiACPIMemoryNVS."
>>>
>>> So I think it means the ACPI tables will always reside in RAM.
>>
>> I think NVS doesn't necessarily mean RAM.
> 
> That's what I thought/expected too (sounds like it could be flash, CMOS,
> ROM etc), but looking at the ACPI 6.0 spec ("16.3.2 BIOS Initialization of
> Memory") it says:
> 
>     Memory identified by the BIOS as being     reserved by the BIOS for its use.
>     OSPM is required to tag this memory as cacheable, and to save     and
>     restore its image before entering an S4 state.
> 
> IOW, if I'm reading that correctly, it actually is "memory", and it is only
> "NV" by virtue of requiring the OSPM to save/restore it over suspend (so
> not at all "NV" in the usual sense).

I think it would be safer to use vmap. It won't impact much Xen as the
mapping are mostly used during Xen boot and DOM0 creation.

Regards,

-- 
Julien Grall

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

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

* Re: [PATCH v3 07/62] arm/acpi: Add arch_acpi_os_map_memory helper function for ARM
  2015-12-07 12:02             ` Julien Grall
@ 2015-12-29 12:01               ` Shannon Zhao
  0 siblings, 0 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-12-29 12:01 UTC (permalink / raw)
  To: Julien Grall, Ian Campbell, Jan Beulich, shannon.zhao
  Cc: hangaohuai, xen-devel, stefano.stabellini, peter.huangpeng,
	Stefano Stabellini

Hi,

On 2015/12/7 20:02, Julien Grall wrote:
> On 07/12/15 10:38, Ian Campbell wrote:
>> On Mon, 2015-12-07 at 03:32 -0700, Jan Beulich wrote:
>>>>>> On 07.12.15 at 09:58, <zhaoshenglong@huawei.com> wrote:
>>>> On 2015/11/30 22:47, Julien Grall wrote:
>>>>> On 23/11/15 11:37, Stefano Stabellini wrote:
>>>>>>> On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
>>>>>>>>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>>>>>> could you please add a couple of lines to the commit message
>>>>>>> mentioning
>>>>>>> why __va(phys) is an acceptable implementation of
>>>>>>> arch_acpi_os_map_memory?
>>>>> FWIW, I already asked this question multiple time on the previous
>>>>> series
>>>>> without clear answer.
>>>>>
>>>>> __va should only be used when the memory is direct-mapped to Xen (i.e
>>>>> accessible directly). On ARM64, this is only the case for the RAM.
>>>>> Can
>>>>> someone confirm the ACPI will always reside to the RAM?
>>>> I checked this with the UEFI SPEC. It says in 2.3.6 AArch64 Platforms:
>>>> "If ACPI is supported :
>>>> ● ACPI Tables loaded at boot time can be contained in memory of type
>>>> EfiACPIReclaimMemory (recommended) or EfiACPIMemoryNVS."
>>>>
>>>> So I think it means the ACPI tables will always reside in RAM.
>>>
>>> I think NVS doesn't necessarily mean RAM.
>>
>> That's what I thought/expected too (sounds like it could be flash, CMOS,
>> ROM etc), but looking at the ACPI 6.0 spec ("16.3.2 BIOS Initialization of
>> Memory") it says:
>>
>>     Memory identified by the BIOS as being     reserved by the BIOS for its use.
>>     OSPM is required to tag this memory as cacheable, and to save     and
>>     restore its image before entering an S4 state.
>>
>> IOW, if I'm reading that correctly, it actually is "memory", and it is only
>> "NV" by virtue of requiring the OSPM to save/restore it over suspend (so
>> not at all "NV" in the usual sense).
> 
> I think it would be safer to use vmap. It won't impact much Xen as the
> mapping are mostly used during Xen boot and DOM0 creation.
> 

If it uses vmap, it needs to move acpi_boot_table_init after vm_init(),
right?

I move acpi_boot_table_init after vm_init() and rewrite
arch_acpi_os_map_memory like below.

 void __iomem *
 arch_acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
 {
-    return __va(phys);
+    mfn_t mfn = _mfn(PFN_DOWN(phys));
+    unsigned int offs = phys & (PAGE_SIZE - 1);
+
+    return __vmap(&mfn, PFN_UP(offs + size), 1, 1, PAGE_HYPERVISOR)
+           + offs;
 }

But there is a weird problem. All the ACPI tables are installed
correctly within acpi_boot_table_init() and it prints with below output:

(XEN) ACPI: RSDP FEC90014, 0024 (r2 LINARO)
(XEN) ACPI: XSDT FEC800E8, 0044 (r1 LINARO RTSMVEV8        0       1000013)
(XEN) ACPI: FACP FEC50000, 0114 (r6 LINARO RTSMVEV8        0 INTL 20150619)
(XEN) ACPI: DSDT FEC60000, 0248 (r2 LINARO RTSMVEV8        4 INTL 20150619)
(XEN) ACPI: APIC FEC70000, 02D4 (r3 LINARO RTSMVEV8        1 INTL 20150619)
(XEN) ACPI: GTDT FEC40000, 009C (r2 LINARO RTSMVEV8        1 INTL 20150619)
(XEN) ACPI: SPCR FEC30000, 0050 (r1 LINARO RTSMVEV8        0 INTL 20150619)

As you see, the physical address of DSDT table is FEC60000, but when I
print acpi_gbl_root_table_list.tables[0].address after
acpi_boot_table_init(), it becomes aafec60000. And it even becomes
d6aaaaaafec60000 when it's used in acpi_map_rest_tables(see patch 49).

But others of acpi_gbl_root_table_list don't change. E.g.
acpi_gbl_root_table_list.tables[2].address is always FEC50000.

-- 
Shannon


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

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

* [Xen-devel] [PATCH v3 20/62] arm/acpi: Add ACPI support for SMP initialization
  2015-11-30 14:57   ` [Xen-devel] " Julien Grall
@ 2015-12-30  3:11     ` Shannon Zhao
  2016-01-04 14:51       ` Stefano Stabellini
                         ` (3 more replies)
  2015-12-30  3:11     ` Shannon Zhao
  1 sibling, 4 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-12-30  3:11 UTC (permalink / raw)
  To: linux-arm-kernel



On 2015/11/30 22:57, Julien Grall wrote:
> Hi Shannon,
> 
> On 17/11/15 09:40, shannon.zhao at linaro.org wrote:
>> > diff --git a/xen/arch/arm/psci.c b/xen/arch/arm/psci.c
>> > index d800cb6..dede0e1 100644
>> > --- a/xen/arch/arm/psci.c
>> > +++ b/xen/arch/arm/psci.c
>> > @@ -22,6 +22,7 @@
>> >  #include <xen/mm.h>
>> >  #include <xen/smp.h>
>> >  #include <asm/psci.h>
>> > +#include <asm/acpi.h>
>> >  
>> >  /*
>> >   * While a 64-bit OS can make calls with SMC32 calling conventions, for
>> > @@ -86,6 +87,9 @@ int __init psci_init_0_1(void)
>> >      int ret;
>> >      const struct dt_device_node *psci;
>> >  
>> > +    if ( !acpi_disabled )
>> > +        return -EINVAL;
> Please explain in the commit message why PSCI 0.1 is not supported on ACPI.

Hi,

I check this again. There are not limitations of supporting PSCI version
in ACPI SPEC. It should support PSCI 0.1 as well. But look at the code
of linux kernel, it says it only supports PSCI 0.2+.

#define ACPI_FADT_PSCI_COMPLIANT    (1)	/* 00: [V5+] PSCI 0.2+ is
implemented */

So does it need to be consistent with Linux or support PSCI 0.1 in Xen
as well?

Thanks,
-- 
Shannon

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

* Re: [PATCH v3 20/62] arm/acpi: Add ACPI support for SMP initialization
  2015-11-30 14:57   ` [Xen-devel] " Julien Grall
  2015-12-30  3:11     ` Shannon Zhao
@ 2015-12-30  3:11     ` Shannon Zhao
  1 sibling, 0 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-12-30  3:11 UTC (permalink / raw)
  To: Julien Grall, shannon.zhao, ian.campbell, stefano.stabellini,
	andrew.cooper3, xen-devel
  Cc: hangaohuai, peter.huangpeng, linux-arm-kernel



On 2015/11/30 22:57, Julien Grall wrote:
> Hi Shannon,
> 
> On 17/11/15 09:40, shannon.zhao@linaro.org wrote:
>> > diff --git a/xen/arch/arm/psci.c b/xen/arch/arm/psci.c
>> > index d800cb6..dede0e1 100644
>> > --- a/xen/arch/arm/psci.c
>> > +++ b/xen/arch/arm/psci.c
>> > @@ -22,6 +22,7 @@
>> >  #include <xen/mm.h>
>> >  #include <xen/smp.h>
>> >  #include <asm/psci.h>
>> > +#include <asm/acpi.h>
>> >  
>> >  /*
>> >   * While a 64-bit OS can make calls with SMC32 calling conventions, for
>> > @@ -86,6 +87,9 @@ int __init psci_init_0_1(void)
>> >      int ret;
>> >      const struct dt_device_node *psci;
>> >  
>> > +    if ( !acpi_disabled )
>> > +        return -EINVAL;
> Please explain in the commit message why PSCI 0.1 is not supported on ACPI.

Hi,

I check this again. There are not limitations of supporting PSCI version
in ACPI SPEC. It should support PSCI 0.1 as well. But look at the code
of linux kernel, it says it only supports PSCI 0.2+.

#define ACPI_FADT_PSCI_COMPLIANT    (1)	/* 00: [V5+] PSCI 0.2+ is
implemented */

So does it need to be consistent with Linux or support PSCI 0.1 in Xen
as well?

Thanks,
-- 
Shannon

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

* [PATCH v3 52/62] arm/acpi: Prepare EFI memory descriptor for Dom0
  2015-11-27 14:30   ` Stefano Stabellini
@ 2015-12-31  7:40       ` Shannon Zhao
  0 siblings, 0 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-12-31  7:40 UTC (permalink / raw)
  To: linux-arm-kernel



On 2015/11/27 22:30, Stefano Stabellini wrote:
> On Tue, 17 Nov 2015, shannon.zhao at linaro.org 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.
>> > 
>> > Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
>> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> > ---
>> >  xen/arch/arm/domain_build.c |  2 ++
>> >  xen/common/efi/boot.c       | 48 +++++++++++++++++++++++++++++++++++++++++++++
>> >  xen/include/asm-arm/setup.h |  4 ++++
>> >  3 files changed, 54 insertions(+)
>> > 
>> > diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
>> > index 9d667ea..073c634 100644
>> > --- a/xen/arch/arm/domain_build.c
>> > +++ b/xen/arch/arm/domain_build.c
>> > @@ -1737,6 +1737,8 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
>> >      acpi_map_rest_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_table,
>> > +                               &kinfo->mem, tbl_add);
>> >  
>> >      return 0;
>> >  }
>> > diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
>> > index 75835ae..ff2faed 100644
>> > --- a/xen/common/efi/boot.c
>> > +++ b/xen/common/efi/boot.c
>> > @@ -1256,6 +1256,54 @@ 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, void *efi_acpi_table,
>> > +                                       const struct meminfo *mem,
>> > +                                       struct membank tbl_add[])
> This function shouldn't be in this file.
> 
> 
> 
>> > +{
>> > +    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 + TBL_MMAX);
>> > +
>> > +    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 = mem->bank[i].size/PAGE_SIZE;
> Use PAGE_SHIFT throughout the function.
> 
> 
>> > +        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 = acpi_mem.bank[i].size/PAGE_SIZE;
>> > +        memory_map[offset].Attribute = EFI_MEMORY_WB;
>> > +    }
>> > +
>> > +    for( i = 0; i < TBL_EFIT; i++, offset++ )
>> > +    {
>> > +        memory_map[offset].Type = EfiACPIReclaimMemory;
>> > +        memory_map[offset].PhysicalStart = tbl_add[i].start;
>> > +        memory_map[offset].NumberOfPages =tbl_add[i].size/PAGE_SIZE;
>> > +        memory_map[offset].Attribute = EFI_MEMORY_WB;
>> > +    }
> Can't we just use a single EFI_MEMORY_DESCRIPTOR (or maybe 2, to cover
> EfiACPIReclaimMemory and EfiReservedMemoryType regions) to describe the
> whole efi_acpi_gpa region? Using one EFI_MEMORY_DESCRIPTOR per table,
> and PAGE_ALIGNing each of them, looks like a waste of memory to me.
> Unless it's an ACPI or EFI spec requirement.
> 

Looking at the UEFI SPEC it says
"EFI memory descriptors of type EfiACPIReclaimMemory and EfiACPIMemoryNVS
must be aligned on a 4 KiB boundary and must be a multiple of 4 KiB in size"

-- 
Shannon

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

* Re: [PATCH v3 52/62] arm/acpi: Prepare EFI memory descriptor for Dom0
@ 2015-12-31  7:40       ` Shannon Zhao
  0 siblings, 0 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-12-31  7:40 UTC (permalink / raw)
  To: Stefano Stabellini, shannon.zhao
  Cc: hangaohuai, ian.campbell, peter.huangpeng, xen-devel,
	julien.grall, stefano.stabellini, jbeulich, linux-arm-kernel



On 2015/11/27 22:30, Stefano Stabellini wrote:
> On Tue, 17 Nov 2015, shannon.zhao@linaro.org 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.
>> > 
>> > Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
>> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> > ---
>> >  xen/arch/arm/domain_build.c |  2 ++
>> >  xen/common/efi/boot.c       | 48 +++++++++++++++++++++++++++++++++++++++++++++
>> >  xen/include/asm-arm/setup.h |  4 ++++
>> >  3 files changed, 54 insertions(+)
>> > 
>> > diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
>> > index 9d667ea..073c634 100644
>> > --- a/xen/arch/arm/domain_build.c
>> > +++ b/xen/arch/arm/domain_build.c
>> > @@ -1737,6 +1737,8 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
>> >      acpi_map_rest_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_table,
>> > +                               &kinfo->mem, tbl_add);
>> >  
>> >      return 0;
>> >  }
>> > diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
>> > index 75835ae..ff2faed 100644
>> > --- a/xen/common/efi/boot.c
>> > +++ b/xen/common/efi/boot.c
>> > @@ -1256,6 +1256,54 @@ 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, void *efi_acpi_table,
>> > +                                       const struct meminfo *mem,
>> > +                                       struct membank tbl_add[])
> This function shouldn't be in this file.
> 
> 
> 
>> > +{
>> > +    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 + TBL_MMAX);
>> > +
>> > +    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 = mem->bank[i].size/PAGE_SIZE;
> Use PAGE_SHIFT throughout the function.
> 
> 
>> > +        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 = acpi_mem.bank[i].size/PAGE_SIZE;
>> > +        memory_map[offset].Attribute = EFI_MEMORY_WB;
>> > +    }
>> > +
>> > +    for( i = 0; i < TBL_EFIT; i++, offset++ )
>> > +    {
>> > +        memory_map[offset].Type = EfiACPIReclaimMemory;
>> > +        memory_map[offset].PhysicalStart = tbl_add[i].start;
>> > +        memory_map[offset].NumberOfPages =tbl_add[i].size/PAGE_SIZE;
>> > +        memory_map[offset].Attribute = EFI_MEMORY_WB;
>> > +    }
> Can't we just use a single EFI_MEMORY_DESCRIPTOR (or maybe 2, to cover
> EfiACPIReclaimMemory and EfiReservedMemoryType regions) to describe the
> whole efi_acpi_gpa region? Using one EFI_MEMORY_DESCRIPTOR per table,
> and PAGE_ALIGNing each of them, looks like a waste of memory to me.
> Unless it's an ACPI or EFI spec requirement.
> 

Looking at the UEFI SPEC it says
"EFI memory descriptors of type EfiACPIReclaimMemory and EfiACPIMemoryNVS
must be aligned on a 4 KiB boundary and must be a multiple of 4 KiB in size"

-- 
Shannon

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

* [PATCH v3 40/62] arm/acpi: Estimate memory required for acpi/efi tables
  2015-11-26 16:39   ` Stefano Stabellini
@ 2015-12-31  9:16     ` Shannon Zhao
  2016-01-04 14:35       ` Stefano Stabellini
  2016-01-04 14:35       ` Stefano Stabellini
  2015-12-31  9:16     ` Shannon Zhao
  1 sibling, 2 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-12-31  9:16 UTC (permalink / raw)
  To: linux-arm-kernel



On 2015/11/27 0:39, Stefano Stabellini wrote:
> On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>
>> Estimate the memory required for loading acpi/efi tables in Dom0. Alloc
>> the pages to store the new created EFI and ACPI tables and free these
>> pages when destroying domain.
> 
> Could you please explain what you are page aligning exactly and why?
> 

At least it should be 64bit aligned of the table start address. If not,
guest will throw out an alignment fault.

ACPI: Using GIC for interrupt routing
Unhandled fault: alignment fault (0x96000021) at 0xffffff800006c19c
Internal error: : 96000021 [#1] PREEMPT SMP
Modules linked in:
CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.3.0+ #551
Hardware name: (null) (DT)
task: ffffffc008870000 ti: ffffffc00884c000 task.ti: ffffffc00884c000
PC is at acpi_get_phys_id+0x264/0x290
LR is at acpi_get_phys_id+0x178/0x290

> 
>>
>> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> ---
>>  xen/arch/arm/domain.c       |  4 +++
>>  xen/arch/arm/domain_build.c | 80 ++++++++++++++++++++++++++++++++++++++++++++-
>>  xen/common/efi/boot.c       | 21 ++++++++++++
>>  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 880d0a6..10c58c4 100644
>> --- a/xen/arch/arm/domain.c
>> +++ b/xen/arch/arm/domain.c
>> @@ -638,6 +638,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 0c3441a..b5ed44c 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,78 @@ 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 += PAGE_ALIGN(sizeof(struct acpi_table_fadt));
>> +    acpi_size += PAGE_ALIGN(sizeof(struct acpi_table_stao));
>> +
>> +    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 += PAGE_ALIGN(madt_size);
> 
> are the MADT and FADT tables guaranteed to be on separate pages or is it
> just an estimate?
> 
> 
>> +    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));
>> +    acpi_size += PAGE_ALIGN(table->length + sizeof(u64));
>> +    acpi_os_unmap_memory(table, sizeof(struct acpi_table_header));
>> +    acpi_os_unmap_memory(rsdp_tbl, sizeof(struct acpi_table_rsdp));
>> +
>> +    acpi_size += PAGE_ALIGN(sizeof(struct acpi_table_rsdp));
>> +    d->arch.efi_acpi_len = PAGE_ALIGN(efi_size) + PAGE_ALIGN(acpi_size);
>> +
>> +    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 -1;
> 
> 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 +1614,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..78d8ae9 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,26 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
>>      for( ; ; ); /* not reached */
>>  }
>>  
>> +#ifdef CONFIG_ACPI
>> +/* 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;
>> +    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 = PAGE_ALIGN(est_size + ect_size + fw_vendor_size)
>> +           + PAGE_ALIGN(emd_size *
>> +                        (mem_nr_banks + acpi_mem.nr_banks + TBL_MMAX));
> 
> Why are they on two separate pages? Is it mandated by the EFI spec?
> Why are you adding TBL_MMAX to the multiplicand here?
> 
> I don't like that we are passing mem_nr_banks as argument but we are
> accessing acpi_mem.nr_banks from the global variable. I would prefer if
> they were both passed as arguments.
> 
> 
>> +    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.1.0
>>
> 
> .
> 

-- 
Shannon

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

* Re: [PATCH v3 40/62] arm/acpi: Estimate memory required for acpi/efi tables
  2015-11-26 16:39   ` Stefano Stabellini
  2015-12-31  9:16     ` Shannon Zhao
@ 2015-12-31  9:16     ` Shannon Zhao
  1 sibling, 0 replies; 426+ messages in thread
From: Shannon Zhao @ 2015-12-31  9:16 UTC (permalink / raw)
  To: Stefano Stabellini, shannon.zhao
  Cc: mark.rutland, hangaohuai, keir, ian.campbell, ard.biesheuvel,
	andrew.cooper3, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, linux-arm-kernel, jbeulich, roger.pau,
	christoffer.dall, david.vrabel



On 2015/11/27 0:39, Stefano Stabellini wrote:
> On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>
>> Estimate the memory required for loading acpi/efi tables in Dom0. Alloc
>> the pages to store the new created EFI and ACPI tables and free these
>> pages when destroying domain.
> 
> Could you please explain what you are page aligning exactly and why?
> 

At least it should be 64bit aligned of the table start address. If not,
guest will throw out an alignment fault.

ACPI: Using GIC for interrupt routing
Unhandled fault: alignment fault (0x96000021) at 0xffffff800006c19c
Internal error: : 96000021 [#1] PREEMPT SMP
Modules linked in:
CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.3.0+ #551
Hardware name: (null) (DT)
task: ffffffc008870000 ti: ffffffc00884c000 task.ti: ffffffc00884c000
PC is at acpi_get_phys_id+0x264/0x290
LR is at acpi_get_phys_id+0x178/0x290

> 
>>
>> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> ---
>>  xen/arch/arm/domain.c       |  4 +++
>>  xen/arch/arm/domain_build.c | 80 ++++++++++++++++++++++++++++++++++++++++++++-
>>  xen/common/efi/boot.c       | 21 ++++++++++++
>>  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 880d0a6..10c58c4 100644
>> --- a/xen/arch/arm/domain.c
>> +++ b/xen/arch/arm/domain.c
>> @@ -638,6 +638,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 0c3441a..b5ed44c 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,78 @@ 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 += PAGE_ALIGN(sizeof(struct acpi_table_fadt));
>> +    acpi_size += PAGE_ALIGN(sizeof(struct acpi_table_stao));
>> +
>> +    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 += PAGE_ALIGN(madt_size);
> 
> are the MADT and FADT tables guaranteed to be on separate pages or is it
> just an estimate?
> 
> 
>> +    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));
>> +    acpi_size += PAGE_ALIGN(table->length + sizeof(u64));
>> +    acpi_os_unmap_memory(table, sizeof(struct acpi_table_header));
>> +    acpi_os_unmap_memory(rsdp_tbl, sizeof(struct acpi_table_rsdp));
>> +
>> +    acpi_size += PAGE_ALIGN(sizeof(struct acpi_table_rsdp));
>> +    d->arch.efi_acpi_len = PAGE_ALIGN(efi_size) + PAGE_ALIGN(acpi_size);
>> +
>> +    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 -1;
> 
> 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 +1614,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..78d8ae9 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,26 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
>>      for( ; ; ); /* not reached */
>>  }
>>  
>> +#ifdef CONFIG_ACPI
>> +/* 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;
>> +    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 = PAGE_ALIGN(est_size + ect_size + fw_vendor_size)
>> +           + PAGE_ALIGN(emd_size *
>> +                        (mem_nr_banks + acpi_mem.nr_banks + TBL_MMAX));
> 
> Why are they on two separate pages? Is it mandated by the EFI spec?
> Why are you adding TBL_MMAX to the multiplicand here?
> 
> I don't like that we are passing mem_nr_banks as argument but we are
> accessing acpi_mem.nr_banks from the global variable. I would prefer if
> they were both passed as arguments.
> 
> 
>> +    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.1.0
>>
> 
> .
> 

-- 
Shannon

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

* [Xen-devel] [PATCH v3 40/62] arm/acpi: Estimate memory required for acpi/efi tables
  2015-11-30 15:14     ` Julien Grall
  (?)
@ 2016-01-04  9:03     ` Shannon Zhao
  2016-01-04 14:34       ` Stefano Stabellini
  2016-01-04 14:34       ` Stefano Stabellini
  -1 siblings, 2 replies; 426+ messages in thread
From: Shannon Zhao @ 2016-01-04  9:03 UTC (permalink / raw)
  To: linux-arm-kernel



On 2015/11/30 23:14, Julien Grall wrote:
> Hi Shannon,
> 
> On 17/11/15 09:40, shannon.zhao at linaro.org wrote:
>> diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
>> index 53c7452..78d8ae9 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,26 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
>>      for( ; ; ); /* not reached */
>>  }
>>  
>> +#ifdef CONFIG_ACPI
>> +/* 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;
>> +    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 = PAGE_ALIGN(est_size + ect_size + fw_vendor_size)
>> +           + PAGE_ALIGN(emd_size *
>> +                        (mem_nr_banks + acpi_mem.nr_banks + TBL_MMAX));
>> +
>> +    return size;
>> +}
>> +#endif
>> +
> 
> efi/boot.c only contains code related to the stub EFI. This is not the
> case of this code.
> 

I add these codes at this file because I want to reuse the definitions
of EFI structures like EFI_SYSTEM_TABLE. Parth re-define those
structures at previous patch set and one comment suggested to reuse the
existing ones. If I add these codes in xen/arch/arm/domain_build.c, it
will have some conflicts. E.g:

In file included from /home/open-source/xen/xen/include/asm/efibind.h:2:0,
                 from domain_build.c:29:
/home/open-source/xen/xen/include/asm/arm64/efibind.h:86:20: error:
conflicting types for 'UINT64'
 typedef uint64_t   UINT64;
                    ^
In file included from /home/open-source/xen/xen/include/acpi/acpi.h:57:0,
                 from /home/open-source/xen/xen/include/xen/acpi.h:33,
                 from domain_build.c:15:
/home/open-source/xen/xen/include/acpi/actypes.h:130:35: note: previous
declaration of 'UINT64' was here
 typedef COMPILER_DEPENDENT_UINT64 UINT64;

> Moreover, this code won't compile on x86 because acpi_mem is only
> defined for ARM.
> 
> Regards,
> 

Thanks,
-- 
Shannon

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

* Re: [PATCH v3 40/62] arm/acpi: Estimate memory required for acpi/efi tables
  2015-11-30 15:14     ` Julien Grall
  (?)
  (?)
@ 2016-01-04  9:03     ` Shannon Zhao
  -1 siblings, 0 replies; 426+ messages in thread
From: Shannon Zhao @ 2016-01-04  9:03 UTC (permalink / raw)
  To: Julien Grall, shannon.zhao, ian.campbell, stefano.stabellini, xen-devel
  Cc: hangaohuai, peter.huangpeng, linux-arm-kernel



On 2015/11/30 23:14, Julien Grall wrote:
> Hi Shannon,
> 
> On 17/11/15 09:40, shannon.zhao@linaro.org wrote:
>> diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
>> index 53c7452..78d8ae9 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,26 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
>>      for( ; ; ); /* not reached */
>>  }
>>  
>> +#ifdef CONFIG_ACPI
>> +/* 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;
>> +    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 = PAGE_ALIGN(est_size + ect_size + fw_vendor_size)
>> +           + PAGE_ALIGN(emd_size *
>> +                        (mem_nr_banks + acpi_mem.nr_banks + TBL_MMAX));
>> +
>> +    return size;
>> +}
>> +#endif
>> +
> 
> efi/boot.c only contains code related to the stub EFI. This is not the
> case of this code.
> 

I add these codes at this file because I want to reuse the definitions
of EFI structures like EFI_SYSTEM_TABLE. Parth re-define those
structures at previous patch set and one comment suggested to reuse the
existing ones. If I add these codes in xen/arch/arm/domain_build.c, it
will have some conflicts. E.g:

In file included from /home/open-source/xen/xen/include/asm/efibind.h:2:0,
                 from domain_build.c:29:
/home/open-source/xen/xen/include/asm/arm64/efibind.h:86:20: error:
conflicting types for 'UINT64'
 typedef uint64_t   UINT64;
                    ^
In file included from /home/open-source/xen/xen/include/acpi/acpi.h:57:0,
                 from /home/open-source/xen/xen/include/xen/acpi.h:33,
                 from domain_build.c:15:
/home/open-source/xen/xen/include/acpi/actypes.h:130:35: note: previous
declaration of 'UINT64' was here
 typedef COMPILER_DEPENDENT_UINT64 UINT64;

> Moreover, this code won't compile on x86 because acpi_mem is only
> defined for ARM.
> 
> Regards,
> 

Thanks,
-- 
Shannon

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

* [Xen-devel] [PATCH v3 40/62] arm/acpi: Estimate memory required for acpi/efi tables
  2016-01-04  9:03     ` [Xen-devel] " Shannon Zhao
@ 2016-01-04 14:34       ` Stefano Stabellini
  2016-01-04 14:34       ` Stefano Stabellini
  1 sibling, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2016-01-04 14:34 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, 4 Jan 2016, Shannon Zhao wrote:
> On 2015/11/30 23:14, Julien Grall wrote:
> > Hi Shannon,
> > 
> > On 17/11/15 09:40, shannon.zhao at linaro.org wrote:
> >> diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
> >> index 53c7452..78d8ae9 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,26 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
> >>      for( ; ; ); /* not reached */
> >>  }
> >>  
> >> +#ifdef CONFIG_ACPI
> >> +/* 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;
> >> +    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 = PAGE_ALIGN(est_size + ect_size + fw_vendor_size)
> >> +           + PAGE_ALIGN(emd_size *
> >> +                        (mem_nr_banks + acpi_mem.nr_banks + TBL_MMAX));
> >> +
> >> +    return size;
> >> +}
> >> +#endif
> >> +
> > 
> > efi/boot.c only contains code related to the stub EFI. This is not the
> > case of this code.
> > 
> 
> I add these codes at this file because I want to reuse the definitions
> of EFI structures like EFI_SYSTEM_TABLE. Parth re-define those
> structures at previous patch set and one comment suggested to reuse the
> existing ones. If I add these codes in xen/arch/arm/domain_build.c, it
> will have some conflicts. E.g:
> 
> In file included from /home/open-source/xen/xen/include/asm/efibind.h:2:0,
>                  from domain_build.c:29:
> /home/open-source/xen/xen/include/asm/arm64/efibind.h:86:20: error:
> conflicting types for 'UINT64'
>  typedef uint64_t   UINT64;
>                     ^
> In file included from /home/open-source/xen/xen/include/acpi/acpi.h:57:0,
>                  from /home/open-source/xen/xen/include/xen/acpi.h:33,
>                  from domain_build.c:15:
> /home/open-source/xen/xen/include/acpi/actypes.h:130:35: note: previous
> declaration of 'UINT64' was here
>  typedef COMPILER_DEPENDENT_UINT64 UINT64;

I think that having this code in efi/boot.c might be OK, but let's see
what Jan thinks.



> > Moreover, this code won't compile on x86 because acpi_mem is only
> > defined for ARM.
> > 
> > Regards,
> > 
> 
> Thanks,
> -- 
> Shannon
> 

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

* Re: [PATCH v3 40/62] arm/acpi: Estimate memory required for acpi/efi tables
  2016-01-04  9:03     ` [Xen-devel] " Shannon Zhao
  2016-01-04 14:34       ` Stefano Stabellini
@ 2016-01-04 14:34       ` Stefano Stabellini
  1 sibling, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2016-01-04 14:34 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: hangaohuai, Ian Campbell, peter.huangpeng, xen-devel,
	Julien Grall, stefano.stabellini, shannon.zhao, linux-arm-kernel

On Mon, 4 Jan 2016, Shannon Zhao wrote:
> On 2015/11/30 23:14, Julien Grall wrote:
> > Hi Shannon,
> > 
> > On 17/11/15 09:40, shannon.zhao@linaro.org wrote:
> >> diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
> >> index 53c7452..78d8ae9 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,26 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
> >>      for( ; ; ); /* not reached */
> >>  }
> >>  
> >> +#ifdef CONFIG_ACPI
> >> +/* 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;
> >> +    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 = PAGE_ALIGN(est_size + ect_size + fw_vendor_size)
> >> +           + PAGE_ALIGN(emd_size *
> >> +                        (mem_nr_banks + acpi_mem.nr_banks + TBL_MMAX));
> >> +
> >> +    return size;
> >> +}
> >> +#endif
> >> +
> > 
> > efi/boot.c only contains code related to the stub EFI. This is not the
> > case of this code.
> > 
> 
> I add these codes at this file because I want to reuse the definitions
> of EFI structures like EFI_SYSTEM_TABLE. Parth re-define those
> structures at previous patch set and one comment suggested to reuse the
> existing ones. If I add these codes in xen/arch/arm/domain_build.c, it
> will have some conflicts. E.g:
> 
> In file included from /home/open-source/xen/xen/include/asm/efibind.h:2:0,
>                  from domain_build.c:29:
> /home/open-source/xen/xen/include/asm/arm64/efibind.h:86:20: error:
> conflicting types for 'UINT64'
>  typedef uint64_t   UINT64;
>                     ^
> In file included from /home/open-source/xen/xen/include/acpi/acpi.h:57:0,
>                  from /home/open-source/xen/xen/include/xen/acpi.h:33,
>                  from domain_build.c:15:
> /home/open-source/xen/xen/include/acpi/actypes.h:130:35: note: previous
> declaration of 'UINT64' was here
>  typedef COMPILER_DEPENDENT_UINT64 UINT64;

I think that having this code in efi/boot.c might be OK, but let's see
what Jan thinks.



> > Moreover, this code won't compile on x86 because acpi_mem is only
> > defined for ARM.
> > 
> > Regards,
> > 
> 
> Thanks,
> -- 
> Shannon
> 

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

* [PATCH v3 40/62] arm/acpi: Estimate memory required for acpi/efi tables
  2015-12-31  9:16     ` Shannon Zhao
  2016-01-04 14:35       ` Stefano Stabellini
@ 2016-01-04 14:35       ` Stefano Stabellini
  1 sibling, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2016-01-04 14:35 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, 31 Dec 2015, Shannon Zhao wrote:
> On 2015/11/27 0:39, Stefano Stabellini wrote:
> > On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
> >> From: Shannon Zhao <shannon.zhao@linaro.org>
> >>
> >> Estimate the memory required for loading acpi/efi tables in Dom0. Alloc
> >> the pages to store the new created EFI and ACPI tables and free these
> >> pages when destroying domain.
> > 
> > Could you please explain what you are page aligning exactly and why?
> > 
> 
> At least it should be 64bit aligned of the table start address. If not,
> guest will throw out an alignment fault.
> 
> ACPI: Using GIC for interrupt routing
> Unhandled fault: alignment fault (0x96000021) at 0xffffff800006c19c
> Internal error: : 96000021 [#1] PREEMPT SMP
> Modules linked in:
> CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.3.0+ #551
> Hardware name: (null) (DT)
> task: ffffffc008870000 ti: ffffffc00884c000 task.ti: ffffffc00884c000
> PC is at acpi_get_phys_id+0x264/0x290
> LR is at acpi_get_phys_id+0x178/0x290

OK, but between page alignment and 64-bit alignment there is a very big
difference.


> > 
> >>
> >> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> >> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> >> ---
> >>  xen/arch/arm/domain.c       |  4 +++
> >>  xen/arch/arm/domain_build.c | 80 ++++++++++++++++++++++++++++++++++++++++++++-
> >>  xen/common/efi/boot.c       | 21 ++++++++++++
> >>  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 880d0a6..10c58c4 100644
> >> --- a/xen/arch/arm/domain.c
> >> +++ b/xen/arch/arm/domain.c
> >> @@ -638,6 +638,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 0c3441a..b5ed44c 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,78 @@ 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 += PAGE_ALIGN(sizeof(struct acpi_table_fadt));
> >> +    acpi_size += PAGE_ALIGN(sizeof(struct acpi_table_stao));
> >> +
> >> +    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 += PAGE_ALIGN(madt_size);
> > 
> > are the MADT and FADT tables guaranteed to be on separate pages or is it
> > just an estimate?
> > 
> > 
> >> +    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));
> >> +    acpi_size += PAGE_ALIGN(table->length + sizeof(u64));
> >> +    acpi_os_unmap_memory(table, sizeof(struct acpi_table_header));
> >> +    acpi_os_unmap_memory(rsdp_tbl, sizeof(struct acpi_table_rsdp));
> >> +
> >> +    acpi_size += PAGE_ALIGN(sizeof(struct acpi_table_rsdp));
> >> +    d->arch.efi_acpi_len = PAGE_ALIGN(efi_size) + PAGE_ALIGN(acpi_size);
> >> +
> >> +    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 -1;
> > 
> > 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 +1614,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..78d8ae9 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,26 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
> >>      for( ; ; ); /* not reached */
> >>  }
> >>  
> >> +#ifdef CONFIG_ACPI
> >> +/* 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;
> >> +    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 = PAGE_ALIGN(est_size + ect_size + fw_vendor_size)
> >> +           + PAGE_ALIGN(emd_size *
> >> +                        (mem_nr_banks + acpi_mem.nr_banks + TBL_MMAX));
> > 
> > Why are they on two separate pages? Is it mandated by the EFI spec?
> > Why are you adding TBL_MMAX to the multiplicand here?
> > 
> > I don't like that we are passing mem_nr_banks as argument but we are
> > accessing acpi_mem.nr_banks from the global variable. I would prefer if
> > they were both passed as arguments.
> > 
> > 
> >> +    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.1.0
> >>
> > 
> > .
> > 
> 
> -- 
> Shannon
> 

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

* Re: [PATCH v3 40/62] arm/acpi: Estimate memory required for acpi/efi tables
  2015-12-31  9:16     ` Shannon Zhao
@ 2016-01-04 14:35       ` Stefano Stabellini
  2016-01-04 14:35       ` Stefano Stabellini
  1 sibling, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2016-01-04 14:35 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: mark.rutland, hangaohuai, david.vrabel, keir, ian.campbell,
	Stefano Stabellini, andrew.cooper3, ard.biesheuvel,
	peter.huangpeng, xen-devel, julien.grall, stefano.stabellini,
	shannon.zhao, jbeulich, roger.pau, christoffer.dall,
	linux-arm-kernel

On Thu, 31 Dec 2015, Shannon Zhao wrote:
> On 2015/11/27 0:39, Stefano Stabellini wrote:
> > On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
> >> From: Shannon Zhao <shannon.zhao@linaro.org>
> >>
> >> Estimate the memory required for loading acpi/efi tables in Dom0. Alloc
> >> the pages to store the new created EFI and ACPI tables and free these
> >> pages when destroying domain.
> > 
> > Could you please explain what you are page aligning exactly and why?
> > 
> 
> At least it should be 64bit aligned of the table start address. If not,
> guest will throw out an alignment fault.
> 
> ACPI: Using GIC for interrupt routing
> Unhandled fault: alignment fault (0x96000021) at 0xffffff800006c19c
> Internal error: : 96000021 [#1] PREEMPT SMP
> Modules linked in:
> CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.3.0+ #551
> Hardware name: (null) (DT)
> task: ffffffc008870000 ti: ffffffc00884c000 task.ti: ffffffc00884c000
> PC is at acpi_get_phys_id+0x264/0x290
> LR is at acpi_get_phys_id+0x178/0x290

OK, but between page alignment and 64-bit alignment there is a very big
difference.


> > 
> >>
> >> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> >> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> >> ---
> >>  xen/arch/arm/domain.c       |  4 +++
> >>  xen/arch/arm/domain_build.c | 80 ++++++++++++++++++++++++++++++++++++++++++++-
> >>  xen/common/efi/boot.c       | 21 ++++++++++++
> >>  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 880d0a6..10c58c4 100644
> >> --- a/xen/arch/arm/domain.c
> >> +++ b/xen/arch/arm/domain.c
> >> @@ -638,6 +638,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 0c3441a..b5ed44c 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,78 @@ 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 += PAGE_ALIGN(sizeof(struct acpi_table_fadt));
> >> +    acpi_size += PAGE_ALIGN(sizeof(struct acpi_table_stao));
> >> +
> >> +    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 += PAGE_ALIGN(madt_size);
> > 
> > are the MADT and FADT tables guaranteed to be on separate pages or is it
> > just an estimate?
> > 
> > 
> >> +    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));
> >> +    acpi_size += PAGE_ALIGN(table->length + sizeof(u64));
> >> +    acpi_os_unmap_memory(table, sizeof(struct acpi_table_header));
> >> +    acpi_os_unmap_memory(rsdp_tbl, sizeof(struct acpi_table_rsdp));
> >> +
> >> +    acpi_size += PAGE_ALIGN(sizeof(struct acpi_table_rsdp));
> >> +    d->arch.efi_acpi_len = PAGE_ALIGN(efi_size) + PAGE_ALIGN(acpi_size);
> >> +
> >> +    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 -1;
> > 
> > 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 +1614,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..78d8ae9 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,26 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
> >>      for( ; ; ); /* not reached */
> >>  }
> >>  
> >> +#ifdef CONFIG_ACPI
> >> +/* 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;
> >> +    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 = PAGE_ALIGN(est_size + ect_size + fw_vendor_size)
> >> +           + PAGE_ALIGN(emd_size *
> >> +                        (mem_nr_banks + acpi_mem.nr_banks + TBL_MMAX));
> > 
> > Why are they on two separate pages? Is it mandated by the EFI spec?
> > Why are you adding TBL_MMAX to the multiplicand here?
> > 
> > I don't like that we are passing mem_nr_banks as argument but we are
> > accessing acpi_mem.nr_banks from the global variable. I would prefer if
> > they were both passed as arguments.
> > 
> > 
> >> +    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.1.0
> >>
> > 
> > .
> > 
> 
> -- 
> Shannon
> 

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

* [Xen-devel] [PATCH v3 20/62] arm/acpi: Add ACPI support for SMP initialization
  2015-12-30  3:11     ` Shannon Zhao
  2016-01-04 14:51       ` Stefano Stabellini
@ 2016-01-04 14:51       ` Stefano Stabellini
  2016-01-04 15:00         ` Mark Rutland
  2016-01-04 15:00         ` Mark Rutland
  2016-01-04 15:12       ` [Xen-devel] " Mark Rutland
  2016-01-04 15:12       ` Mark Rutland
  3 siblings, 2 replies; 426+ messages in thread
From: Stefano Stabellini @ 2016-01-04 14:51 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, 30 Dec 2015, Shannon Zhao wrote:
> On 2015/11/30 22:57, Julien Grall wrote:
> > Hi Shannon,
> > 
> > On 17/11/15 09:40, shannon.zhao at linaro.org wrote:
> >> > diff --git a/xen/arch/arm/psci.c b/xen/arch/arm/psci.c
> >> > index d800cb6..dede0e1 100644
> >> > --- a/xen/arch/arm/psci.c
> >> > +++ b/xen/arch/arm/psci.c
> >> > @@ -22,6 +22,7 @@
> >> >  #include <xen/mm.h>
> >> >  #include <xen/smp.h>
> >> >  #include <asm/psci.h>
> >> > +#include <asm/acpi.h>
> >> >  
> >> >  /*
> >> >   * While a 64-bit OS can make calls with SMC32 calling conventions, for
> >> > @@ -86,6 +87,9 @@ int __init psci_init_0_1(void)
> >> >      int ret;
> >> >      const struct dt_device_node *psci;
> >> >  
> >> > +    if ( !acpi_disabled )
> >> > +        return -EINVAL;
> > Please explain in the commit message why PSCI 0.1 is not supported on ACPI.
> 
> Hi,
> 
> I check this again. There are not limitations of supporting PSCI version
> in ACPI SPEC. It should support PSCI 0.1 as well. But look at the code
> of linux kernel, it says it only supports PSCI 0.2+.
> 
> #define ACPI_FADT_PSCI_COMPLIANT    (1)	/* 00: [V5+] PSCI 0.2+ is
> implemented */
> 
> So does it need to be consistent with Linux or support PSCI 0.1 in Xen
> as well?

I don't think it needs to be consistent with Linux. I would support PSCI
0.1 too.

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

* Re: [PATCH v3 20/62] arm/acpi: Add ACPI support for SMP initialization
  2015-12-30  3:11     ` Shannon Zhao
@ 2016-01-04 14:51       ` Stefano Stabellini
  2016-01-04 14:51       ` [Xen-devel] " Stefano Stabellini
                         ` (2 subsequent siblings)
  3 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2016-01-04 14:51 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: hangaohuai, ian.campbell, andrew.cooper3, peter.huangpeng,
	xen-devel, Julien Grall, stefano.stabellini, shannon.zhao,
	linux-arm-kernel

On Wed, 30 Dec 2015, Shannon Zhao wrote:
> On 2015/11/30 22:57, Julien Grall wrote:
> > Hi Shannon,
> > 
> > On 17/11/15 09:40, shannon.zhao@linaro.org wrote:
> >> > diff --git a/xen/arch/arm/psci.c b/xen/arch/arm/psci.c
> >> > index d800cb6..dede0e1 100644
> >> > --- a/xen/arch/arm/psci.c
> >> > +++ b/xen/arch/arm/psci.c
> >> > @@ -22,6 +22,7 @@
> >> >  #include <xen/mm.h>
> >> >  #include <xen/smp.h>
> >> >  #include <asm/psci.h>
> >> > +#include <asm/acpi.h>
> >> >  
> >> >  /*
> >> >   * While a 64-bit OS can make calls with SMC32 calling conventions, for
> >> > @@ -86,6 +87,9 @@ int __init psci_init_0_1(void)
> >> >      int ret;
> >> >      const struct dt_device_node *psci;
> >> >  
> >> > +    if ( !acpi_disabled )
> >> > +        return -EINVAL;
> > Please explain in the commit message why PSCI 0.1 is not supported on ACPI.
> 
> Hi,
> 
> I check this again. There are not limitations of supporting PSCI version
> in ACPI SPEC. It should support PSCI 0.1 as well. But look at the code
> of linux kernel, it says it only supports PSCI 0.2+.
> 
> #define ACPI_FADT_PSCI_COMPLIANT    (1)	/* 00: [V5+] PSCI 0.2+ is
> implemented */
> 
> So does it need to be consistent with Linux or support PSCI 0.1 in Xen
> as well?

I don't think it needs to be consistent with Linux. I would support PSCI
0.1 too.

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

* [PATCH v3 52/62] arm/acpi: Prepare EFI memory descriptor for Dom0
  2015-12-31  7:40       ` Shannon Zhao
  (?)
@ 2016-01-04 14:54       ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2016-01-04 14:54 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, 31 Dec 2015, Shannon Zhao wrote:
> On 2015/11/27 22:30, Stefano Stabellini wrote:
> > On Tue, 17 Nov 2015, shannon.zhao at linaro.org 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.
> >> > 
> >> > Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> >> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> >> > ---
> >> >  xen/arch/arm/domain_build.c |  2 ++
> >> >  xen/common/efi/boot.c       | 48 +++++++++++++++++++++++++++++++++++++++++++++
> >> >  xen/include/asm-arm/setup.h |  4 ++++
> >> >  3 files changed, 54 insertions(+)
> >> > 
> >> > diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> >> > index 9d667ea..073c634 100644
> >> > --- a/xen/arch/arm/domain_build.c
> >> > +++ b/xen/arch/arm/domain_build.c
> >> > @@ -1737,6 +1737,8 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
> >> >      acpi_map_rest_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_table,
> >> > +                               &kinfo->mem, tbl_add);
> >> >  
> >> >      return 0;
> >> >  }
> >> > diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
> >> > index 75835ae..ff2faed 100644
> >> > --- a/xen/common/efi/boot.c
> >> > +++ b/xen/common/efi/boot.c
> >> > @@ -1256,6 +1256,54 @@ 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, void *efi_acpi_table,
> >> > +                                       const struct meminfo *mem,
> >> > +                                       struct membank tbl_add[])
> > This function shouldn't be in this file.
> > 
> > 
> > 
> >> > +{
> >> > +    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 + TBL_MMAX);
> >> > +
> >> > +    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 = mem->bank[i].size/PAGE_SIZE;
> > Use PAGE_SHIFT throughout the function.
> > 
> > 
> >> > +        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 = acpi_mem.bank[i].size/PAGE_SIZE;
> >> > +        memory_map[offset].Attribute = EFI_MEMORY_WB;
> >> > +    }
> >> > +
> >> > +    for( i = 0; i < TBL_EFIT; i++, offset++ )
> >> > +    {
> >> > +        memory_map[offset].Type = EfiACPIReclaimMemory;
> >> > +        memory_map[offset].PhysicalStart = tbl_add[i].start;
> >> > +        memory_map[offset].NumberOfPages =tbl_add[i].size/PAGE_SIZE;
> >> > +        memory_map[offset].Attribute = EFI_MEMORY_WB;
> >> > +    }
> > Can't we just use a single EFI_MEMORY_DESCRIPTOR (or maybe 2, to cover
> > EfiACPIReclaimMemory and EfiReservedMemoryType regions) to describe the
> > whole efi_acpi_gpa region? Using one EFI_MEMORY_DESCRIPTOR per table,
> > and PAGE_ALIGNing each of them, looks like a waste of memory to me.
> > Unless it's an ACPI or EFI spec requirement.
> > 
> 
> Looking at the UEFI SPEC it says
> "EFI memory descriptors of type EfiACPIReclaimMemory and EfiACPIMemoryNVS
> must be aligned on a 4 KiB boundary and must be a multiple of 4 KiB in size"

OK, but can we use only one, 4 KiB aligned, descriptor for all tables?

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

* Re: [PATCH v3 52/62] arm/acpi: Prepare EFI memory descriptor for Dom0
  2015-12-31  7:40       ` Shannon Zhao
  (?)
  (?)
@ 2016-01-04 14:54       ` Stefano Stabellini
  -1 siblings, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2016-01-04 14:54 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: hangaohuai, ian.campbell, Stefano Stabellini, peter.huangpeng,
	xen-devel, julien.grall, stefano.stabellini, shannon.zhao,
	jbeulich, linux-arm-kernel

On Thu, 31 Dec 2015, Shannon Zhao wrote:
> On 2015/11/27 22:30, Stefano Stabellini wrote:
> > On Tue, 17 Nov 2015, shannon.zhao@linaro.org 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.
> >> > 
> >> > Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> >> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> >> > ---
> >> >  xen/arch/arm/domain_build.c |  2 ++
> >> >  xen/common/efi/boot.c       | 48 +++++++++++++++++++++++++++++++++++++++++++++
> >> >  xen/include/asm-arm/setup.h |  4 ++++
> >> >  3 files changed, 54 insertions(+)
> >> > 
> >> > diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> >> > index 9d667ea..073c634 100644
> >> > --- a/xen/arch/arm/domain_build.c
> >> > +++ b/xen/arch/arm/domain_build.c
> >> > @@ -1737,6 +1737,8 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
> >> >      acpi_map_rest_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_table,
> >> > +                               &kinfo->mem, tbl_add);
> >> >  
> >> >      return 0;
> >> >  }
> >> > diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
> >> > index 75835ae..ff2faed 100644
> >> > --- a/xen/common/efi/boot.c
> >> > +++ b/xen/common/efi/boot.c
> >> > @@ -1256,6 +1256,54 @@ 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, void *efi_acpi_table,
> >> > +                                       const struct meminfo *mem,
> >> > +                                       struct membank tbl_add[])
> > This function shouldn't be in this file.
> > 
> > 
> > 
> >> > +{
> >> > +    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 + TBL_MMAX);
> >> > +
> >> > +    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 = mem->bank[i].size/PAGE_SIZE;
> > Use PAGE_SHIFT throughout the function.
> > 
> > 
> >> > +        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 = acpi_mem.bank[i].size/PAGE_SIZE;
> >> > +        memory_map[offset].Attribute = EFI_MEMORY_WB;
> >> > +    }
> >> > +
> >> > +    for( i = 0; i < TBL_EFIT; i++, offset++ )
> >> > +    {
> >> > +        memory_map[offset].Type = EfiACPIReclaimMemory;
> >> > +        memory_map[offset].PhysicalStart = tbl_add[i].start;
> >> > +        memory_map[offset].NumberOfPages =tbl_add[i].size/PAGE_SIZE;
> >> > +        memory_map[offset].Attribute = EFI_MEMORY_WB;
> >> > +    }
> > Can't we just use a single EFI_MEMORY_DESCRIPTOR (or maybe 2, to cover
> > EfiACPIReclaimMemory and EfiReservedMemoryType regions) to describe the
> > whole efi_acpi_gpa region? Using one EFI_MEMORY_DESCRIPTOR per table,
> > and PAGE_ALIGNing each of them, looks like a waste of memory to me.
> > Unless it's an ACPI or EFI spec requirement.
> > 
> 
> Looking at the UEFI SPEC it says
> "EFI memory descriptors of type EfiACPIReclaimMemory and EfiACPIMemoryNVS
> must be aligned on a 4 KiB boundary and must be a multiple of 4 KiB in size"

OK, but can we use only one, 4 KiB aligned, descriptor for all tables?

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

* [Xen-devel] [PATCH v3 20/62] arm/acpi: Add ACPI support for SMP initialization
  2016-01-04 14:51       ` [Xen-devel] " Stefano Stabellini
@ 2016-01-04 15:00         ` Mark Rutland
  2016-01-04 15:14           ` Mark Rutland
  2016-01-04 15:14           ` Mark Rutland
  2016-01-04 15:00         ` Mark Rutland
  1 sibling, 2 replies; 426+ messages in thread
From: Mark Rutland @ 2016-01-04 15:00 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Jan 04, 2016 at 02:51:51PM +0000, Stefano Stabellini wrote:
> On Wed, 30 Dec 2015, Shannon Zhao wrote:
> > On 2015/11/30 22:57, Julien Grall wrote:
> > > Hi Shannon,
> > > 
> > > On 17/11/15 09:40, shannon.zhao at linaro.org wrote:
> > >> > diff --git a/xen/arch/arm/psci.c b/xen/arch/arm/psci.c
> > >> > index d800cb6..dede0e1 100644
> > >> > --- a/xen/arch/arm/psci.c
> > >> > +++ b/xen/arch/arm/psci.c
> > >> > @@ -22,6 +22,7 @@
> > >> >  #include <xen/mm.h>
> > >> >  #include <xen/smp.h>
> > >> >  #include <asm/psci.h>
> > >> > +#include <asm/acpi.h>
> > >> >  
> > >> >  /*
> > >> >   * While a 64-bit OS can make calls with SMC32 calling conventions, for
> > >> > @@ -86,6 +87,9 @@ int __init psci_init_0_1(void)
> > >> >      int ret;
> > >> >      const struct dt_device_node *psci;
> > >> >  
> > >> > +    if ( !acpi_disabled )
> > >> > +        return -EINVAL;
> > > Please explain in the commit message why PSCI 0.1 is not supported on ACPI.
> > 
> > Hi,
> > 
> > I check this again. There are not limitations of supporting PSCI version
> > in ACPI SPEC. It should support PSCI 0.1 as well. But look at the code
> > of linux kernel, it says it only supports PSCI 0.2+.
> > 
> > #define ACPI_FADT_PSCI_COMPLIANT    (1)	/* 00: [V5+] PSCI 0.2+ is
> > implemented */
> > 
> > So does it need to be consistent with Linux or support PSCI 0.1 in Xen
> > as well?
> 
> I don't think it needs to be consistent with Linux. I would support PSCI
> 0.1 too.

That's not possible, so I don't follow. Prior to 0.2 the function IDs
are not defined.

The FADT has a single bit which describes PSCI 0.2+ being implemented,
and does not describe function IDs.

You must assume PSCI 0.2+ in order to have a set of function IDs to use.

You should also assume the presence of the rest of the mandatory
portions of PSCI 0.2, as these are also required per the combination of
the PSCI spec and the ACPI spec.

Mark.

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

* Re: [PATCH v3 20/62] arm/acpi: Add ACPI support for SMP initialization
  2016-01-04 14:51       ` [Xen-devel] " Stefano Stabellini
  2016-01-04 15:00         ` Mark Rutland
@ 2016-01-04 15:00         ` Mark Rutland
  1 sibling, 0 replies; 426+ messages in thread
From: Mark Rutland @ 2016-01-04 15:00 UTC (permalink / raw)
  To: Stefano Stabellini
  Cc: hangaohuai, ian.campbell, andrew.cooper3, peter.huangpeng,
	xen-devel, Julien Grall, stefano.stabellini, shannon.zhao,
	Shannon Zhao, linux-arm-kernel

On Mon, Jan 04, 2016 at 02:51:51PM +0000, Stefano Stabellini wrote:
> On Wed, 30 Dec 2015, Shannon Zhao wrote:
> > On 2015/11/30 22:57, Julien Grall wrote:
> > > Hi Shannon,
> > > 
> > > On 17/11/15 09:40, shannon.zhao@linaro.org wrote:
> > >> > diff --git a/xen/arch/arm/psci.c b/xen/arch/arm/psci.c
> > >> > index d800cb6..dede0e1 100644
> > >> > --- a/xen/arch/arm/psci.c
> > >> > +++ b/xen/arch/arm/psci.c
> > >> > @@ -22,6 +22,7 @@
> > >> >  #include <xen/mm.h>
> > >> >  #include <xen/smp.h>
> > >> >  #include <asm/psci.h>
> > >> > +#include <asm/acpi.h>
> > >> >  
> > >> >  /*
> > >> >   * While a 64-bit OS can make calls with SMC32 calling conventions, for
> > >> > @@ -86,6 +87,9 @@ int __init psci_init_0_1(void)
> > >> >      int ret;
> > >> >      const struct dt_device_node *psci;
> > >> >  
> > >> > +    if ( !acpi_disabled )
> > >> > +        return -EINVAL;
> > > Please explain in the commit message why PSCI 0.1 is not supported on ACPI.
> > 
> > Hi,
> > 
> > I check this again. There are not limitations of supporting PSCI version
> > in ACPI SPEC. It should support PSCI 0.1 as well. But look at the code
> > of linux kernel, it says it only supports PSCI 0.2+.
> > 
> > #define ACPI_FADT_PSCI_COMPLIANT    (1)	/* 00: [V5+] PSCI 0.2+ is
> > implemented */
> > 
> > So does it need to be consistent with Linux or support PSCI 0.1 in Xen
> > as well?
> 
> I don't think it needs to be consistent with Linux. I would support PSCI
> 0.1 too.

That's not possible, so I don't follow. Prior to 0.2 the function IDs
are not defined.

The FADT has a single bit which describes PSCI 0.2+ being implemented,
and does not describe function IDs.

You must assume PSCI 0.2+ in order to have a set of function IDs to use.

You should also assume the presence of the rest of the mandatory
portions of PSCI 0.2, as these are also required per the combination of
the PSCI spec and the ACPI spec.

Mark.

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

* [Xen-devel] [PATCH v3 20/62] arm/acpi: Add ACPI support for SMP initialization
  2015-12-30  3:11     ` Shannon Zhao
  2016-01-04 14:51       ` Stefano Stabellini
  2016-01-04 14:51       ` [Xen-devel] " Stefano Stabellini
@ 2016-01-04 15:12       ` Mark Rutland
  2016-01-04 15:12       ` Mark Rutland
  3 siblings, 0 replies; 426+ messages in thread
From: Mark Rutland @ 2016-01-04 15:12 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Dec 30, 2015 at 11:11:08AM +0800, Shannon Zhao wrote:
> 
> 
> On 2015/11/30 22:57, Julien Grall wrote:
> > Hi Shannon,
> > 
> > On 17/11/15 09:40, shannon.zhao at linaro.org wrote:
> >> > diff --git a/xen/arch/arm/psci.c b/xen/arch/arm/psci.c
> >> > index d800cb6..dede0e1 100644
> >> > --- a/xen/arch/arm/psci.c
> >> > +++ b/xen/arch/arm/psci.c
> >> > @@ -22,6 +22,7 @@
> >> >  #include <xen/mm.h>
> >> >  #include <xen/smp.h>
> >> >  #include <asm/psci.h>
> >> > +#include <asm/acpi.h>
> >> >  
> >> >  /*
> >> >   * While a 64-bit OS can make calls with SMC32 calling conventions, for
> >> > @@ -86,6 +87,9 @@ int __init psci_init_0_1(void)
> >> >      int ret;
> >> >      const struct dt_device_node *psci;
> >> >  
> >> > +    if ( !acpi_disabled )
> >> > +        return -EINVAL;
> > Please explain in the commit message why PSCI 0.1 is not supported on ACPI.
> 
> Hi,
> 
> I check this again. There are not limitations of supporting PSCI version
> in ACPI SPEC. It should support PSCI 0.1 as well.

I believe that's an oversight in the ACPI documentation, which should
state 0.2+.

There was a deliberate decision that the FADT PSCI flag implied PSCI
0.2+, since prior to PSCI 0.2 function IDs were not well-defined, and
functions crticial for some uses cases did not exist (e.g. AFFINITY_INFO
for kexec-type things).

I don't know why that did not make it into the documentation.

Charles, thoughts?

Mark.

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

* Re: [PATCH v3 20/62] arm/acpi: Add ACPI support for SMP initialization
  2015-12-30  3:11     ` Shannon Zhao
                         ` (2 preceding siblings ...)
  2016-01-04 15:12       ` [Xen-devel] " Mark Rutland
@ 2016-01-04 15:12       ` Mark Rutland
  3 siblings, 0 replies; 426+ messages in thread
From: Mark Rutland @ 2016-01-04 15:12 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: hangaohuai, ian.campbell, andrew.cooper3, peter.huangpeng,
	xen-devel, Julien Grall, stefano.stabellini, shannon.zhao,
	linux-arm-kernel, charles.garcia-tobin

On Wed, Dec 30, 2015 at 11:11:08AM +0800, Shannon Zhao wrote:
> 
> 
> On 2015/11/30 22:57, Julien Grall wrote:
> > Hi Shannon,
> > 
> > On 17/11/15 09:40, shannon.zhao@linaro.org wrote:
> >> > diff --git a/xen/arch/arm/psci.c b/xen/arch/arm/psci.c
> >> > index d800cb6..dede0e1 100644
> >> > --- a/xen/arch/arm/psci.c
> >> > +++ b/xen/arch/arm/psci.c
> >> > @@ -22,6 +22,7 @@
> >> >  #include <xen/mm.h>
> >> >  #include <xen/smp.h>
> >> >  #include <asm/psci.h>
> >> > +#include <asm/acpi.h>
> >> >  
> >> >  /*
> >> >   * While a 64-bit OS can make calls with SMC32 calling conventions, for
> >> > @@ -86,6 +87,9 @@ int __init psci_init_0_1(void)
> >> >      int ret;
> >> >      const struct dt_device_node *psci;
> >> >  
> >> > +    if ( !acpi_disabled )
> >> > +        return -EINVAL;
> > Please explain in the commit message why PSCI 0.1 is not supported on ACPI.
> 
> Hi,
> 
> I check this again. There are not limitations of supporting PSCI version
> in ACPI SPEC. It should support PSCI 0.1 as well.

I believe that's an oversight in the ACPI documentation, which should
state 0.2+.

There was a deliberate decision that the FADT PSCI flag implied PSCI
0.2+, since prior to PSCI 0.2 function IDs were not well-defined, and
functions crticial for some uses cases did not exist (e.g. AFFINITY_INFO
for kexec-type things).

I don't know why that did not make it into the documentation.

Charles, thoughts?

Mark.

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

* [Xen-devel] [PATCH v3 20/62] arm/acpi: Add ACPI support for SMP initialization
  2016-01-04 15:00         ` Mark Rutland
@ 2016-01-04 15:14           ` Mark Rutland
  2016-01-04 15:14           ` Mark Rutland
  1 sibling, 0 replies; 426+ messages in thread
From: Mark Rutland @ 2016-01-04 15:14 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Jan 04, 2016 at 03:00:45PM +0000, Mark Rutland wrote:
> On Mon, Jan 04, 2016 at 02:51:51PM +0000, Stefano Stabellini wrote:
> > On Wed, 30 Dec 2015, Shannon Zhao wrote:
> > > I check this again. There are not limitations of supporting PSCI version
> > > in ACPI SPEC. It should support PSCI 0.1 as well. But look at the code
> > > of linux kernel, it says it only supports PSCI 0.2+.
> > > 
> > > #define ACPI_FADT_PSCI_COMPLIANT    (1)	/* 00: [V5+] PSCI 0.2+ is
> > > implemented */
> > > 
> > > So does it need to be consistent with Linux or support PSCI 0.1 in Xen
> > > as well?
> > 
> > I don't think it needs to be consistent with Linux. I would support PSCI
> > 0.1 too.
> 
> That's not possible, so I don't follow. Prior to 0.2 the function IDs
> are not defined.
> 
> The FADT has a single bit which describes PSCI 0.2+ being implemented,
> and does not describe function IDs.

I've now spotted that this wording is indeed missing from the ACPI
documentation. I believe this is a documentation bug, as the intent was
always for the bit to imply PSCI 0.2+.

Mark.

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

* Re: [PATCH v3 20/62] arm/acpi: Add ACPI support for SMP initialization
  2016-01-04 15:00         ` Mark Rutland
  2016-01-04 15:14           ` Mark Rutland
@ 2016-01-04 15:14           ` Mark Rutland
  1 sibling, 0 replies; 426+ messages in thread
From: Mark Rutland @ 2016-01-04 15:14 UTC (permalink / raw)
  To: Stefano Stabellini
  Cc: hangaohuai, ian.campbell, andrew.cooper3, peter.huangpeng,
	xen-devel, Julien Grall, stefano.stabellini, shannon.zhao,
	Shannon Zhao, linux-arm-kernel

On Mon, Jan 04, 2016 at 03:00:45PM +0000, Mark Rutland wrote:
> On Mon, Jan 04, 2016 at 02:51:51PM +0000, Stefano Stabellini wrote:
> > On Wed, 30 Dec 2015, Shannon Zhao wrote:
> > > I check this again. There are not limitations of supporting PSCI version
> > > in ACPI SPEC. It should support PSCI 0.1 as well. But look at the code
> > > of linux kernel, it says it only supports PSCI 0.2+.
> > > 
> > > #define ACPI_FADT_PSCI_COMPLIANT    (1)	/* 00: [V5+] PSCI 0.2+ is
> > > implemented */
> > > 
> > > So does it need to be consistent with Linux or support PSCI 0.1 in Xen
> > > as well?
> > 
> > I don't think it needs to be consistent with Linux. I would support PSCI
> > 0.1 too.
> 
> That's not possible, so I don't follow. Prior to 0.2 the function IDs
> are not defined.
> 
> The FADT has a single bit which describes PSCI 0.2+ being implemented,
> and does not describe function IDs.

I've now spotted that this wording is indeed missing from the ACPI
documentation. I believe this is a documentation bug, as the intent was
always for the bit to imply PSCI 0.2+.

Mark.

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

* [PATCH v3 47/62] arm/p2m: Add helper functions to map memory regions
  2015-11-30 15:22     ` Julien Grall
@ 2016-01-05  3:50       ` Shannon Zhao
  2016-01-05  3:50       ` Shannon Zhao
  1 sibling, 0 replies; 426+ messages in thread
From: Shannon Zhao @ 2016-01-05  3:50 UTC (permalink / raw)
  To: linux-arm-kernel



On 2015/11/30 23:22, Julien Grall wrote:
> Hi,
> 
> On 27/11/15 12:04, Stefano Stabellini wrote:
>> > On Tue, 17 Nov 2015, shannon.zhao at linaro.org wrote:
>>> >> From: Parth Dixit <parth.dixit@linaro.org>
>>> >>
>>> >> Create a helper function for mapping with cached attributes.
>>> >>
>>> >> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
>>> >> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> > 
>> > You might be able to use the existing guest_physmap_add_entry and
>> > guest_physmap_remove_page for your purposes.
> I would rather avoid to do that, those function use the type p2m_ram_rw
> which imply the memory is executable.

It could pass the type p2m_mmio_direct or p2m_ram_ro to
guest_physmap_add_entry, right?

Thanks,
-- 
Shannon

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

* Re: [PATCH v3 47/62] arm/p2m: Add helper functions to map memory regions
  2015-11-30 15:22     ` Julien Grall
  2016-01-05  3:50       ` Shannon Zhao
@ 2016-01-05  3:50       ` Shannon Zhao
  1 sibling, 0 replies; 426+ messages in thread
From: Shannon Zhao @ 2016-01-05  3:50 UTC (permalink / raw)
  To: Julien Grall, Stefano Stabellini, shannon.zhao
  Cc: mark.rutland, hangaohuai, david.vrabel, keir, ian.campbell,
	ard.biesheuvel, andrew.cooper3, peter.huangpeng, xen-devel,
	stefano.stabellini, christoffer.dall, jbeulich, linux-arm-kernel,
	roger.pau



On 2015/11/30 23:22, Julien Grall wrote:
> Hi,
> 
> On 27/11/15 12:04, Stefano Stabellini wrote:
>> > On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:
>>> >> From: Parth Dixit <parth.dixit@linaro.org>
>>> >>
>>> >> Create a helper function for mapping with cached attributes.
>>> >>
>>> >> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
>>> >> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> > 
>> > You might be able to use the existing guest_physmap_add_entry and
>> > guest_physmap_remove_page for your purposes.
> I would rather avoid to do that, those function use the type p2m_ram_rw
> which imply the memory is executable.

It could pass the type p2m_mmio_direct or p2m_ram_ro to
guest_physmap_add_entry, right?

Thanks,
-- 
Shannon

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

* [Xen-devel] [PATCH v3 60/62] arm/acpi: Configure interrupts dynamically
  2015-11-30 15:42     ` Julien Grall
  (?)
  (?)
@ 2016-01-05 11:51     ` Shannon Zhao
  2016-01-05 14:18       ` Stefano Stabellini
  2016-01-05 14:18       ` [Xen-devel] " Stefano Stabellini
  -1 siblings, 2 replies; 426+ messages in thread
From: Shannon Zhao @ 2016-01-05 11:51 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

On 2015/11/30 23:42, Julien Grall wrote:
> Hi Shannon,
> 
> On 17/11/15 09:40, shannon.zhao at linaro.org wrote:
>> From: Parth Dixit <parth.dixit@linaro.org>
>>
>> Interrupt information is described in DSDT and is not available at
>> the time of booting. Configure the interrupts dynamically when requested
>> by Dom0
> 
> Missing ".".
> 
> As said on a previous version of this patch [1], I'd like to keep the
> ACPI changes very contained to Xen boot. Your change is not ACPI
> specific and could be used for DT.
> 
>>
>> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> ---
>>  xen/arch/arm/vgic.c | 19 +++++++++++++++++++
>>  1 file changed, 19 insertions(+)
>>
>> diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c
>> index 7bb4570..d05abde 100644
>> --- a/xen/arch/arm/vgic.c
>> +++ b/xen/arch/arm/vgic.c
>> @@ -25,6 +25,7 @@
>>  #include <xen/irq.h>
>>  #include <xen/sched.h>
>>  #include <xen/perfc.h>
>> +#include <xen/acpi.h>
>>  
>>  #include <asm/current.h>
>>  
>> @@ -310,6 +311,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)
>>  {
>>      struct domain *d = v->domain;
>> @@ -321,7 +324,23 @@ void vgic_enable_irqs(struct vcpu *v, uint32_t r, int n)
>>      struct vcpu *v_target;
>>  
>>      while ( (i = find_next_bit(&mask, 32, i)) < 32 ) {
>> +#ifdef CONFIG_ACPI
>> +        struct vgic_irq_rank *vr = vgic_get_rank(v, n);
>> +        uint32_t tr;
>> +
>>          irq = i + (32 * n);
>> +        if( ( !acpi_disabled ) && ( n != 0 ) && is_hardware_domain(d) )
> 
> You need to add a comment explaining the ( n != 0 ) i.e we don't SGIs
> and PPIs are RO. It's implementation defined for PPI but it's preferable
> to let Xen take care of it.
> 
> Also, we should set the type only for IRQ assigned to DOM0 (i.e p->desc
> != NULL). With your current solution, DOM0 may change the configuration
> of the serial IRQ by mistake and take down Xen because the physical IRQ
> is enabled and the behavior will be unpredictable.
> 
>> +        {
>> +            tr = vr->icfg[i >> 4] ;
>> +
>> +            if( ( tr & VGIC_ICFG_MASK(i) ) )
>> +                irq_set_type(irq, ACPI_IRQ_TYPE_EDGE_BOTH);
>> +            else
>> +                irq_set_type(irq, ACPI_IRQ_TYPE_LEVEL_MASK);
> 
> Given that only SPI can be configured it would have been better to call
> irq_set_type.
> 
> Although, those 2 functions don't do what you think. They are setting
> the type internally in Xen but don't change the GIC interrupt
> configuration register.
> 
Here it wants to set the type according to the value of GIC ICFG.

I don't know this well. Does it need to set the type here when Dom0
configures the interrupts since I have set them as ACPI_IRQ_TYPE_NONE in
patch 55?

How about following way?
1) In patch 55, it only permit the access of Dom0 to those irqs, not set
the type.
2) Then in this function or in the handler of writing GIC ICFG, check if
the irq is permitted and set the irq type.

> Lastly, they will fail because the configuration has been set earlier
> (as you did in patch #55)
> 
>> +        }
>> +#else
>> +        irq = i + (32 * n);
>> +#endif
>>          v_target = d->arch.vgic.handler->get_target_vcpu(v, irq);
>>          p = irq_to_pending(v_target, irq);
>>          set_bit(GIC_IRQ_GUEST_ENABLED, &p->status);
>>
> 
> Regards,
> 
> [1] http://lists.xen.org/archives/html/xen-devel/2015-06/msg01128.html
> 

-- 
Shannon

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

* Re: [PATCH v3 60/62] arm/acpi: Configure interrupts dynamically
  2015-11-30 15:42     ` Julien Grall
  (?)
@ 2016-01-05 11:51     ` Shannon Zhao
  -1 siblings, 0 replies; 426+ messages in thread
From: Shannon Zhao @ 2016-01-05 11:51 UTC (permalink / raw)
  To: Julien Grall, shannon.zhao, ian.campbell, stefano.stabellini, xen-devel
  Cc: hangaohuai, peter.huangpeng, linux-arm-kernel

Hi,

On 2015/11/30 23:42, Julien Grall wrote:
> Hi Shannon,
> 
> On 17/11/15 09:40, shannon.zhao@linaro.org wrote:
>> From: Parth Dixit <parth.dixit@linaro.org>
>>
>> Interrupt information is described in DSDT and is not available at
>> the time of booting. Configure the interrupts dynamically when requested
>> by Dom0
> 
> Missing ".".
> 
> As said on a previous version of this patch [1], I'd like to keep the
> ACPI changes very contained to Xen boot. Your change is not ACPI
> specific and could be used for DT.
> 
>>
>> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> ---
>>  xen/arch/arm/vgic.c | 19 +++++++++++++++++++
>>  1 file changed, 19 insertions(+)
>>
>> diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c
>> index 7bb4570..d05abde 100644
>> --- a/xen/arch/arm/vgic.c
>> +++ b/xen/arch/arm/vgic.c
>> @@ -25,6 +25,7 @@
>>  #include <xen/irq.h>
>>  #include <xen/sched.h>
>>  #include <xen/perfc.h>
>> +#include <xen/acpi.h>
>>  
>>  #include <asm/current.h>
>>  
>> @@ -310,6 +311,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)
>>  {
>>      struct domain *d = v->domain;
>> @@ -321,7 +324,23 @@ void vgic_enable_irqs(struct vcpu *v, uint32_t r, int n)
>>      struct vcpu *v_target;
>>  
>>      while ( (i = find_next_bit(&mask, 32, i)) < 32 ) {
>> +#ifdef CONFIG_ACPI
>> +        struct vgic_irq_rank *vr = vgic_get_rank(v, n);
>> +        uint32_t tr;
>> +
>>          irq = i + (32 * n);
>> +        if( ( !acpi_disabled ) && ( n != 0 ) && is_hardware_domain(d) )
> 
> You need to add a comment explaining the ( n != 0 ) i.e we don't SGIs
> and PPIs are RO. It's implementation defined for PPI but it's preferable
> to let Xen take care of it.
> 
> Also, we should set the type only for IRQ assigned to DOM0 (i.e p->desc
> != NULL). With your current solution, DOM0 may change the configuration
> of the serial IRQ by mistake and take down Xen because the physical IRQ
> is enabled and the behavior will be unpredictable.
> 
>> +        {
>> +            tr = vr->icfg[i >> 4] ;
>> +
>> +            if( ( tr & VGIC_ICFG_MASK(i) ) )
>> +                irq_set_type(irq, ACPI_IRQ_TYPE_EDGE_BOTH);
>> +            else
>> +                irq_set_type(irq, ACPI_IRQ_TYPE_LEVEL_MASK);
> 
> Given that only SPI can be configured it would have been better to call
> irq_set_type.
> 
> Although, those 2 functions don't do what you think. They are setting
> the type internally in Xen but don't change the GIC interrupt
> configuration register.
> 
Here it wants to set the type according to the value of GIC ICFG.

I don't know this well. Does it need to set the type here when Dom0
configures the interrupts since I have set them as ACPI_IRQ_TYPE_NONE in
patch 55?

How about following way?
1) In patch 55, it only permit the access of Dom0 to those irqs, not set
the type.
2) Then in this function or in the handler of writing GIC ICFG, check if
the irq is permitted and set the irq type.

> Lastly, they will fail because the configuration has been set earlier
> (as you did in patch #55)
> 
>> +        }
>> +#else
>> +        irq = i + (32 * n);
>> +#endif
>>          v_target = d->arch.vgic.handler->get_target_vcpu(v, irq);
>>          p = irq_to_pending(v_target, irq);
>>          set_bit(GIC_IRQ_GUEST_ENABLED, &p->status);
>>
> 
> Regards,
> 
> [1] http://lists.xen.org/archives/html/xen-devel/2015-06/msg01128.html
> 

-- 
Shannon

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

* [Xen-devel] [PATCH v3 60/62] arm/acpi: Configure interrupts dynamically
  2016-01-05 11:51     ` [Xen-devel] " Shannon Zhao
  2016-01-05 14:18       ` Stefano Stabellini
@ 2016-01-05 14:18       ` Stefano Stabellini
  1 sibling, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2016-01-05 14:18 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 5 Jan 2016, Shannon Zhao wrote:
> Hi,
> 
> On 2015/11/30 23:42, Julien Grall wrote:
> > Hi Shannon,
> > 
> > On 17/11/15 09:40, shannon.zhao at linaro.org wrote:
> >> From: Parth Dixit <parth.dixit@linaro.org>
> >>
> >> Interrupt information is described in DSDT and is not available at
> >> the time of booting. Configure the interrupts dynamically when requested
> >> by Dom0
> > 
> > Missing ".".
> > 
> > As said on a previous version of this patch [1], I'd like to keep the
> > ACPI changes very contained to Xen boot. Your change is not ACPI
> > specific and could be used for DT.
> > 
> >>
> >> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> >> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> >> ---
> >>  xen/arch/arm/vgic.c | 19 +++++++++++++++++++
> >>  1 file changed, 19 insertions(+)
> >>
> >> diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c
> >> index 7bb4570..d05abde 100644
> >> --- a/xen/arch/arm/vgic.c
> >> +++ b/xen/arch/arm/vgic.c
> >> @@ -25,6 +25,7 @@
> >>  #include <xen/irq.h>
> >>  #include <xen/sched.h>
> >>  #include <xen/perfc.h>
> >> +#include <xen/acpi.h>
> >>  
> >>  #include <asm/current.h>
> >>  
> >> @@ -310,6 +311,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)
> >>  {
> >>      struct domain *d = v->domain;
> >> @@ -321,7 +324,23 @@ void vgic_enable_irqs(struct vcpu *v, uint32_t r, int n)
> >>      struct vcpu *v_target;
> >>  
> >>      while ( (i = find_next_bit(&mask, 32, i)) < 32 ) {
> >> +#ifdef CONFIG_ACPI
> >> +        struct vgic_irq_rank *vr = vgic_get_rank(v, n);
> >> +        uint32_t tr;
> >> +
> >>          irq = i + (32 * n);
> >> +        if( ( !acpi_disabled ) && ( n != 0 ) && is_hardware_domain(d) )
> > 
> > You need to add a comment explaining the ( n != 0 ) i.e we don't SGIs
> > and PPIs are RO. It's implementation defined for PPI but it's preferable
> > to let Xen take care of it.
> > 
> > Also, we should set the type only for IRQ assigned to DOM0 (i.e p->desc
> > != NULL). With your current solution, DOM0 may change the configuration
> > of the serial IRQ by mistake and take down Xen because the physical IRQ
> > is enabled and the behavior will be unpredictable.
> > 
> >> +        {
> >> +            tr = vr->icfg[i >> 4] ;
> >> +
> >> +            if( ( tr & VGIC_ICFG_MASK(i) ) )
> >> +                irq_set_type(irq, ACPI_IRQ_TYPE_EDGE_BOTH);
> >> +            else
> >> +                irq_set_type(irq, ACPI_IRQ_TYPE_LEVEL_MASK);
> > 
> > Given that only SPI can be configured it would have been better to call
> > irq_set_type.
> > 
> > Although, those 2 functions don't do what you think. They are setting
> > the type internally in Xen but don't change the GIC interrupt
> > configuration register.
> > 
> Here it wants to set the type according to the value of GIC ICFG.
> 
> I don't know this well. Does it need to set the type here when Dom0
> configures the interrupts since I have set them as ACPI_IRQ_TYPE_NONE in
> patch 55?
> 
> How about following way?
> 1) In patch 55, it only permit the access of Dom0 to those irqs, not set
> the type.
> 2) Then in this function or in the handler of writing GIC ICFG, check if
> the irq is permitted and set the irq type.

Sounds good


> > Lastly, they will fail because the configuration has been set earlier
> > (as you did in patch #55)
> > 
> >> +        }
> >> +#else
> >> +        irq = i + (32 * n);
> >> +#endif
> >>          v_target = d->arch.vgic.handler->get_target_vcpu(v, irq);
> >>          p = irq_to_pending(v_target, irq);
> >>          set_bit(GIC_IRQ_GUEST_ENABLED, &p->status);
> >>
> > 
> > Regards,
> > 
> > [1] http://lists.xen.org/archives/html/xen-devel/2015-06/msg01128.html
> > 
> 
> -- 
> Shannon
> 

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

* Re: [PATCH v3 60/62] arm/acpi: Configure interrupts dynamically
  2016-01-05 11:51     ` [Xen-devel] " Shannon Zhao
@ 2016-01-05 14:18       ` Stefano Stabellini
  2016-01-05 14:18       ` [Xen-devel] " Stefano Stabellini
  1 sibling, 0 replies; 426+ messages in thread
From: Stefano Stabellini @ 2016-01-05 14:18 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: hangaohuai, ian.campbell, peter.huangpeng, xen-devel,
	Julien Grall, stefano.stabellini, shannon.zhao, linux-arm-kernel

On Tue, 5 Jan 2016, Shannon Zhao wrote:
> Hi,
> 
> On 2015/11/30 23:42, Julien Grall wrote:
> > Hi Shannon,
> > 
> > On 17/11/15 09:40, shannon.zhao@linaro.org wrote:
> >> From: Parth Dixit <parth.dixit@linaro.org>
> >>
> >> Interrupt information is described in DSDT and is not available at
> >> the time of booting. Configure the interrupts dynamically when requested
> >> by Dom0
> > 
> > Missing ".".
> > 
> > As said on a previous version of this patch [1], I'd like to keep the
> > ACPI changes very contained to Xen boot. Your change is not ACPI
> > specific and could be used for DT.
> > 
> >>
> >> Signed-off-by: Parth Dixit <parth.dixit@linaro.org>
> >> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> >> ---
> >>  xen/arch/arm/vgic.c | 19 +++++++++++++++++++
> >>  1 file changed, 19 insertions(+)
> >>
> >> diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c
> >> index 7bb4570..d05abde 100644
> >> --- a/xen/arch/arm/vgic.c
> >> +++ b/xen/arch/arm/vgic.c
> >> @@ -25,6 +25,7 @@
> >>  #include <xen/irq.h>
> >>  #include <xen/sched.h>
> >>  #include <xen/perfc.h>
> >> +#include <xen/acpi.h>
> >>  
> >>  #include <asm/current.h>
> >>  
> >> @@ -310,6 +311,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)
> >>  {
> >>      struct domain *d = v->domain;
> >> @@ -321,7 +324,23 @@ void vgic_enable_irqs(struct vcpu *v, uint32_t r, int n)
> >>      struct vcpu *v_target;
> >>  
> >>      while ( (i = find_next_bit(&mask, 32, i)) < 32 ) {
> >> +#ifdef CONFIG_ACPI
> >> +        struct vgic_irq_rank *vr = vgic_get_rank(v, n);
> >> +        uint32_t tr;
> >> +
> >>          irq = i + (32 * n);
> >> +        if( ( !acpi_disabled ) && ( n != 0 ) && is_hardware_domain(d) )
> > 
> > You need to add a comment explaining the ( n != 0 ) i.e we don't SGIs
> > and PPIs are RO. It's implementation defined for PPI but it's preferable
> > to let Xen take care of it.
> > 
> > Also, we should set the type only for IRQ assigned to DOM0 (i.e p->desc
> > != NULL). With your current solution, DOM0 may change the configuration
> > of the serial IRQ by mistake and take down Xen because the physical IRQ
> > is enabled and the behavior will be unpredictable.
> > 
> >> +        {
> >> +            tr = vr->icfg[i >> 4] ;
> >> +
> >> +            if( ( tr & VGIC_ICFG_MASK(i) ) )
> >> +                irq_set_type(irq, ACPI_IRQ_TYPE_EDGE_BOTH);
> >> +            else
> >> +                irq_set_type(irq, ACPI_IRQ_TYPE_LEVEL_MASK);
> > 
> > Given that only SPI can be configured it would have been better to call
> > irq_set_type.
> > 
> > Although, those 2 functions don't do what you think. They are setting
> > the type internally in Xen but don't change the GIC interrupt
> > configuration register.
> > 
> Here it wants to set the type according to the value of GIC ICFG.
> 
> I don't know this well. Does it need to set the type here when Dom0
> configures the interrupts since I have set them as ACPI_IRQ_TYPE_NONE in
> patch 55?
> 
> How about following way?
> 1) In patch 55, it only permit the access of Dom0 to those irqs, not set
> the type.
> 2) Then in this function or in the handler of writing GIC ICFG, check if
> the irq is permitted and set the irq type.

Sounds good


> > Lastly, they will fail because the configuration has been set earlier
> > (as you did in patch #55)
> > 
> >> +        }
> >> +#else
> >> +        irq = i + (32 * n);
> >> +#endif
> >>          v_target = d->arch.vgic.handler->get_target_vcpu(v, irq);
> >>          p = irq_to_pending(v_target, irq);
> >>          set_bit(GIC_IRQ_GUEST_ENABLED, &p->status);
> >>
> > 
> > Regards,
> > 
> > [1] http://lists.xen.org/archives/html/xen-devel/2015-06/msg01128.html
> > 
> 
> -- 
> Shannon
> 

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

* [PATCH v3 59/62] xen/arm: Add a hypercall for device mmio mapping
  2015-11-17 11:04   ` Jan Beulich
@ 2016-01-07  6:58       ` Shannon Zhao
  0 siblings, 0 replies; 426+ messages in thread
From: Shannon Zhao @ 2016-01-07  6:58 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Jan,

On 2015/11/17 19:04, Jan Beulich wrote:
>>>> On 17.11.15 at 10:40, <shannon.zhao@linaro.org> wrote:
>> > --- 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;
> Blindly for any kind of domain? The XSM check in the
> XENMEM_add_to_physmap_batch handler (in common code) doesn't
> even know which map space is to be used...

Sorry, I know little about XSM. Could you suggest me how to add the
check for this new type here?

Thanks,
-- 
Shannon

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

* Re: [PATCH v3 59/62] xen/arm: Add a hypercall for device mmio mapping
@ 2016-01-07  6:58       ` Shannon Zhao
  0 siblings, 0 replies; 426+ messages in thread
From: Shannon Zhao @ 2016-01-07  6:58 UTC (permalink / raw)
  To: Jan Beulich, shannon.zhao
  Cc: ian.campbell, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, linux-arm-kernel

Hi Jan,

On 2015/11/17 19:04, Jan Beulich wrote:
>>>> On 17.11.15 at 10:40, <shannon.zhao@linaro.org> wrote:
>> > --- 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;
> Blindly for any kind of domain? The XSM check in the
> XENMEM_add_to_physmap_batch handler (in common code) doesn't
> even know which map space is to be used...

Sorry, I know little about XSM. Could you suggest me how to add the
check for this new type here?

Thanks,
-- 
Shannon

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

* [PATCH v3 59/62] xen/arm: Add a hypercall for device mmio mapping
  2016-01-07  6:58       ` Shannon Zhao
  (?)
@ 2016-01-07  7:45       ` Jan Beulich
  2016-01-07  9:11         ` Shannon Zhao
  2016-01-07  9:11         ` Shannon Zhao
  -1 siblings, 2 replies; 426+ messages in thread
From: Jan Beulich @ 2016-01-07  7:45 UTC (permalink / raw)
  To: linux-arm-kernel

>>> On 07.01.16 at 07:58, <zhaoshenglong@huawei.com> wrote:
> On 2015/11/17 19:04, Jan Beulich wrote:
>>>>> On 17.11.15 at 10:40, <shannon.zhao@linaro.org> wrote:
>>> > --- 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;
>> Blindly for any kind of domain? The XSM check in the
>> XENMEM_add_to_physmap_batch handler (in common code) doesn't
>> even know which map space is to be used...
> 
> Sorry, I know little about XSM. Could you suggest me how to add the
> check for this new type here?

I'm sorry to push back here, but did you at least try to derive
what is wanted from the multitude of other XSM checks present
throughout the tree?

Jan

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

* Re: [PATCH v3 59/62] xen/arm: Add a hypercall for device mmio mapping
  2016-01-07  6:58       ` Shannon Zhao
  (?)
  (?)
@ 2016-01-07  7:45       ` Jan Beulich
  -1 siblings, 0 replies; 426+ messages in thread
From: Jan Beulich @ 2016-01-07  7:45 UTC (permalink / raw)
  To: Shannon Zhao, shannon.zhao
  Cc: ian.campbell, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, linux-arm-kernel

>>> On 07.01.16 at 07:58, <zhaoshenglong@huawei.com> wrote:
> On 2015/11/17 19:04, Jan Beulich wrote:
>>>>> On 17.11.15 at 10:40, <shannon.zhao@linaro.org> wrote:
>>> > --- 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;
>> Blindly for any kind of domain? The XSM check in the
>> XENMEM_add_to_physmap_batch handler (in common code) doesn't
>> even know which map space is to be used...
> 
> Sorry, I know little about XSM. Could you suggest me how to add the
> check for this new type here?

I'm sorry to push back here, but did you at least try to derive
what is wanted from the multitude of other XSM checks present
throughout the tree?

Jan

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

* [PATCH v3 59/62] xen/arm: Add a hypercall for device mmio mapping
  2016-01-07  7:45       ` Jan Beulich
  2016-01-07  9:11         ` Shannon Zhao
@ 2016-01-07  9:11         ` Shannon Zhao
  2016-01-07 10:50           ` Jan Beulich
  2016-01-07 10:50           ` Jan Beulich
  1 sibling, 2 replies; 426+ messages in thread
From: Shannon Zhao @ 2016-01-07  9:11 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Jan,

On 2016/1/7 15:45, Jan Beulich wrote:
>>>> On 07.01.16 at 07:58, <zhaoshenglong@huawei.com> wrote:
>> > On 2015/11/17 19:04, Jan Beulich wrote:
>>>>>> >>>>> On 17.11.15 at 10:40, <shannon.zhao@linaro.org> wrote:
>>>>> >>> > --- 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;
>>> >> Blindly for any kind of domain? The XSM check in the
>>> >> XENMEM_add_to_physmap_batch handler (in common code) doesn't
>>> >> even know which map space is to be used...
>> > 
>> > Sorry, I know little about XSM. Could you suggest me how to add the
>> > check for this new type here?
> I'm sorry to push back here, but did you at least try to derive
> what is wanted from the multitude of other XSM checks present
> throughout the tree?

IIUC, you mean that it doean't need to change the XSM check itself, but
we should check if the current->domain is hardware domain and it maps
the space to itself before the XSM check, right?

If so, how about below patch on top of this patch?

diff --git a/xen/common/memory.c b/xen/common/memory.c
index 9ff1145..33feb2d 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;

+       /* Device MMIO mapping is only supported for Domain0 to map
these ranges
+        * 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;

+        /* Device MMIO mapping is only supported for Domain0 to map
these ranges
+         * 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 )
          {

Thanks,
-- 
Shannon

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

* Re: [PATCH v3 59/62] xen/arm: Add a hypercall for device mmio mapping
  2016-01-07  7:45       ` Jan Beulich
@ 2016-01-07  9:11         ` Shannon Zhao
  2016-01-07  9:11         ` Shannon Zhao
  1 sibling, 0 replies; 426+ messages in thread
From: Shannon Zhao @ 2016-01-07  9:11 UTC (permalink / raw)
  To: Jan Beulich, shannon.zhao
  Cc: ian.campbell, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, linux-arm-kernel

Hi Jan,

On 2016/1/7 15:45, Jan Beulich wrote:
>>>> On 07.01.16 at 07:58, <zhaoshenglong@huawei.com> wrote:
>> > On 2015/11/17 19:04, Jan Beulich wrote:
>>>>>> >>>>> On 17.11.15 at 10:40, <shannon.zhao@linaro.org> wrote:
>>>>> >>> > --- 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;
>>> >> Blindly for any kind of domain? The XSM check in the
>>> >> XENMEM_add_to_physmap_batch handler (in common code) doesn't
>>> >> even know which map space is to be used...
>> > 
>> > Sorry, I know little about XSM. Could you suggest me how to add the
>> > check for this new type here?
> I'm sorry to push back here, but did you at least try to derive
> what is wanted from the multitude of other XSM checks present
> throughout the tree?

IIUC, you mean that it doean't need to change the XSM check itself, but
we should check if the current->domain is hardware domain and it maps
the space to itself before the XSM check, right?

If so, how about below patch on top of this patch?

diff --git a/xen/common/memory.c b/xen/common/memory.c
index 9ff1145..33feb2d 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;

+       /* Device MMIO mapping is only supported for Domain0 to map
these ranges
+        * 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;

+        /* Device MMIO mapping is only supported for Domain0 to map
these ranges
+         * 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 )
          {

Thanks,
-- 
Shannon

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

* [PATCH v3 59/62] xen/arm: Add a hypercall for device mmio mapping
  2016-01-07  9:11         ` Shannon Zhao
@ 2016-01-07 10:50           ` Jan Beulich
  2016-01-07 21:40             ` Daniel De Graaf
  2016-01-07 21:40             ` Daniel De Graaf
  2016-01-07 10:50           ` Jan Beulich
  1 sibling, 2 replies; 426+ messages in thread
From: Jan Beulich @ 2016-01-07 10:50 UTC (permalink / raw)
  To: linux-arm-kernel

>>> On 07.01.16 at 10:11, <zhaoshenglong@huawei.com> wrote:
> Hi Jan,
> 
> On 2016/1/7 15:45, Jan Beulich wrote:
>>>>> On 07.01.16 at 07:58, <zhaoshenglong@huawei.com> wrote:
>>> > On 2015/11/17 19:04, Jan Beulich wrote:
>>>>>>> >>>>> On 17.11.15 at 10:40, <shannon.zhao@linaro.org> wrote:
>>>>>> >>> > --- 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;
>>>> >> Blindly for any kind of domain? The XSM check in the
>>>> >> XENMEM_add_to_physmap_batch handler (in common code) doesn't
>>>> >> even know which map space is to be used...
>>> > 
>>> > Sorry, I know little about XSM. Could you suggest me how to add the
>>> > check for this new type here?
>> I'm sorry to push back here, but did you at least try to derive
>> what is wanted from the multitude of other XSM checks present
>> throughout the tree?
> 
> IIUC, you mean that it doean't need to change the XSM check itself, but
> we should check if the current->domain is hardware domain and it maps
> the space to itself before the XSM check, right?

No, I actually think that you need to add a new, secondary XSM
check. But you may want to consult with Daniel (who so far wasn't
even Cc-ed).

Jan

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

* Re: [PATCH v3 59/62] xen/arm: Add a hypercall for device mmio mapping
  2016-01-07  9:11         ` Shannon Zhao
  2016-01-07 10:50           ` Jan Beulich
@ 2016-01-07 10:50           ` Jan Beulich
  1 sibling, 0 replies; 426+ messages in thread
From: Jan Beulich @ 2016-01-07 10:50 UTC (permalink / raw)
  To: Shannon Zhao, shannon.zhao
  Cc: ian.campbell, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, dgdegra, linux-arm-kernel

>>> On 07.01.16 at 10:11, <zhaoshenglong@huawei.com> wrote:
> Hi Jan,
> 
> On 2016/1/7 15:45, Jan Beulich wrote:
>>>>> On 07.01.16 at 07:58, <zhaoshenglong@huawei.com> wrote:
>>> > On 2015/11/17 19:04, Jan Beulich wrote:
>>>>>>> >>>>> On 17.11.15 at 10:40, <shannon.zhao@linaro.org> wrote:
>>>>>> >>> > --- 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;
>>>> >> Blindly for any kind of domain? The XSM check in the
>>>> >> XENMEM_add_to_physmap_batch handler (in common code) doesn't
>>>> >> even know which map space is to be used...
>>> > 
>>> > Sorry, I know little about XSM. Could you suggest me how to add the
>>> > check for this new type here?
>> I'm sorry to push back here, but did you at least try to derive
>> what is wanted from the multitude of other XSM checks present
>> throughout the tree?
> 
> IIUC, you mean that it doean't need to change the XSM check itself, but
> we should check if the current->domain is hardware domain and it maps
> the space to itself before the XSM check, right?

No, I actually think that you need to add a new, secondary XSM
check. But you may want to consult with Daniel (who so far wasn't
even Cc-ed).

Jan

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

* [PATCH v3 59/62] xen/arm: Add a hypercall for device mmio mapping
  2016-01-07 10:50           ` Jan Beulich
@ 2016-01-07 21:40             ` Daniel De Graaf
  2016-01-08  2:12               ` Shannon Zhao
  2016-01-08  2:12               ` Shannon Zhao
  2016-01-07 21:40             ` Daniel De Graaf
  1 sibling, 2 replies; 426+ messages in thread
From: Daniel De Graaf @ 2016-01-07 21:40 UTC (permalink / raw)
  To: linux-arm-kernel

On 01/07/2016 05:50 AM, Jan Beulich wrote:
>>>> On 07.01.16 at 10:11, <zhaoshenglong@huawei.com> wrote:
>> Hi Jan,
>>
>> On 2016/1/7 15:45, Jan Beulich wrote:
>>>>>> On 07.01.16 at 07:58, <zhaoshenglong@huawei.com> wrote:
>>>>> On 2015/11/17 19:04, Jan Beulich wrote:
>>>>>>>>>>>>> On 17.11.15 at 10:40, <shannon.zhao@linaro.org> wrote:
>>>>>>>>>>> --- 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;
>>>>>>> Blindly for any kind of domain? The XSM check in the
>>>>>>> XENMEM_add_to_physmap_batch handler (in common code) doesn't
>>>>>>> even know which map space is to be used...
>>>>>
>>>>> Sorry, I know little about XSM. Could you suggest me how to add the
>>>>> check for this new type here?
>>> I'm sorry to push back here, but did you at least try to derive
>>> what is wanted from the multitude of other XSM checks present
>>> throughout the tree?
>>
>> IIUC, you mean that it doean't need to change the XSM check itself, but
>> we should check if the current->domain is hardware domain and it maps
>> the space to itself before the XSM check, right?
>
> No, I actually think that you need to add a new, secondary XSM
> check. But you may want to consult with Daniel (who so far wasn't
> even Cc-ed).

Looking at the original patch, I am not sure if I understand the
checks: it seems like the iomem_access_permitted check is being done
on the guest's page range instead of the actual IO memory, which
ends up allowing the guest to map anything as long as it maps it in
the right guest area.  The iomem_permit_access call there also seems
to be redundant because it is the same range that was just checked.

If the [start_gfn, start_gfn + nr) memory range actually describes
the physical addresses, then this operation is taking advantage of
the existing XSM checks on XEN_DOMCTL_iomem_permission, and the
only XSM check that is needed would be that current->domain has
permission to modify (d)'s mappings - and this is done by the
xsm_add_to_physmap check in XENMEM_add_to_physmap.

-- 
Daniel De Graaf
National Security Agency

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

* Re: [PATCH v3 59/62] xen/arm: Add a hypercall for device mmio mapping
  2016-01-07 10:50           ` Jan Beulich
  2016-01-07 21:40             ` Daniel De Graaf
@ 2016-01-07 21:40             ` Daniel De Graaf
  1 sibling, 0 replies; 426+ messages in thread
From: Daniel De Graaf @ 2016-01-07 21:40 UTC (permalink / raw)
  To: Jan Beulich, Shannon Zhao, shannon.zhao
  Cc: ian.campbell, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, linux-arm-kernel

On 01/07/2016 05:50 AM, Jan Beulich wrote:
>>>> On 07.01.16 at 10:11, <zhaoshenglong@huawei.com> wrote:
>> Hi Jan,
>>
>> On 2016/1/7 15:45, Jan Beulich wrote:
>>>>>> On 07.01.16 at 07:58, <zhaoshenglong@huawei.com> wrote:
>>>>> On 2015/11/17 19:04, Jan Beulich wrote:
>>>>>>>>>>>>> On 17.11.15 at 10:40, <shannon.zhao@linaro.org> wrote:
>>>>>>>>>>> --- 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;
>>>>>>> Blindly for any kind of domain? The XSM check in the
>>>>>>> XENMEM_add_to_physmap_batch handler (in common code) doesn't
>>>>>>> even know which map space is to be used...
>>>>>
>>>>> Sorry, I know little about XSM. Could you suggest me how to add the
>>>>> check for this new type here?
>>> I'm sorry to push back here, but did you at least try to derive
>>> what is wanted from the multitude of other XSM checks present
>>> throughout the tree?
>>
>> IIUC, you mean that it doean't need to change the XSM check itself, but
>> we should check if the current->domain is hardware domain and it maps
>> the space to itself before the XSM check, right?
>
> No, I actually think that you need to add a new, secondary XSM
> check. But you may want to consult with Daniel (who so far wasn't
> even Cc-ed).

Looking at the original patch, I am not sure if I understand the
checks: it seems like the iomem_access_permitted check is being done
on the guest's page range instead of the actual IO memory, which
ends up allowing the guest to map anything as long as it maps it in
the right guest area.  The iomem_permit_access call there also seems
to be redundant because it is the same range that was just checked.

If the [start_gfn, start_gfn + nr) memory range actually describes
the physical addresses, then this operation is taking advantage of
the existing XSM checks on XEN_DOMCTL_iomem_permission, and the
only XSM check that is needed would be that current->domain has
permission to modify (d)'s mappings - and this is done by the
xsm_add_to_physmap check in XENMEM_add_to_physmap.

-- 
Daniel De Graaf
National Security Agency

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

* [PATCH v3 59/62] xen/arm: Add a hypercall for device mmio mapping
  2016-01-07 21:40             ` Daniel De Graaf
  2016-01-08  2:12               ` Shannon Zhao
@ 2016-01-08  2:12               ` Shannon Zhao
  1 sibling, 0 replies; 426+ messages in thread
From: Shannon Zhao @ 2016-01-08  2:12 UTC (permalink / raw)
  To: linux-arm-kernel



On 2016/1/8 5:40, Daniel De Graaf wrote:
> On 01/07/2016 05:50 AM, Jan Beulich wrote:
>>>>> On 07.01.16 at 10:11, <zhaoshenglong@huawei.com> wrote:
>>> Hi Jan,
>>>
>>> On 2016/1/7 15:45, Jan Beulich wrote:
>>>>>>> On 07.01.16 at 07:58, <zhaoshenglong@huawei.com> wrote:
>>>>>> On 2015/11/17 19:04, Jan Beulich wrote:
>>>>>>>>>>>>>> On 17.11.15 at 10:40, <shannon.zhao@linaro.org> wrote:
>>>>>>>>>>>> --- 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;
>>>>>>>> Blindly for any kind of domain? The XSM check in the
>>>>>>>> XENMEM_add_to_physmap_batch handler (in common code) doesn't
>>>>>>>> even know which map space is to be used...
>>>>>>
>>>>>> Sorry, I know little about XSM. Could you suggest me how to add the
>>>>>> check for this new type here?
>>>> I'm sorry to push back here, but did you at least try to derive
>>>> what is wanted from the multitude of other XSM checks present
>>>> throughout the tree?
>>>
>>> IIUC, you mean that it doean't need to change the XSM check itself, but
>>> we should check if the current->domain is hardware domain and it maps
>>> the space to itself before the XSM check, right?
>>
>> No, I actually think that you need to add a new, secondary XSM
>> check. But you may want to consult with Daniel (who so far wasn't
>> even Cc-ed).
> 
> Looking at the original patch, I am not sure if I understand the
> checks: it seems like the iomem_access_permitted check is being done
> on the guest's page range instead of the actual IO memory, which
> ends up allowing the guest to map anything as long as it maps it in
> the right guest area. 
Yeah, since it's hard to know the MMIO range from the DSDT in XEN, we
permit full mmio capabilities for Dom0 and deny mmio access for some
devices e.g. uart. Then when Dom0 add those devices, call
XENMEM_add_to_physmap to map their MMIO ranges. This looks similar with
what x86 does.

    /* The hardware domain is initially permitted full I/O capabilities. */
    rc |= ioports_permit_access(d, 0, 0xFFFF);
    rc |= iomem_permit_access(d, 0UL, ~0UL);
    rc |= irqs_permit_access(d, 1, nr_irqs_gsi - 1);

> The iomem_permit_access call there also seems
> to be redundant because it is the same range that was just checked.
>
Ah, I'll drop this at next version.

> If the [start_gfn, start_gfn + nr) memory range actually describes
> the physical addresses, then this operation is taking advantage of
> the existing XSM checks on XEN_DOMCTL_iomem_permission, and the
> only XSM check that is needed would be that current->domain has
> permission to modify (d)'s mappings - and this is done by the
> xsm_add_to_physmap check in XENMEM_add_to_physmap.

Thanks,
-- 
Shannon

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

* Re: [PATCH v3 59/62] xen/arm: Add a hypercall for device mmio mapping
  2016-01-07 21:40             ` Daniel De Graaf
@ 2016-01-08  2:12               ` Shannon Zhao
  2016-01-08  2:12               ` Shannon Zhao
  1 sibling, 0 replies; 426+ messages in thread
From: Shannon Zhao @ 2016-01-08  2:12 UTC (permalink / raw)
  To: Daniel De Graaf
  Cc: ian.campbell, peter.huangpeng, xen-devel, julien.grall,
	stefano.stabellini, shannon.zhao, Jan Beulich, linux-arm-kernel



On 2016/1/8 5:40, Daniel De Graaf wrote:
> On 01/07/2016 05:50 AM, Jan Beulich wrote:
>>>>> On 07.01.16 at 10:11, <zhaoshenglong@huawei.com> wrote:
>>> Hi Jan,
>>>
>>> On 2016/1/7 15:45, Jan Beulich wrote:
>>>>>>> On 07.01.16 at 07:58, <zhaoshenglong@huawei.com> wrote:
>>>>>> On 2015/11/17 19:04, Jan Beulich wrote:
>>>>>>>>>>>>>> On 17.11.15 at 10:40, <shannon.zhao@linaro.org> wrote:
>>>>>>>>>>>> --- 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;
>>>>>>>> Blindly for any kind of domain? The XSM check in the
>>>>>>>> XENMEM_add_to_physmap_batch handler (in common code) doesn't
>>>>>>>> even know which map space is to be used...
>>>>>>
>>>>>> Sorry, I know little about XSM. Could you suggest me how to add the
>>>>>> check for this new type here?
>>>> I'm sorry to push back here, but did you at least try to derive
>>>> what is wanted from the multitude of other XSM checks present
>>>> throughout the tree?
>>>
>>> IIUC, you mean that it doean't need to change the XSM check itself, but
>>> we should check if the current->domain is hardware domain and it maps
>>> the space to itself before the XSM check, right?
>>
>> No, I actually think that you need to add a new, secondary XSM
>> check. But you may want to consult with Daniel (who so far wasn't
>> even Cc-ed).
> 
> Looking at the original patch, I am not sure if I understand the
> checks: it seems like the iomem_access_permitted check is being done
> on the guest's page range instead of the actual IO memory, which
> ends up allowing the guest to map anything as long as it maps it in
> the right guest area. 
Yeah, since it's hard to know the MMIO range from the DSDT in XEN, we
permit full mmio capabilities for Dom0 and deny mmio access for some
devices e.g. uart. Then when Dom0 add those devices, call
XENMEM_add_to_physmap to map their MMIO ranges. This looks similar with
what x86 does.

    /* The hardware domain is initially permitted full I/O capabilities. */
    rc |= ioports_permit_access(d, 0, 0xFFFF);
    rc |= iomem_permit_access(d, 0UL, ~0UL);
    rc |= irqs_permit_access(d, 1, nr_irqs_gsi - 1);

> The iomem_permit_access call there also seems
> to be redundant because it is the same range that was just checked.
>
Ah, I'll drop this at next version.

> If the [start_gfn, start_gfn + nr) memory range actually describes
> the physical addresses, then this operation is taking advantage of
> the existing XSM checks on XEN_DOMCTL_iomem_permission, and the
> only XSM check that is needed would be that current->domain has
> permission to modify (d)'s mappings - and this is done by the
> xsm_add_to_physmap check in XENMEM_add_to_physmap.

Thanks,
-- 
Shannon

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

end of thread, other threads:[~2016-01-08  2:12 UTC | newest]

Thread overview: 426+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-17  9:39 [PATCH v3 00/62] Add ACPI support for arm64 on Xen shannon.zhao at linaro.org
2015-11-17  9:40 ` [PATCH v3 01/62] Revert "xen/arm: vgic-v2: Drop cbase from arch_domain" shannon.zhao
2015-11-17  9:40 ` shannon.zhao at linaro.org
2015-11-17 11:27   ` Julien Grall
2015-11-17 11:27     ` Julien Grall
2015-11-17 12:32     ` Shannon Zhao
2015-11-17 12:32     ` Shannon Zhao
2015-11-17 13:57       ` Julien Grall
2015-11-18  2:28         ` Shannon Zhao
2015-11-18  2:28         ` Shannon Zhao
2015-11-18 11:41           ` Julien Grall
2015-11-18 13:09             ` Shannon Zhao
2015-11-18 13:09             ` Shannon Zhao
2015-11-18 13:33               ` Julien Grall
2015-11-18 13:33               ` Julien Grall
2015-11-18 13:38                 ` Shannon Zhao
2015-11-18 13:38                 ` Shannon Zhao
2015-11-18 11:41           ` Julien Grall
2015-11-17 13:57       ` Julien Grall
2015-11-17  9:40 ` [PATCH v3 02/62] acpi/NUMA: Build NUMA for x86 only shannon.zhao at linaro.org
2015-11-17  9:40 ` shannon.zhao
2015-11-17  9:40 ` [PATCH v3 03/62] acpi/pmstat: Build pmstat " shannon.zhao
2015-11-17  9:40 ` shannon.zhao at linaro.org
2015-11-23 15:46   ` Jan Beulich
2015-11-23 15:46   ` Jan Beulich
2015-11-17  9:40 ` [PATCH v3 04/62] arm/acpi: Emulate io ports for arm shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-17  9:50   ` Arnd Bergmann
2015-11-17  9:50     ` Arnd Bergmann
2015-11-18  7:01     ` Shannon Zhao
2015-11-18  7:01     ` Shannon Zhao
2015-11-18  8:24       ` Arnd Bergmann
2015-11-18  8:24       ` Arnd Bergmann
2015-11-17  9:40 ` [PATCH v3 05/62] acpi: Don't do traditional BIOS table scan for ARM64 shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-23 11:24   ` Stefano Stabellini
2015-11-23 11:24     ` Stefano Stabellini
2015-11-23 11:35     ` Jan Beulich
2015-11-24  3:39       ` Shannon Zhao
2015-11-24  3:39       ` Shannon Zhao
2015-11-24  7:20         ` Jan Beulich
2015-11-24  7:20         ` Jan Beulich
2015-11-23 11:35     ` Jan Beulich
2015-11-17  9:40 ` [PATCH v3 06/62] acpi: Refactor acpi_os_map_memory to be architecturally independent shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-23 11:29   ` Stefano Stabellini
2015-11-23 11:29   ` [Xen-devel] " Stefano Stabellini
2015-11-23 11:37     ` Jan Beulich
2015-11-23 11:37     ` [Xen-devel] " Jan Beulich
2015-12-07 12:00   ` Julien Grall
2015-12-07 12:00   ` [Xen-devel] " Julien Grall
2015-11-17  9:40 ` [PATCH v3 07/62] arm/acpi: Add arch_acpi_os_map_memory helper function for ARM shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-23 11:37   ` Stefano Stabellini
2015-11-23 11:37   ` Stefano Stabellini
2015-11-30 14:47     ` Julien Grall
2015-11-30 14:47     ` [Xen-devel] " Julien Grall
2015-12-07  8:58       ` Shannon Zhao
2015-12-07  8:58         ` Shannon Zhao
2015-12-07 10:32         ` Jan Beulich
2015-12-07 10:32         ` [Xen-devel] " Jan Beulich
2015-12-07 10:38           ` Ian Campbell
2015-12-07 10:38           ` [Xen-devel] " Ian Campbell
2015-12-07 12:02             ` Julien Grall
2015-12-29 12:01               ` Shannon Zhao
2015-12-07 12:02             ` Julien Grall
2015-11-17  9:40 ` [PATCH v3 08/62] arm/acpi: Add arm specific acpi header file shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-23 11:43   ` Stefano Stabellini
2015-11-23 11:43   ` Stefano Stabellini
2015-11-17  9:40 ` [PATCH v3 09/62] arm/acpi: Add basic ACPI initialization shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-23 11:52   ` [Xen-devel] " Stefano Stabellini
2015-11-23 11:52   ` Stefano Stabellini
2015-11-17  9:40 ` [PATCH v3 10/62] arm/acpi: Move end_boot_allocator after acpi_boot_table_init shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-23 11:54   ` Stefano Stabellini
2015-11-23 11:54   ` Stefano Stabellini
2015-11-17  9:40 ` [PATCH v3 11/62] arm/acpi: Introduce ARM Boot Architecture Flags in FADT shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-23 12:13   ` Stefano Stabellini
2015-11-23 12:13   ` Stefano Stabellini
2015-11-17  9:40 ` [PATCH v3 12/62] ACPICA: ACPI 6.0: Add changes for FADT table shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-23 12:15   ` Stefano Stabellini
2015-11-23 12:15   ` Stefano Stabellini
2015-11-24 11:29   ` Jan Beulich
2015-11-24 11:29   ` Jan Beulich
2015-11-25  1:45     ` Shannon Zhao
2015-11-25  1:45     ` Shannon Zhao
2015-11-17  9:40 ` [PATCH v3 13/62] arm/acpi: Parse FADT table and get PSCI flags shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-23 12:42   ` Stefano Stabellini
2015-11-23 12:42   ` Stefano Stabellini
2015-11-17  9:40 ` [PATCH v3 14/62] arm/acpi: Add Generic Interrupt and Distributor struct shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-23 14:43   ` Stefano Stabellini
2015-11-23 14:43   ` Stefano Stabellini
2015-11-17  9:40 ` [PATCH v3 15/62] ACPICA: ACPI 6.0: Add changes for MADT table shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-23 14:51   ` Stefano Stabellini
2015-11-23 14:51   ` Stefano Stabellini
2015-11-17  9:40 ` [PATCH v3 16/62] ACPICA: ACPI 6.0: Add values for MADT GIC version field shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-23 14:52   ` Stefano Stabellini
2015-11-23 14:52   ` Stefano Stabellini
2015-11-17  9:40 ` [PATCH v3 17/62] arm/acpi: Print GIC information when MADT is parsed shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-23 14:56   ` Stefano Stabellini
2015-11-23 14:56   ` Stefano Stabellini
2015-11-17  9:40 ` [PATCH v3 18/62] arm/acpi: Parse MADT to map logical cpu to MPIDR and get cpu_possible_map shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-23 15:18   ` Stefano Stabellini
2015-11-23 15:18     ` Stefano Stabellini
2015-11-17  9:40 ` [PATCH v3 19/62] arm/smpboot: Move dt specific code in smp to seperate functions shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-23 15:22   ` Stefano Stabellini
2015-11-23 15:22   ` Stefano Stabellini
2015-11-17  9:40 ` [PATCH v3 20/62] arm/acpi: Add ACPI support for SMP initialization shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-23 15:27   ` Stefano Stabellini
2015-11-23 15:27   ` Stefano Stabellini
2015-11-30 14:57   ` Julien Grall
2015-11-30 14:57   ` [Xen-devel] " Julien Grall
2015-12-30  3:11     ` Shannon Zhao
2016-01-04 14:51       ` Stefano Stabellini
2016-01-04 14:51       ` [Xen-devel] " Stefano Stabellini
2016-01-04 15:00         ` Mark Rutland
2016-01-04 15:14           ` Mark Rutland
2016-01-04 15:14           ` Mark Rutland
2016-01-04 15:00         ` Mark Rutland
2016-01-04 15:12       ` [Xen-devel] " Mark Rutland
2016-01-04 15:12       ` Mark Rutland
2015-12-30  3:11     ` Shannon Zhao
2015-11-17  9:40 ` [PATCH v3 21/62] arm/gic-v2: Refactor gicv2_init into generic and dt specific parts shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-23 15:40   ` Stefano Stabellini
2015-11-23 15:40   ` Stefano Stabellini
2015-11-17  9:40 ` [PATCH v3 22/62] arm/gic-v3: Refactor gicv3_init " shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-24 10:51   ` [Xen-devel] " Stefano Stabellini
2015-11-30 15:01     ` Julien Grall
2015-11-30 15:01     ` [Xen-devel] " Julien Grall
2015-11-24 10:51   ` Stefano Stabellini
2015-11-17  9:40 ` [PATCH v3 23/62] acpi/table: Introduce acpi_parse_entries shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-23 16:56   ` Jan Beulich
2015-11-23 16:56   ` Jan Beulich
2015-11-17  9:40 ` [PATCH v3 24/62] arm: Introduce a generic way to use a device from acpi shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-17 12:40   ` Julien Grall
2015-11-17 13:21     ` Shannon Zhao
2015-11-17 13:21     ` Shannon Zhao
2015-11-17 14:25       ` Julien Grall
2015-11-18  2:37         ` Shannon Zhao
2015-11-18  2:37         ` Shannon Zhao
2015-11-18 11:46           ` Julien Grall
2015-11-18 11:46           ` Julien Grall
2015-11-17 14:25       ` Julien Grall
2015-11-17 12:40   ` Julien Grall
2015-11-24 11:18   ` [Xen-devel] " Stefano Stabellini
2015-11-24 11:18   ` Stefano Stabellini
2015-11-17  9:40 ` [PATCH v3 25/62] acpi/table: Introduce acpi_get_entry to get specified entry shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-23 16:59   ` Jan Beulich
2015-11-23 16:59   ` Jan Beulich
2015-11-24  3:08     ` Shannon Zhao
2015-11-24  7:22       ` Jan Beulich
2015-11-24  7:48         ` Shannon Zhao
2015-11-24  7:48         ` Shannon Zhao
2015-11-24  8:04           ` Jan Beulich
2015-11-24  8:04           ` Jan Beulich
2015-11-24  7:22       ` Jan Beulich
2015-11-24  3:08     ` Shannon Zhao
2015-11-17  9:40 ` [PATCH v3 26/62] arm/gic-v2: Add ACPI boot support for GICv2 shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-24 11:54   ` Stefano Stabellini
2015-11-24 11:54   ` [Xen-devel] " Stefano Stabellini
2015-11-17  9:40 ` [PATCH v3 27/62] arm/gic-v3: Add ACPI boot support for GICv3 shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-24 12:00   ` Stefano Stabellini
2015-11-24 12:00   ` [Xen-devel] " Stefano Stabellini
2015-11-17  9:40 ` [PATCH v3 28/62] arm/gic: Add ACPI support for GIC preinit shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-26 12:10   ` Stefano Stabellini
2015-11-26 12:10   ` Stefano Stabellini
2015-11-17  9:40 ` [PATCH v3 29/62] arm/acpi: Add GTDT support updated by ACPI 5.1 shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-26 12:14   ` Stefano Stabellini
2015-11-26 12:14   ` [Xen-devel] " Stefano Stabellini
2015-11-17  9:40 ` [PATCH v3 30/62] arm/irq: Add helper function for setting interrupt type shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-26 12:20   ` Stefano Stabellini
2015-11-26 12:20   ` Stefano Stabellini
2015-11-17  9:40 ` [PATCH v3 31/62] arm/acpi: Add a helper function to get " shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-18 12:16   ` Julien Grall
2015-11-18 12:16   ` [Xen-devel] " Julien Grall
2015-11-26 12:33   ` Stefano Stabellini
2015-11-26 12:33   ` Stefano Stabellini
2015-11-17  9:40 ` [PATCH v3 32/62] arm/acpi: Parse GTDT to initialize timer shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-26 12:54   ` [Xen-devel] " Stefano Stabellini
2015-11-26 12:54   ` Stefano Stabellini
2015-11-17  9:40 ` [PATCH v3 33/62] arm/uart: Create generic uart initialization function shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-17 11:49   ` Julien Grall
2015-11-17 11:49   ` Julien Grall
2015-11-17 12:34     ` Shannon Zhao
2015-11-17 12:34     ` Shannon Zhao
2015-11-17  9:40 ` [PATCH v3 34/62] pl011: Refactor pl011 driver to dt and common initialization parts shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-26 15:22   ` Stefano Stabellini
2015-11-26 15:22   ` Stefano Stabellini
2015-11-17  9:40 ` [PATCH v3 35/62] serial: Rename SERHND_DTUART to SERHND_UART shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-26 15:32   ` Stefano Stabellini
2015-11-26 15:32   ` [Xen-devel] " Stefano Stabellini
2015-11-17  9:40 ` [PATCH v3 36/62] arm/acpi: Initialize serial port from ACPI SPCR table shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-26 15:43   ` Stefano Stabellini
2015-11-26 15:43   ` Stefano Stabellini
2015-11-17  9:40 ` [PATCH v3 37/62] arm/acpi: Define a enum for reserved tables shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-26 16:50   ` [Xen-devel] " Stefano Stabellini
2015-11-26 17:06     ` Stefano Stabellini
2015-11-26 17:06     ` Stefano Stabellini
2015-11-26 16:50   ` Stefano Stabellini
2015-11-17  9:40 ` [PATCH v3 38/62] arm/acpi: Add placeholder for efi and acpi load address shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-17 11:58   ` Julien Grall
2015-11-17 11:58   ` Julien Grall
2015-11-17 12:45     ` Shannon Zhao
2015-11-17 12:45     ` Shannon Zhao
2015-11-17 14:23       ` Julien Grall
2015-11-18  3:01         ` Shannon Zhao
2015-11-18 11:56           ` Julien Grall
2015-11-26 16:04             ` Stefano Stabellini
2015-11-30 15:10               ` Julien Grall
2015-11-30 15:10                 ` Julien Grall
2015-11-26 16:04             ` Stefano Stabellini
2015-11-18 11:56           ` Julien Grall
2015-11-18  3:01         ` Shannon Zhao
2015-11-17 14:23       ` Julien Grall
2015-11-26 16:02       ` Stefano Stabellini
2015-11-26 16:02       ` Stefano Stabellini
2015-11-17  9:40 ` [PATCH v3 39/62] arm/acpi: Read acpi memory info from uefi shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-26 16:18   ` Stefano Stabellini
2015-11-26 16:18   ` Stefano Stabellini
2015-11-17  9:40 ` [PATCH v3 40/62] arm/acpi: Estimate memory required for acpi/efi tables shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-26 16:39   ` Stefano Stabellini
2015-11-26 16:39   ` Stefano Stabellini
2015-12-31  9:16     ` Shannon Zhao
2016-01-04 14:35       ` Stefano Stabellini
2016-01-04 14:35       ` Stefano Stabellini
2015-12-31  9:16     ` Shannon Zhao
2015-11-30 15:14   ` [Xen-devel] " Julien Grall
2015-11-30 15:14     ` Julien Grall
2016-01-04  9:03     ` [Xen-devel] " Shannon Zhao
2016-01-04 14:34       ` Stefano Stabellini
2016-01-04 14:34       ` Stefano Stabellini
2016-01-04  9:03     ` Shannon Zhao
2015-11-17  9:40 ` [PATCH v3 41/62] arm/acpi: Add a helper function to get the acpi table offset shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-26 17:02   ` Stefano Stabellini
2015-11-26 17:02   ` Stefano Stabellini
2015-11-17  9:40 ` [PATCH v3 42/62] arm/acpi: Prepare FADT table for Dom0 shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-26 17:19   ` Stefano Stabellini
2015-11-26 17:19   ` [Xen-devel] " Stefano Stabellini
2015-11-27  9:50     ` Ian Campbell
2015-11-27  9:50     ` [Xen-devel] " Ian Campbell
2015-11-17  9:40 ` [PATCH v3 43/62] arm/acpi: Prepare MADT " shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-26 17:48   ` Stefano Stabellini
2015-11-26 17:48   ` Stefano Stabellini
2015-11-17  9:40 ` [PATCH v3 44/62] ACPICA: ACPI 6.0: Add support for STAO table shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-27 11:15   ` Stefano Stabellini
2015-11-27 11:15   ` Stefano Stabellini
2015-11-17  9:40 ` [PATCH v3 45/62] arm/acpi: Prepare STAO table for Dom0 shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-27 11:24   ` Stefano Stabellini
2015-11-27 11:24   ` [Xen-devel] " Stefano Stabellini
2015-11-17  9:40 ` [PATCH v3 46/62] arm/acpi: Prepare XSDT " shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-27 11:58   ` [Xen-devel] " Stefano Stabellini
2015-11-27 11:58     ` Stefano Stabellini
2015-11-17  9:40 ` [PATCH v3 47/62] arm/p2m: Add helper functions to map memory regions shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-27 12:04   ` Stefano Stabellini
2015-11-30 15:22     ` Julien Grall
2015-11-30 15:22     ` Julien Grall
2016-01-05  3:50       ` Shannon Zhao
2016-01-05  3:50       ` Shannon Zhao
2015-11-27 12:04   ` Stefano Stabellini
2015-11-30 15:23   ` [Xen-devel] " Julien Grall
2015-11-30 15:23   ` Julien Grall
2015-11-17  9:40 ` [PATCH v3 48/62] arm/acpi: Prepare RSDP table for Dom0 shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-27 12:10   ` Stefano Stabellini
2015-11-27 12:10   ` Stefano Stabellini
2015-11-17  9:40 ` [PATCH v3 49/62] arm/acpi: Map rest tables " shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-27 12:16   ` Stefano Stabellini
2015-11-30 15:25     ` Julien Grall
2015-11-30 15:25       ` Julien Grall
2015-11-27 12:16   ` Stefano Stabellini
2015-11-17  9:40 ` [PATCH v3 50/62] xen/efi: store EFI system table in efi structure shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-17 11:07   ` Jan Beulich
2015-11-17 11:07   ` Jan Beulich
2015-11-17 11:57   ` Julien Grall
2015-11-17 11:57   ` Julien Grall
2015-11-18  3:17     ` Shannon Zhao
2015-11-18  3:17     ` Shannon Zhao
2015-11-17  9:40 ` [PATCH v3 51/62] arm/acpi: Prepare EFI system table for Dom0 shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-17 12:02   ` Julien Grall
2015-11-18  3:34     ` Shannon Zhao
2015-11-18 12:06       ` Julien Grall
2015-11-17 12:02   ` Julien Grall
2015-11-18 12:09   ` Julien Grall
2015-11-18 12:09   ` [Xen-devel] " Julien Grall
2015-11-27 14:13   ` Stefano Stabellini
2015-11-27 14:13   ` Stefano Stabellini
2015-11-17  9:40 ` [PATCH v3 52/62] arm/acpi: Prepare EFI memory descriptor " shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-27 14:30   ` Stefano Stabellini
2015-12-31  7:40     ` Shannon Zhao
2015-12-31  7:40       ` Shannon Zhao
2016-01-04 14:54       ` Stefano Stabellini
2016-01-04 14:54       ` Stefano Stabellini
2015-11-27 14:30   ` Stefano Stabellini
2015-11-17  9:40 ` [PATCH v3 53/62] arm/acpi: Map the new created EFI and ACPI tables to Dom0 shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-27 14:34   ` Stefano Stabellini
2015-11-27 14:34   ` Stefano Stabellini
2015-11-17  9:40 ` [PATCH v3 54/62] arm/acpi: Create min DT stub for Dom0 shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-27 14:44   ` [Xen-devel] " Stefano Stabellini
2015-11-27 14:44   ` Stefano Stabellini
2015-11-17  9:40 ` [PATCH v3 55/62] arm/acpi: Route all Xen unused SPIs to Dom0 shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-17 12:33   ` Julien Grall
2015-11-17 12:33   ` Julien Grall
2015-11-27 15:04   ` Stefano Stabellini
2015-11-27 15:04   ` Stefano Stabellini
2015-11-30 15:41     ` Julien Grall
2015-11-30 15:41     ` [Xen-devel] " Julien Grall
2015-11-17  9:40 ` [PATCH v3 56/62] arm/acpi: Deny MMIO access of UART shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-17 12:04   ` Julien Grall
2015-11-17 12:04   ` Julien Grall
2015-11-17 13:10     ` Shannon Zhao
2015-11-17 13:10     ` Shannon Zhao
2015-11-27 14:50       ` Stefano Stabellini
2015-11-27 14:50       ` Stefano Stabellini
2015-11-30 15:30       ` Julien Grall
2015-11-30 15:30       ` Julien Grall
2015-11-17  9:40 ` [PATCH v3 57/62] hvm/params: Add a new dilivery type for event-channel in HVM_PARAM_CALLBACK_IRQ shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-24  7:35   ` Jan Beulich
2015-11-24  7:35   ` Jan Beulich
2015-11-17  9:40 ` [PATCH v3 58/62] xen/acpi: Fix event-channel interrupt when booting with ACPI shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-27 15:12   ` Stefano Stabellini
2015-11-30 15:30     ` Julien Grall
2015-11-30 15:30       ` Julien Grall
2015-11-27 15:12   ` Stefano Stabellini
2015-11-17  9:40 ` [PATCH v3 59/62] xen/arm: Add a hypercall for device mmio mapping shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-17 11:04   ` Jan Beulich
2015-11-17 11:04   ` Jan Beulich
2016-01-07  6:58     ` Shannon Zhao
2016-01-07  6:58       ` Shannon Zhao
2016-01-07  7:45       ` Jan Beulich
2016-01-07  9:11         ` Shannon Zhao
2016-01-07  9:11         ` Shannon Zhao
2016-01-07 10:50           ` Jan Beulich
2016-01-07 21:40             ` Daniel De Graaf
2016-01-08  2:12               ` Shannon Zhao
2016-01-08  2:12               ` Shannon Zhao
2016-01-07 21:40             ` Daniel De Graaf
2016-01-07 10:50           ` Jan Beulich
2016-01-07  7:45       ` Jan Beulich
2015-11-17  9:40 ` [PATCH v3 60/62] arm/acpi: Configure interrupts dynamically shannon.zhao at linaro.org
2015-11-17  9:40   ` shannon.zhao
2015-11-27 16:13   ` Stefano Stabellini
2015-11-27 16:13   ` Stefano Stabellini
2015-11-27 16:19     ` Stefano Stabellini
2015-11-27 16:19     ` Stefano Stabellini
2015-11-30 15:42   ` [Xen-devel] " Julien Grall
2015-11-30 15:42     ` Julien Grall
2016-01-05 11:51     ` Shannon Zhao
2016-01-05 11:51     ` [Xen-devel] " Shannon Zhao
2016-01-05 14:18       ` Stefano Stabellini
2016-01-05 14:18       ` [Xen-devel] " Stefano Stabellini
2015-11-17  9:41 ` [PATCH v3 61/62] arm/acpi: Add acpi parameter to enable/disable acpi shannon.zhao at linaro.org
2015-11-17  9:41   ` shannon.zhao
2015-11-17 12:26   ` Julien Grall
2015-11-17 12:26   ` Julien Grall
2015-11-17 12:57     ` Shannon Zhao
2015-11-17 12:57     ` Shannon Zhao
2015-11-17 14:32       ` Julien Grall
2015-11-17 14:32       ` Julien Grall
2015-11-17  9:41 ` [PATCH v3 62/62] xen/arm64: Add ACPI support shannon.zhao at linaro.org
2015-11-17  9:41   ` shannon.zhao
2015-11-27 15:16   ` [Xen-devel] " Stefano Stabellini
2015-11-27 15:16     ` Stefano Stabellini
2015-11-30 15:44   ` [Xen-devel] " Julien Grall
2015-11-30 15:44   ` Julien Grall
2015-11-17 10:59 ` [PATCH v3 00/62] Add ACPI support for arm64 on Xen Jan Beulich
2015-11-17 10:59   ` Jan Beulich
2015-11-17 11:10   ` David Vrabel
2015-11-17 11:10   ` David Vrabel
2015-11-17 13:02     ` Shannon Zhao
2015-11-17 13:02     ` Shannon Zhao
2015-11-17 11:52 ` Julien Grall
2015-11-18  8:03   ` Shannon Zhao
2015-11-18 12:18     ` Julien Grall
2015-11-18 12:18     ` Julien Grall
2015-11-18  8:03   ` Shannon Zhao
2015-11-17 11:52 ` Julien Grall

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.