All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 00/17] Add ACPI support for Xen Dom0 on ARM64
@ 2016-01-23  3:19 ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: catalin.marinas, will.deacon, julien.grall, xen-devel,
	devicetree, linux-efi, linux-kernel, ian.campbell, shannon.zhao,
	peter.huangpeng

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

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

This patch set adds a new FDT node "uefi" under /hypervisor to pass UEFI
information. Introduce a bus notifier of AMBA and Platform bus to map
the new added device's MMIO space. Make Xen domain use
xlated_setup_gnttab_pages to setup grant table and a new hypercall to
get event-channel irq.

Regarding the initialization flow of Linux kernel, it needs to move
xen_early_init() before efi_init(). Then xen_early_init() will check
whether it runs on Xen through the /hypervisor node and efi_init() will
call a new function fdt_find_xen_uefi_params(), to parse those
xen,uefi-* parameters just like the existing efi_get_fdt_params().

And in arm64_enable_runtime_services() it will check whether it runs on
Xen and call another new function xen_efi_runtime_setup() to setup
runtime service instead of efi_native_runtime_setup(). The
xen_efi_runtime_setup() will assign the runtime function pointers with
the functions of driver/xen/efi.c.

And since we pass a /hypervisor node and a /chosen node to Dom0, it
needs to check whether the DTS only contains a /hypervisor node and a
/chosen node in acpi_boot_table_init().

Patches are tested on FVP base model. The corresponding Xen patches can
be fetched from [2].

Thanks,
Shannon

[1] http://lists.xen.org/archives/html/xen-devel/2015-11/msg00488.html
[2] http://git.linaro.org/people/shannon.zhao/xen.git  ACPI_XEN_ARM_V3

Changes since v2:
* Use 0 to check if it should ignore the UART
* Fix the use of page_to_xen_pfn
* Factor ACPI and DT parts in xen_guest_init
* Check "uefi" node by full path
* Fix the statement of Documentation/devicetree/bindings/arm/xen.txt

Changes since v1:
* Rebase on linux mainline and wallclock patch from Stefano
* Refactor AMBA and platform device MMIO map to one file
* Use EFI_PARAVIRT to check if it supports XEN EFI
* Refactor Xen EFI codes
* Address other comments

Shannon Zhao (17):
  Xen: ACPI: Hide UART used by Xen
  xen/grant-table: Move xlated_setup_gnttab_pages to common place
  Xen: xlate: Use page_to_xen_pfn instead of page_to_pfn
  arm/xen: Use xen_xlate_map_ballooned_pages to setup grant table
  xen: memory : Add new XENMAPSPACE type XENMAPSPACE_dev_mmio
  Xen: ARM: Add support for mapping platform device mmio
  Xen: ARM: Add support for mapping AMBA device mmio
  Xen: public/hvm: sync changes of HVM_PARAM_CALLBACK_VIA ABI from Xen
  xen/hvm/params: Add a new delivery type for event-channel in
    HVM_PARAM_CALLBACK_IRQ
  arm/xen: Get event-channel irq through HVM_PARAM when booting with
    ACPI
  ARM: XEN: Move xen_early_init() before efi_init()
  ARM64: ACPI: Check if it runs on Xen to enable or disable ACPI
  ARM: Xen: Document UEFI support on Xen ARM virtual platforms
  XEN: EFI: Move x86 specific codes to architecture directory
  ARM64: XEN: Add a function to initialize Xen specific UEFI runtime
    services
  FDT: Add a helper to get specified name subnode
  Xen: EFI: Parse DT parameters for Xen specific UEFI

 Documentation/devicetree/bindings/arm/xen.txt |  34 +++++
 arch/arm/xen/enlighten.c                      | 109 +++++++++++----
 arch/arm64/include/asm/xen/xen-ops.h          |   6 +
 arch/arm64/kernel/acpi.c                      |  12 +-
 arch/arm64/kernel/efi.c                       |  17 ++-
 arch/arm64/kernel/setup.c                     |   2 +-
 arch/arm64/xen/Makefile                       |   1 +
 arch/arm64/xen/efi.c                          |  40 ++++++
 arch/x86/xen/efi.c                            | 112 ++++++++++++++++
 arch/x86/xen/grant-table.c                    |  57 +-------
 drivers/acpi/bus.c                            |  36 ++++-
 drivers/firmware/efi/efi.c                    |  45 ++++++-
 drivers/of/fdt.c                              |  35 +++++
 drivers/xen/Kconfig                           |   2 +-
 drivers/xen/Makefile                          |   1 +
 drivers/xen/arm-device.c                      | 184 ++++++++++++++++++++++++++
 drivers/xen/efi.c                             | 174 +++++-------------------
 drivers/xen/xlate_mmu.c                       |  67 ++++++++++
 include/linux/of_fdt.h                        |   2 +
 include/xen/interface/hvm/params.h            |  36 ++++-
 include/xen/interface/memory.h                |   1 +
 include/xen/xen-ops.h                         |  32 +++--
 22 files changed, 757 insertions(+), 248 deletions(-)
 create mode 100644 arch/arm64/include/asm/xen/xen-ops.h
 create mode 100644 arch/arm64/xen/efi.c
 create mode 100644 drivers/xen/arm-device.c

-- 
2.0.4

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

* [PATCH v3 00/17] Add ACPI support for Xen Dom0 on ARM64
@ 2016-01-23  3:19 ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	stefano.stabellini-Sxgqhf6Nn4DQT0dZR+AlfA,
	david.vrabel-Sxgqhf6Nn4DQT0dZR+AlfA
  Cc: catalin.marinas-5wv7dgnIgG8, will.deacon-5wv7dgnIgG8,
	julien.grall-Sxgqhf6Nn4DQT0dZR+AlfA,
	xen-devel-GuqFBffKawuEi8DpZVb4nw,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-efi-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	ian.campbell-Sxgqhf6Nn4DQT0dZR+AlfA,
	shannon.zhao-QSEj5FYQhm4dnm+yROfE0A,
	peter.huangpeng-hv44wF8Li93QT0dZR+AlfA

From: Shannon Zhao <shannon.zhao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>

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

This patch set adds a new FDT node "uefi" under /hypervisor to pass UEFI
information. Introduce a bus notifier of AMBA and Platform bus to map
the new added device's MMIO space. Make Xen domain use
xlated_setup_gnttab_pages to setup grant table and a new hypercall to
get event-channel irq.

Regarding the initialization flow of Linux kernel, it needs to move
xen_early_init() before efi_init(). Then xen_early_init() will check
whether it runs on Xen through the /hypervisor node and efi_init() will
call a new function fdt_find_xen_uefi_params(), to parse those
xen,uefi-* parameters just like the existing efi_get_fdt_params().

And in arm64_enable_runtime_services() it will check whether it runs on
Xen and call another new function xen_efi_runtime_setup() to setup
runtime service instead of efi_native_runtime_setup(). The
xen_efi_runtime_setup() will assign the runtime function pointers with
the functions of driver/xen/efi.c.

And since we pass a /hypervisor node and a /chosen node to Dom0, it
needs to check whether the DTS only contains a /hypervisor node and a
/chosen node in acpi_boot_table_init().

Patches are tested on FVP base model. The corresponding Xen patches can
be fetched from [2].

Thanks,
Shannon

[1] http://lists.xen.org/archives/html/xen-devel/2015-11/msg00488.html
[2] http://git.linaro.org/people/shannon.zhao/xen.git  ACPI_XEN_ARM_V3

Changes since v2:
* Use 0 to check if it should ignore the UART
* Fix the use of page_to_xen_pfn
* Factor ACPI and DT parts in xen_guest_init
* Check "uefi" node by full path
* Fix the statement of Documentation/devicetree/bindings/arm/xen.txt

Changes since v1:
* Rebase on linux mainline and wallclock patch from Stefano
* Refactor AMBA and platform device MMIO map to one file
* Use EFI_PARAVIRT to check if it supports XEN EFI
* Refactor Xen EFI codes
* Address other comments

Shannon Zhao (17):
  Xen: ACPI: Hide UART used by Xen
  xen/grant-table: Move xlated_setup_gnttab_pages to common place
  Xen: xlate: Use page_to_xen_pfn instead of page_to_pfn
  arm/xen: Use xen_xlate_map_ballooned_pages to setup grant table
  xen: memory : Add new XENMAPSPACE type XENMAPSPACE_dev_mmio
  Xen: ARM: Add support for mapping platform device mmio
  Xen: ARM: Add support for mapping AMBA device mmio
  Xen: public/hvm: sync changes of HVM_PARAM_CALLBACK_VIA ABI from Xen
  xen/hvm/params: Add a new delivery type for event-channel in
    HVM_PARAM_CALLBACK_IRQ
  arm/xen: Get event-channel irq through HVM_PARAM when booting with
    ACPI
  ARM: XEN: Move xen_early_init() before efi_init()
  ARM64: ACPI: Check if it runs on Xen to enable or disable ACPI
  ARM: Xen: Document UEFI support on Xen ARM virtual platforms
  XEN: EFI: Move x86 specific codes to architecture directory
  ARM64: XEN: Add a function to initialize Xen specific UEFI runtime
    services
  FDT: Add a helper to get specified name subnode
  Xen: EFI: Parse DT parameters for Xen specific UEFI

 Documentation/devicetree/bindings/arm/xen.txt |  34 +++++
 arch/arm/xen/enlighten.c                      | 109 +++++++++++----
 arch/arm64/include/asm/xen/xen-ops.h          |   6 +
 arch/arm64/kernel/acpi.c                      |  12 +-
 arch/arm64/kernel/efi.c                       |  17 ++-
 arch/arm64/kernel/setup.c                     |   2 +-
 arch/arm64/xen/Makefile                       |   1 +
 arch/arm64/xen/efi.c                          |  40 ++++++
 arch/x86/xen/efi.c                            | 112 ++++++++++++++++
 arch/x86/xen/grant-table.c                    |  57 +-------
 drivers/acpi/bus.c                            |  36 ++++-
 drivers/firmware/efi/efi.c                    |  45 ++++++-
 drivers/of/fdt.c                              |  35 +++++
 drivers/xen/Kconfig                           |   2 +-
 drivers/xen/Makefile                          |   1 +
 drivers/xen/arm-device.c                      | 184 ++++++++++++++++++++++++++
 drivers/xen/efi.c                             | 174 +++++-------------------
 drivers/xen/xlate_mmu.c                       |  67 ++++++++++
 include/linux/of_fdt.h                        |   2 +
 include/xen/interface/hvm/params.h            |  36 ++++-
 include/xen/interface/memory.h                |   1 +
 include/xen/xen-ops.h                         |  32 +++--
 22 files changed, 757 insertions(+), 248 deletions(-)
 create mode 100644 arch/arm64/include/asm/xen/xen-ops.h
 create mode 100644 arch/arm64/xen/efi.c
 create mode 100644 drivers/xen/arm-device.c

-- 
2.0.4


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v3 00/17] Add ACPI support for Xen Dom0 on ARM64
@ 2016-01-23  3:19 ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel

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

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

This patch set adds a new FDT node "uefi" under /hypervisor to pass UEFI
information. Introduce a bus notifier of AMBA and Platform bus to map
the new added device's MMIO space. Make Xen domain use
xlated_setup_gnttab_pages to setup grant table and a new hypercall to
get event-channel irq.

Regarding the initialization flow of Linux kernel, it needs to move
xen_early_init() before efi_init(). Then xen_early_init() will check
whether it runs on Xen through the /hypervisor node and efi_init() will
call a new function fdt_find_xen_uefi_params(), to parse those
xen,uefi-* parameters just like the existing efi_get_fdt_params().

And in arm64_enable_runtime_services() it will check whether it runs on
Xen and call another new function xen_efi_runtime_setup() to setup
runtime service instead of efi_native_runtime_setup(). The
xen_efi_runtime_setup() will assign the runtime function pointers with
the functions of driver/xen/efi.c.

And since we pass a /hypervisor node and a /chosen node to Dom0, it
needs to check whether the DTS only contains a /hypervisor node and a
/chosen node in acpi_boot_table_init().

Patches are tested on FVP base model. The corresponding Xen patches can
be fetched from [2].

Thanks,
Shannon

[1] http://lists.xen.org/archives/html/xen-devel/2015-11/msg00488.html
[2] http://git.linaro.org/people/shannon.zhao/xen.git  ACPI_XEN_ARM_V3

Changes since v2:
* Use 0 to check if it should ignore the UART
* Fix the use of page_to_xen_pfn
* Factor ACPI and DT parts in xen_guest_init
* Check "uefi" node by full path
* Fix the statement of Documentation/devicetree/bindings/arm/xen.txt

Changes since v1:
* Rebase on linux mainline and wallclock patch from Stefano
* Refactor AMBA and platform device MMIO map to one file
* Use EFI_PARAVIRT to check if it supports XEN EFI
* Refactor Xen EFI codes
* Address other comments

Shannon Zhao (17):
  Xen: ACPI: Hide UART used by Xen
  xen/grant-table: Move xlated_setup_gnttab_pages to common place
  Xen: xlate: Use page_to_xen_pfn instead of page_to_pfn
  arm/xen: Use xen_xlate_map_ballooned_pages to setup grant table
  xen: memory : Add new XENMAPSPACE type XENMAPSPACE_dev_mmio
  Xen: ARM: Add support for mapping platform device mmio
  Xen: ARM: Add support for mapping AMBA device mmio
  Xen: public/hvm: sync changes of HVM_PARAM_CALLBACK_VIA ABI from Xen
  xen/hvm/params: Add a new delivery type for event-channel in
    HVM_PARAM_CALLBACK_IRQ
  arm/xen: Get event-channel irq through HVM_PARAM when booting with
    ACPI
  ARM: XEN: Move xen_early_init() before efi_init()
  ARM64: ACPI: Check if it runs on Xen to enable or disable ACPI
  ARM: Xen: Document UEFI support on Xen ARM virtual platforms
  XEN: EFI: Move x86 specific codes to architecture directory
  ARM64: XEN: Add a function to initialize Xen specific UEFI runtime
    services
  FDT: Add a helper to get specified name subnode
  Xen: EFI: Parse DT parameters for Xen specific UEFI

 Documentation/devicetree/bindings/arm/xen.txt |  34 +++++
 arch/arm/xen/enlighten.c                      | 109 +++++++++++----
 arch/arm64/include/asm/xen/xen-ops.h          |   6 +
 arch/arm64/kernel/acpi.c                      |  12 +-
 arch/arm64/kernel/efi.c                       |  17 ++-
 arch/arm64/kernel/setup.c                     |   2 +-
 arch/arm64/xen/Makefile                       |   1 +
 arch/arm64/xen/efi.c                          |  40 ++++++
 arch/x86/xen/efi.c                            | 112 ++++++++++++++++
 arch/x86/xen/grant-table.c                    |  57 +-------
 drivers/acpi/bus.c                            |  36 ++++-
 drivers/firmware/efi/efi.c                    |  45 ++++++-
 drivers/of/fdt.c                              |  35 +++++
 drivers/xen/Kconfig                           |   2 +-
 drivers/xen/Makefile                          |   1 +
 drivers/xen/arm-device.c                      | 184 ++++++++++++++++++++++++++
 drivers/xen/efi.c                             | 174 +++++-------------------
 drivers/xen/xlate_mmu.c                       |  67 ++++++++++
 include/linux/of_fdt.h                        |   2 +
 include/xen/interface/hvm/params.h            |  36 ++++-
 include/xen/interface/memory.h                |   1 +
 include/xen/xen-ops.h                         |  32 +++--
 22 files changed, 757 insertions(+), 248 deletions(-)
 create mode 100644 arch/arm64/include/asm/xen/xen-ops.h
 create mode 100644 arch/arm64/xen/efi.c
 create mode 100644 drivers/xen/arm-device.c

-- 
2.0.4

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

* [PATCH v3 01/17] Xen: ACPI: Hide UART used by Xen
  2016-01-23  3:19 ` Shannon Zhao
  (?)
@ 2016-01-23  3:19   ` Shannon Zhao
  -1 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: catalin.marinas, will.deacon, julien.grall, xen-devel,
	devicetree, linux-efi, linux-kernel, ian.campbell, shannon.zhao,
	peter.huangpeng, Rafael J. Wysocki, Len Brown, open list:ACPI

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

ACPI 6.0 introduces a new table STAO to list the devices which are used
by Xen and can't be used by Dom0. On Xen virtual platforms, the physical
UART is used by Xen. So here it hides UART from Dom0.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
CC: "Rafael J. Wysocki" <rjw@rjwysocki.net> (supporter:ACPI)
CC: Len Brown <lenb@kernel.org> (supporter:ACPI)
CC: linux-acpi@vger.kernel.org (open list:ACPI)
---
 drivers/acpi/bus.c | 36 +++++++++++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index a212cef..7f85b54 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -46,6 +46,7 @@ ACPI_MODULE_NAME("bus");
 struct acpi_device *acpi_root;
 struct proc_dir_entry *acpi_root_dir;
 EXPORT_SYMBOL(acpi_root_dir);
+static u64 spcr_uart_addr;
 
 #ifdef CONFIG_X86
 #ifdef CONFIG_ACPI_CUSTOM_DSDT
@@ -105,6 +106,22 @@ acpi_status acpi_bus_get_status_handle(acpi_handle handle,
 	return status;
 }
 
+static bool acpi_check_device_is_ignored(acpi_handle handle)
+{
+	acpi_status status;
+	u64 addr;
+
+	/* Check if it should ignore the UART device */
+	if (spcr_uart_addr != 0) {
+		status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL,
+					       &addr);
+		if (ACPI_SUCCESS(status) && addr == spcr_uart_addr)
+			return true;
+	}
+
+	return false;
+}
+
 int acpi_bus_get_status(struct acpi_device *device)
 {
 	acpi_status status;
@@ -114,7 +131,8 @@ int acpi_bus_get_status(struct acpi_device *device)
 	if (ACPI_FAILURE(status))
 		return -ENODEV;
 
-	acpi_set_device_status(device, sta);
+	if (!acpi_check_device_is_ignored(device->handle))
+		acpi_set_device_status(device, sta);
 
 	if (device->status.functional && !device->status.present) {
 		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]: "
@@ -1069,6 +1087,8 @@ EXPORT_SYMBOL_GPL(acpi_kobj);
 static int __init acpi_init(void)
 {
 	int result;
+	acpi_status status;
+	struct acpi_table_stao *stao_ptr;
 
 	if (acpi_disabled) {
 		printk(KERN_INFO PREFIX "Interpreter disabled.\n");
@@ -1081,6 +1101,20 @@ static int __init acpi_init(void)
 		acpi_kobj = NULL;
 	}
 
+	/* If there is STAO table, check whether it needs to ignore the UART
+	 * device in SPCR table.
+	 */
+	status = acpi_get_table(ACPI_SIG_STAO, 0,
+				(struct acpi_table_header **)&stao_ptr);
+	if (ACPI_SUCCESS(status) && stao_ptr->ignore_uart) {
+		struct acpi_table_spcr *spcr_ptr;
+
+		status = acpi_get_table(ACPI_SIG_SPCR, 0,
+					(struct acpi_table_header **)&spcr_ptr);
+		if (ACPI_SUCCESS(status))
+			spcr_uart_addr = spcr_ptr->serial_port.address;
+	}
+
 	init_acpi_device_notify();
 	result = acpi_bus_init();
 	if (result) {
-- 
2.0.4



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

* [PATCH v3 01/17] Xen: ACPI: Hide UART used by Xen
@ 2016-01-23  3:19   ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: catalin.marinas, will.deacon, julien.grall, xen-devel,
	devicetree, linux-efi, linux-kernel, ian.campbell, shannon.zhao,
	peter.huangpeng, Rafael J. Wysocki, Len Brown, open list:ACPI

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

ACPI 6.0 introduces a new table STAO to list the devices which are used
by Xen and can't be used by Dom0. On Xen virtual platforms, the physical
UART is used by Xen. So here it hides UART from Dom0.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
CC: "Rafael J. Wysocki" <rjw@rjwysocki.net> (supporter:ACPI)
CC: Len Brown <lenb@kernel.org> (supporter:ACPI)
CC: linux-acpi@vger.kernel.org (open list:ACPI)
---
 drivers/acpi/bus.c | 36 +++++++++++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index a212cef..7f85b54 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -46,6 +46,7 @@ ACPI_MODULE_NAME("bus");
 struct acpi_device *acpi_root;
 struct proc_dir_entry *acpi_root_dir;
 EXPORT_SYMBOL(acpi_root_dir);
+static u64 spcr_uart_addr;
 
 #ifdef CONFIG_X86
 #ifdef CONFIG_ACPI_CUSTOM_DSDT
@@ -105,6 +106,22 @@ acpi_status acpi_bus_get_status_handle(acpi_handle handle,
 	return status;
 }
 
+static bool acpi_check_device_is_ignored(acpi_handle handle)
+{
+	acpi_status status;
+	u64 addr;
+
+	/* Check if it should ignore the UART device */
+	if (spcr_uart_addr != 0) {
+		status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL,
+					       &addr);
+		if (ACPI_SUCCESS(status) && addr == spcr_uart_addr)
+			return true;
+	}
+
+	return false;
+}
+
 int acpi_bus_get_status(struct acpi_device *device)
 {
 	acpi_status status;
@@ -114,7 +131,8 @@ int acpi_bus_get_status(struct acpi_device *device)
 	if (ACPI_FAILURE(status))
 		return -ENODEV;
 
-	acpi_set_device_status(device, sta);
+	if (!acpi_check_device_is_ignored(device->handle))
+		acpi_set_device_status(device, sta);
 
 	if (device->status.functional && !device->status.present) {
 		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]: "
@@ -1069,6 +1087,8 @@ EXPORT_SYMBOL_GPL(acpi_kobj);
 static int __init acpi_init(void)
 {
 	int result;
+	acpi_status status;
+	struct acpi_table_stao *stao_ptr;
 
 	if (acpi_disabled) {
 		printk(KERN_INFO PREFIX "Interpreter disabled.\n");
@@ -1081,6 +1101,20 @@ static int __init acpi_init(void)
 		acpi_kobj = NULL;
 	}
 
+	/* If there is STAO table, check whether it needs to ignore the UART
+	 * device in SPCR table.
+	 */
+	status = acpi_get_table(ACPI_SIG_STAO, 0,
+				(struct acpi_table_header **)&stao_ptr);
+	if (ACPI_SUCCESS(status) && stao_ptr->ignore_uart) {
+		struct acpi_table_spcr *spcr_ptr;
+
+		status = acpi_get_table(ACPI_SIG_SPCR, 0,
+					(struct acpi_table_header **)&spcr_ptr);
+		if (ACPI_SUCCESS(status))
+			spcr_uart_addr = spcr_ptr->serial_port.address;
+	}
+
 	init_acpi_device_notify();
 	result = acpi_bus_init();
 	if (result) {
-- 
2.0.4

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

* [PATCH v3 01/17] Xen: ACPI: Hide UART used by Xen
@ 2016-01-23  3:19   ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel

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

ACPI 6.0 introduces a new table STAO to list the devices which are used
by Xen and can't be used by Dom0. On Xen virtual platforms, the physical
UART is used by Xen. So here it hides UART from Dom0.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
CC: "Rafael J. Wysocki" <rjw@rjwysocki.net> (supporter:ACPI)
CC: Len Brown <lenb@kernel.org> (supporter:ACPI)
CC: linux-acpi at vger.kernel.org (open list:ACPI)
---
 drivers/acpi/bus.c | 36 +++++++++++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index a212cef..7f85b54 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -46,6 +46,7 @@ ACPI_MODULE_NAME("bus");
 struct acpi_device *acpi_root;
 struct proc_dir_entry *acpi_root_dir;
 EXPORT_SYMBOL(acpi_root_dir);
+static u64 spcr_uart_addr;
 
 #ifdef CONFIG_X86
 #ifdef CONFIG_ACPI_CUSTOM_DSDT
@@ -105,6 +106,22 @@ acpi_status acpi_bus_get_status_handle(acpi_handle handle,
 	return status;
 }
 
+static bool acpi_check_device_is_ignored(acpi_handle handle)
+{
+	acpi_status status;
+	u64 addr;
+
+	/* Check if it should ignore the UART device */
+	if (spcr_uart_addr != 0) {
+		status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL,
+					       &addr);
+		if (ACPI_SUCCESS(status) && addr == spcr_uart_addr)
+			return true;
+	}
+
+	return false;
+}
+
 int acpi_bus_get_status(struct acpi_device *device)
 {
 	acpi_status status;
@@ -114,7 +131,8 @@ int acpi_bus_get_status(struct acpi_device *device)
 	if (ACPI_FAILURE(status))
 		return -ENODEV;
 
-	acpi_set_device_status(device, sta);
+	if (!acpi_check_device_is_ignored(device->handle))
+		acpi_set_device_status(device, sta);
 
 	if (device->status.functional && !device->status.present) {
 		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]: "
@@ -1069,6 +1087,8 @@ EXPORT_SYMBOL_GPL(acpi_kobj);
 static int __init acpi_init(void)
 {
 	int result;
+	acpi_status status;
+	struct acpi_table_stao *stao_ptr;
 
 	if (acpi_disabled) {
 		printk(KERN_INFO PREFIX "Interpreter disabled.\n");
@@ -1081,6 +1101,20 @@ static int __init acpi_init(void)
 		acpi_kobj = NULL;
 	}
 
+	/* If there is STAO table, check whether it needs to ignore the UART
+	 * device in SPCR table.
+	 */
+	status = acpi_get_table(ACPI_SIG_STAO, 0,
+				(struct acpi_table_header **)&stao_ptr);
+	if (ACPI_SUCCESS(status) && stao_ptr->ignore_uart) {
+		struct acpi_table_spcr *spcr_ptr;
+
+		status = acpi_get_table(ACPI_SIG_SPCR, 0,
+					(struct acpi_table_header **)&spcr_ptr);
+		if (ACPI_SUCCESS(status))
+			spcr_uart_addr = spcr_ptr->serial_port.address;
+	}
+
 	init_acpi_device_notify();
 	result = acpi_bus_init();
 	if (result) {
-- 
2.0.4

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

* [PATCH v3 01/17] Xen: ACPI: Hide UART used by Xen
  2016-01-23  3:19 ` Shannon Zhao
  (?)
  (?)
@ 2016-01-23  3:19 ` Shannon Zhao
  -1 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: devicetree, linux-efi, ian.campbell, Rafael J. Wysocki,
	catalin.marinas, will.deacon, linux-kernel, xen-devel,
	julien.grall, open list:ACPI, shannon.zhao, peter.huangpeng,
	Len Brown

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

ACPI 6.0 introduces a new table STAO to list the devices which are used
by Xen and can't be used by Dom0. On Xen virtual platforms, the physical
UART is used by Xen. So here it hides UART from Dom0.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
CC: "Rafael J. Wysocki" <rjw@rjwysocki.net> (supporter:ACPI)
CC: Len Brown <lenb@kernel.org> (supporter:ACPI)
CC: linux-acpi@vger.kernel.org (open list:ACPI)
---
 drivers/acpi/bus.c | 36 +++++++++++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index a212cef..7f85b54 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -46,6 +46,7 @@ ACPI_MODULE_NAME("bus");
 struct acpi_device *acpi_root;
 struct proc_dir_entry *acpi_root_dir;
 EXPORT_SYMBOL(acpi_root_dir);
+static u64 spcr_uart_addr;
 
 #ifdef CONFIG_X86
 #ifdef CONFIG_ACPI_CUSTOM_DSDT
@@ -105,6 +106,22 @@ acpi_status acpi_bus_get_status_handle(acpi_handle handle,
 	return status;
 }
 
+static bool acpi_check_device_is_ignored(acpi_handle handle)
+{
+	acpi_status status;
+	u64 addr;
+
+	/* Check if it should ignore the UART device */
+	if (spcr_uart_addr != 0) {
+		status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL,
+					       &addr);
+		if (ACPI_SUCCESS(status) && addr == spcr_uart_addr)
+			return true;
+	}
+
+	return false;
+}
+
 int acpi_bus_get_status(struct acpi_device *device)
 {
 	acpi_status status;
@@ -114,7 +131,8 @@ int acpi_bus_get_status(struct acpi_device *device)
 	if (ACPI_FAILURE(status))
 		return -ENODEV;
 
-	acpi_set_device_status(device, sta);
+	if (!acpi_check_device_is_ignored(device->handle))
+		acpi_set_device_status(device, sta);
 
 	if (device->status.functional && !device->status.present) {
 		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]: "
@@ -1069,6 +1087,8 @@ EXPORT_SYMBOL_GPL(acpi_kobj);
 static int __init acpi_init(void)
 {
 	int result;
+	acpi_status status;
+	struct acpi_table_stao *stao_ptr;
 
 	if (acpi_disabled) {
 		printk(KERN_INFO PREFIX "Interpreter disabled.\n");
@@ -1081,6 +1101,20 @@ static int __init acpi_init(void)
 		acpi_kobj = NULL;
 	}
 
+	/* If there is STAO table, check whether it needs to ignore the UART
+	 * device in SPCR table.
+	 */
+	status = acpi_get_table(ACPI_SIG_STAO, 0,
+				(struct acpi_table_header **)&stao_ptr);
+	if (ACPI_SUCCESS(status) && stao_ptr->ignore_uart) {
+		struct acpi_table_spcr *spcr_ptr;
+
+		status = acpi_get_table(ACPI_SIG_SPCR, 0,
+					(struct acpi_table_header **)&spcr_ptr);
+		if (ACPI_SUCCESS(status))
+			spcr_uart_addr = spcr_ptr->serial_port.address;
+	}
+
 	init_acpi_device_notify();
 	result = acpi_bus_init();
 	if (result) {
-- 
2.0.4

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

* [PATCH v3 02/17] xen/grant-table: Move xlated_setup_gnttab_pages to common place
  2016-01-23  3:19 ` Shannon Zhao
  (?)
@ 2016-01-23  3:19   ` Shannon Zhao
  -1 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: catalin.marinas, will.deacon, julien.grall, xen-devel,
	devicetree, linux-efi, linux-kernel, ian.campbell, shannon.zhao,
	peter.huangpeng

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

Move xlated_setup_gnttab_pages to common place, so it can be reused by
ARM to setup grant table.

Rename it to xen_xlate_map_ballooned_pages.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
 arch/x86/xen/grant-table.c | 57 +++++--------------------------------------
 drivers/xen/xlate_mmu.c    | 61 ++++++++++++++++++++++++++++++++++++++++++++++
 include/xen/xen-ops.h      |  2 ++
 3 files changed, 69 insertions(+), 51 deletions(-)

diff --git a/arch/x86/xen/grant-table.c b/arch/x86/xen/grant-table.c
index e079500..de4144c 100644
--- a/arch/x86/xen/grant-table.c
+++ b/arch/x86/xen/grant-table.c
@@ -111,63 +111,18 @@ int arch_gnttab_init(unsigned long nr_shared)
 }
 
 #ifdef CONFIG_XEN_PVH
-#include <xen/balloon.h>
 #include <xen/events.h>
-#include <linux/slab.h>
-static int __init xlated_setup_gnttab_pages(void)
-{
-	struct page **pages;
-	xen_pfn_t *pfns;
-	void *vaddr;
-	int rc;
-	unsigned int i;
-	unsigned long nr_grant_frames = gnttab_max_grant_frames();
-
-	BUG_ON(nr_grant_frames == 0);
-	pages = kcalloc(nr_grant_frames, sizeof(pages[0]), GFP_KERNEL);
-	if (!pages)
-		return -ENOMEM;
-
-	pfns = kcalloc(nr_grant_frames, sizeof(pfns[0]), GFP_KERNEL);
-	if (!pfns) {
-		kfree(pages);
-		return -ENOMEM;
-	}
-	rc = alloc_xenballooned_pages(nr_grant_frames, pages);
-	if (rc) {
-		pr_warn("%s Couldn't balloon alloc %ld pfns rc:%d\n", __func__,
-			nr_grant_frames, rc);
-		kfree(pages);
-		kfree(pfns);
-		return rc;
-	}
-	for (i = 0; i < nr_grant_frames; i++)
-		pfns[i] = page_to_pfn(pages[i]);
-
-	vaddr = vmap(pages, nr_grant_frames, 0, PAGE_KERNEL);
-	if (!vaddr) {
-		pr_warn("%s Couldn't map %ld pfns rc:%d\n", __func__,
-			nr_grant_frames, rc);
-		free_xenballooned_pages(nr_grant_frames, pages);
-		kfree(pages);
-		kfree(pfns);
-		return -ENOMEM;
-	}
-	kfree(pages);
-
-	xen_auto_xlat_grant_frames.pfn = pfns;
-	xen_auto_xlat_grant_frames.count = nr_grant_frames;
-	xen_auto_xlat_grant_frames.vaddr = vaddr;
-
-	return 0;
-}
-
+#include <xen/xen-ops.h>
 static int __init xen_pvh_gnttab_setup(void)
 {
 	if (!xen_pvh_domain())
 		return -ENODEV;
 
-	return xlated_setup_gnttab_pages();
+	xen_auto_xlat_grant_frames.count = gnttab_max_grant_frames();
+
+	return xen_xlate_map_ballooned_pages(&xen_auto_xlat_grant_frames.pfn,
+					     &xen_auto_xlat_grant_frames.vaddr,
+					     xen_auto_xlat_grant_frames.count);
 }
 /* Call it _before_ __gnttab_init as we need to initialize the
  * xen_auto_xlat_grant_frames first. */
diff --git a/drivers/xen/xlate_mmu.c b/drivers/xen/xlate_mmu.c
index 5063c5e..9692656 100644
--- a/drivers/xen/xlate_mmu.c
+++ b/drivers/xen/xlate_mmu.c
@@ -29,6 +29,8 @@
  */
 #include <linux/kernel.h>
 #include <linux/mm.h>
+#include <linux/slab.h>
+#include <linux/vmalloc.h>
 
 #include <asm/xen/hypercall.h>
 #include <asm/xen/hypervisor.h>
@@ -37,6 +39,7 @@
 #include <xen/page.h>
 #include <xen/interface/xen.h>
 #include <xen/interface/memory.h>
+#include <xen/balloon.h>
 
 typedef void (*xen_gfn_fn_t)(unsigned long gfn, void *data);
 
@@ -185,3 +188,61 @@ int xen_xlate_unmap_gfn_range(struct vm_area_struct *vma,
 	return 0;
 }
 EXPORT_SYMBOL_GPL(xen_xlate_unmap_gfn_range);
+
+/**
+ * xen_xlate_map_ballooned_pages - map a new set of ballooned pages
+ * @gfns: returns the array of corresponding GFNs
+ * @virt: returns the virtual address of the mapped region
+ * @nr_grant_frames: number of GFNs
+ * @return 0 on success, error otherwise
+ *
+ * This allocates a set of ballooned pages and maps them into the
+ * kernel's address space.
+ */
+int __init xen_xlate_map_ballooned_pages(xen_pfn_t **gfns, void **virt,
+					 unsigned long nr_grant_frames)
+{
+	struct page **pages;
+	xen_pfn_t *pfns;
+	void *vaddr;
+	int rc;
+	unsigned int i;
+
+	BUG_ON(nr_grant_frames == 0);
+	pages = kcalloc(nr_grant_frames, sizeof(pages[0]), GFP_KERNEL);
+	if (!pages)
+		return -ENOMEM;
+
+	pfns = kcalloc(nr_grant_frames, sizeof(pfns[0]), GFP_KERNEL);
+	if (!pfns) {
+		kfree(pages);
+		return -ENOMEM;
+	}
+	rc = alloc_xenballooned_pages(nr_grant_frames, pages);
+	if (rc) {
+		pr_warn("%s Couldn't balloon alloc %ld pfns rc:%d\n", __func__,
+			nr_grant_frames, rc);
+		kfree(pages);
+		kfree(pfns);
+		return rc;
+	}
+	for (i = 0; i < nr_grant_frames; i++)
+		pfns[i] = page_to_pfn(pages[i]);
+
+	vaddr = vmap(pages, nr_grant_frames, 0, PAGE_KERNEL);
+	if (!vaddr) {
+		pr_warn("%s Couldn't map %ld pfns rc:%d\n", __func__,
+			nr_grant_frames, rc);
+		free_xenballooned_pages(nr_grant_frames, pages);
+		kfree(pages);
+		kfree(pfns);
+		return -ENOMEM;
+	}
+	kfree(pages);
+
+	*gfns = pfns;
+	*virt = vaddr;
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(xen_xlate_map_ballooned_pages);
diff --git a/include/xen/xen-ops.h b/include/xen/xen-ops.h
index e4e214a..42be31a 100644
--- a/include/xen/xen-ops.h
+++ b/include/xen/xen-ops.h
@@ -80,6 +80,8 @@ int xen_xlate_remap_gfn_array(struct vm_area_struct *vma,
 			      struct page **pages);
 int xen_xlate_unmap_gfn_range(struct vm_area_struct *vma,
 			      int nr, struct page **pages);
+int xen_xlate_map_ballooned_pages(xen_pfn_t **pfns, void **vaddr,
+				  unsigned long nr_grant_frames);
 
 bool xen_running_on_version_or_later(unsigned int major, unsigned int minor);
 
-- 
2.0.4

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

* [PATCH v3 02/17] xen/grant-table: Move xlated_setup_gnttab_pages to common place
@ 2016-01-23  3:19   ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: devicetree, linux-efi, ian.campbell, catalin.marinas,
	will.deacon, linux-kernel, xen-devel, julien.grall, shannon.zhao,
	peter.huangpeng

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

Move xlated_setup_gnttab_pages to common place, so it can be reused by
ARM to setup grant table.

Rename it to xen_xlate_map_ballooned_pages.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
 arch/x86/xen/grant-table.c | 57 +++++--------------------------------------
 drivers/xen/xlate_mmu.c    | 61 ++++++++++++++++++++++++++++++++++++++++++++++
 include/xen/xen-ops.h      |  2 ++
 3 files changed, 69 insertions(+), 51 deletions(-)

diff --git a/arch/x86/xen/grant-table.c b/arch/x86/xen/grant-table.c
index e079500..de4144c 100644
--- a/arch/x86/xen/grant-table.c
+++ b/arch/x86/xen/grant-table.c
@@ -111,63 +111,18 @@ int arch_gnttab_init(unsigned long nr_shared)
 }
 
 #ifdef CONFIG_XEN_PVH
-#include <xen/balloon.h>
 #include <xen/events.h>
-#include <linux/slab.h>
-static int __init xlated_setup_gnttab_pages(void)
-{
-	struct page **pages;
-	xen_pfn_t *pfns;
-	void *vaddr;
-	int rc;
-	unsigned int i;
-	unsigned long nr_grant_frames = gnttab_max_grant_frames();
-
-	BUG_ON(nr_grant_frames == 0);
-	pages = kcalloc(nr_grant_frames, sizeof(pages[0]), GFP_KERNEL);
-	if (!pages)
-		return -ENOMEM;
-
-	pfns = kcalloc(nr_grant_frames, sizeof(pfns[0]), GFP_KERNEL);
-	if (!pfns) {
-		kfree(pages);
-		return -ENOMEM;
-	}
-	rc = alloc_xenballooned_pages(nr_grant_frames, pages);
-	if (rc) {
-		pr_warn("%s Couldn't balloon alloc %ld pfns rc:%d\n", __func__,
-			nr_grant_frames, rc);
-		kfree(pages);
-		kfree(pfns);
-		return rc;
-	}
-	for (i = 0; i < nr_grant_frames; i++)
-		pfns[i] = page_to_pfn(pages[i]);
-
-	vaddr = vmap(pages, nr_grant_frames, 0, PAGE_KERNEL);
-	if (!vaddr) {
-		pr_warn("%s Couldn't map %ld pfns rc:%d\n", __func__,
-			nr_grant_frames, rc);
-		free_xenballooned_pages(nr_grant_frames, pages);
-		kfree(pages);
-		kfree(pfns);
-		return -ENOMEM;
-	}
-	kfree(pages);
-
-	xen_auto_xlat_grant_frames.pfn = pfns;
-	xen_auto_xlat_grant_frames.count = nr_grant_frames;
-	xen_auto_xlat_grant_frames.vaddr = vaddr;
-
-	return 0;
-}
-
+#include <xen/xen-ops.h>
 static int __init xen_pvh_gnttab_setup(void)
 {
 	if (!xen_pvh_domain())
 		return -ENODEV;
 
-	return xlated_setup_gnttab_pages();
+	xen_auto_xlat_grant_frames.count = gnttab_max_grant_frames();
+
+	return xen_xlate_map_ballooned_pages(&xen_auto_xlat_grant_frames.pfn,
+					     &xen_auto_xlat_grant_frames.vaddr,
+					     xen_auto_xlat_grant_frames.count);
 }
 /* Call it _before_ __gnttab_init as we need to initialize the
  * xen_auto_xlat_grant_frames first. */
diff --git a/drivers/xen/xlate_mmu.c b/drivers/xen/xlate_mmu.c
index 5063c5e..9692656 100644
--- a/drivers/xen/xlate_mmu.c
+++ b/drivers/xen/xlate_mmu.c
@@ -29,6 +29,8 @@
  */
 #include <linux/kernel.h>
 #include <linux/mm.h>
+#include <linux/slab.h>
+#include <linux/vmalloc.h>
 
 #include <asm/xen/hypercall.h>
 #include <asm/xen/hypervisor.h>
@@ -37,6 +39,7 @@
 #include <xen/page.h>
 #include <xen/interface/xen.h>
 #include <xen/interface/memory.h>
+#include <xen/balloon.h>
 
 typedef void (*xen_gfn_fn_t)(unsigned long gfn, void *data);
 
@@ -185,3 +188,61 @@ int xen_xlate_unmap_gfn_range(struct vm_area_struct *vma,
 	return 0;
 }
 EXPORT_SYMBOL_GPL(xen_xlate_unmap_gfn_range);
+
+/**
+ * xen_xlate_map_ballooned_pages - map a new set of ballooned pages
+ * @gfns: returns the array of corresponding GFNs
+ * @virt: returns the virtual address of the mapped region
+ * @nr_grant_frames: number of GFNs
+ * @return 0 on success, error otherwise
+ *
+ * This allocates a set of ballooned pages and maps them into the
+ * kernel's address space.
+ */
+int __init xen_xlate_map_ballooned_pages(xen_pfn_t **gfns, void **virt,
+					 unsigned long nr_grant_frames)
+{
+	struct page **pages;
+	xen_pfn_t *pfns;
+	void *vaddr;
+	int rc;
+	unsigned int i;
+
+	BUG_ON(nr_grant_frames == 0);
+	pages = kcalloc(nr_grant_frames, sizeof(pages[0]), GFP_KERNEL);
+	if (!pages)
+		return -ENOMEM;
+
+	pfns = kcalloc(nr_grant_frames, sizeof(pfns[0]), GFP_KERNEL);
+	if (!pfns) {
+		kfree(pages);
+		return -ENOMEM;
+	}
+	rc = alloc_xenballooned_pages(nr_grant_frames, pages);
+	if (rc) {
+		pr_warn("%s Couldn't balloon alloc %ld pfns rc:%d\n", __func__,
+			nr_grant_frames, rc);
+		kfree(pages);
+		kfree(pfns);
+		return rc;
+	}
+	for (i = 0; i < nr_grant_frames; i++)
+		pfns[i] = page_to_pfn(pages[i]);
+
+	vaddr = vmap(pages, nr_grant_frames, 0, PAGE_KERNEL);
+	if (!vaddr) {
+		pr_warn("%s Couldn't map %ld pfns rc:%d\n", __func__,
+			nr_grant_frames, rc);
+		free_xenballooned_pages(nr_grant_frames, pages);
+		kfree(pages);
+		kfree(pfns);
+		return -ENOMEM;
+	}
+	kfree(pages);
+
+	*gfns = pfns;
+	*virt = vaddr;
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(xen_xlate_map_ballooned_pages);
diff --git a/include/xen/xen-ops.h b/include/xen/xen-ops.h
index e4e214a..42be31a 100644
--- a/include/xen/xen-ops.h
+++ b/include/xen/xen-ops.h
@@ -80,6 +80,8 @@ int xen_xlate_remap_gfn_array(struct vm_area_struct *vma,
 			      struct page **pages);
 int xen_xlate_unmap_gfn_range(struct vm_area_struct *vma,
 			      int nr, struct page **pages);
+int xen_xlate_map_ballooned_pages(xen_pfn_t **pfns, void **vaddr,
+				  unsigned long nr_grant_frames);
 
 bool xen_running_on_version_or_later(unsigned int major, unsigned int minor);
 
-- 
2.0.4

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

* [PATCH v3 02/17] xen/grant-table: Move xlated_setup_gnttab_pages to common place
@ 2016-01-23  3:19   ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel

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

Move xlated_setup_gnttab_pages to common place, so it can be reused by
ARM to setup grant table.

Rename it to xen_xlate_map_ballooned_pages.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
 arch/x86/xen/grant-table.c | 57 +++++--------------------------------------
 drivers/xen/xlate_mmu.c    | 61 ++++++++++++++++++++++++++++++++++++++++++++++
 include/xen/xen-ops.h      |  2 ++
 3 files changed, 69 insertions(+), 51 deletions(-)

diff --git a/arch/x86/xen/grant-table.c b/arch/x86/xen/grant-table.c
index e079500..de4144c 100644
--- a/arch/x86/xen/grant-table.c
+++ b/arch/x86/xen/grant-table.c
@@ -111,63 +111,18 @@ int arch_gnttab_init(unsigned long nr_shared)
 }
 
 #ifdef CONFIG_XEN_PVH
-#include <xen/balloon.h>
 #include <xen/events.h>
-#include <linux/slab.h>
-static int __init xlated_setup_gnttab_pages(void)
-{
-	struct page **pages;
-	xen_pfn_t *pfns;
-	void *vaddr;
-	int rc;
-	unsigned int i;
-	unsigned long nr_grant_frames = gnttab_max_grant_frames();
-
-	BUG_ON(nr_grant_frames == 0);
-	pages = kcalloc(nr_grant_frames, sizeof(pages[0]), GFP_KERNEL);
-	if (!pages)
-		return -ENOMEM;
-
-	pfns = kcalloc(nr_grant_frames, sizeof(pfns[0]), GFP_KERNEL);
-	if (!pfns) {
-		kfree(pages);
-		return -ENOMEM;
-	}
-	rc = alloc_xenballooned_pages(nr_grant_frames, pages);
-	if (rc) {
-		pr_warn("%s Couldn't balloon alloc %ld pfns rc:%d\n", __func__,
-			nr_grant_frames, rc);
-		kfree(pages);
-		kfree(pfns);
-		return rc;
-	}
-	for (i = 0; i < nr_grant_frames; i++)
-		pfns[i] = page_to_pfn(pages[i]);
-
-	vaddr = vmap(pages, nr_grant_frames, 0, PAGE_KERNEL);
-	if (!vaddr) {
-		pr_warn("%s Couldn't map %ld pfns rc:%d\n", __func__,
-			nr_grant_frames, rc);
-		free_xenballooned_pages(nr_grant_frames, pages);
-		kfree(pages);
-		kfree(pfns);
-		return -ENOMEM;
-	}
-	kfree(pages);
-
-	xen_auto_xlat_grant_frames.pfn = pfns;
-	xen_auto_xlat_grant_frames.count = nr_grant_frames;
-	xen_auto_xlat_grant_frames.vaddr = vaddr;
-
-	return 0;
-}
-
+#include <xen/xen-ops.h>
 static int __init xen_pvh_gnttab_setup(void)
 {
 	if (!xen_pvh_domain())
 		return -ENODEV;
 
-	return xlated_setup_gnttab_pages();
+	xen_auto_xlat_grant_frames.count = gnttab_max_grant_frames();
+
+	return xen_xlate_map_ballooned_pages(&xen_auto_xlat_grant_frames.pfn,
+					     &xen_auto_xlat_grant_frames.vaddr,
+					     xen_auto_xlat_grant_frames.count);
 }
 /* Call it _before_ __gnttab_init as we need to initialize the
  * xen_auto_xlat_grant_frames first. */
diff --git a/drivers/xen/xlate_mmu.c b/drivers/xen/xlate_mmu.c
index 5063c5e..9692656 100644
--- a/drivers/xen/xlate_mmu.c
+++ b/drivers/xen/xlate_mmu.c
@@ -29,6 +29,8 @@
  */
 #include <linux/kernel.h>
 #include <linux/mm.h>
+#include <linux/slab.h>
+#include <linux/vmalloc.h>
 
 #include <asm/xen/hypercall.h>
 #include <asm/xen/hypervisor.h>
@@ -37,6 +39,7 @@
 #include <xen/page.h>
 #include <xen/interface/xen.h>
 #include <xen/interface/memory.h>
+#include <xen/balloon.h>
 
 typedef void (*xen_gfn_fn_t)(unsigned long gfn, void *data);
 
@@ -185,3 +188,61 @@ int xen_xlate_unmap_gfn_range(struct vm_area_struct *vma,
 	return 0;
 }
 EXPORT_SYMBOL_GPL(xen_xlate_unmap_gfn_range);
+
+/**
+ * xen_xlate_map_ballooned_pages - map a new set of ballooned pages
+ * @gfns: returns the array of corresponding GFNs
+ * @virt: returns the virtual address of the mapped region
+ * @nr_grant_frames: number of GFNs
+ * @return 0 on success, error otherwise
+ *
+ * This allocates a set of ballooned pages and maps them into the
+ * kernel's address space.
+ */
+int __init xen_xlate_map_ballooned_pages(xen_pfn_t **gfns, void **virt,
+					 unsigned long nr_grant_frames)
+{
+	struct page **pages;
+	xen_pfn_t *pfns;
+	void *vaddr;
+	int rc;
+	unsigned int i;
+
+	BUG_ON(nr_grant_frames == 0);
+	pages = kcalloc(nr_grant_frames, sizeof(pages[0]), GFP_KERNEL);
+	if (!pages)
+		return -ENOMEM;
+
+	pfns = kcalloc(nr_grant_frames, sizeof(pfns[0]), GFP_KERNEL);
+	if (!pfns) {
+		kfree(pages);
+		return -ENOMEM;
+	}
+	rc = alloc_xenballooned_pages(nr_grant_frames, pages);
+	if (rc) {
+		pr_warn("%s Couldn't balloon alloc %ld pfns rc:%d\n", __func__,
+			nr_grant_frames, rc);
+		kfree(pages);
+		kfree(pfns);
+		return rc;
+	}
+	for (i = 0; i < nr_grant_frames; i++)
+		pfns[i] = page_to_pfn(pages[i]);
+
+	vaddr = vmap(pages, nr_grant_frames, 0, PAGE_KERNEL);
+	if (!vaddr) {
+		pr_warn("%s Couldn't map %ld pfns rc:%d\n", __func__,
+			nr_grant_frames, rc);
+		free_xenballooned_pages(nr_grant_frames, pages);
+		kfree(pages);
+		kfree(pfns);
+		return -ENOMEM;
+	}
+	kfree(pages);
+
+	*gfns = pfns;
+	*virt = vaddr;
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(xen_xlate_map_ballooned_pages);
diff --git a/include/xen/xen-ops.h b/include/xen/xen-ops.h
index e4e214a..42be31a 100644
--- a/include/xen/xen-ops.h
+++ b/include/xen/xen-ops.h
@@ -80,6 +80,8 @@ int xen_xlate_remap_gfn_array(struct vm_area_struct *vma,
 			      struct page **pages);
 int xen_xlate_unmap_gfn_range(struct vm_area_struct *vma,
 			      int nr, struct page **pages);
+int xen_xlate_map_ballooned_pages(xen_pfn_t **pfns, void **vaddr,
+				  unsigned long nr_grant_frames);
 
 bool xen_running_on_version_or_later(unsigned int major, unsigned int minor);
 
-- 
2.0.4

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

* [PATCH v3 03/17] Xen: xlate: Use page_to_xen_pfn instead of page_to_pfn
@ 2016-01-23  3:19   ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: catalin.marinas, will.deacon, julien.grall, xen-devel,
	devicetree, linux-efi, linux-kernel, ian.campbell, shannon.zhao,
	peter.huangpeng

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

Use page_to_xen_pfn in case of 64KB page.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 drivers/xen/xlate_mmu.c | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/drivers/xen/xlate_mmu.c b/drivers/xen/xlate_mmu.c
index 9692656..28f728b 100644
--- a/drivers/xen/xlate_mmu.c
+++ b/drivers/xen/xlate_mmu.c
@@ -207,9 +207,12 @@ int __init xen_xlate_map_ballooned_pages(xen_pfn_t **gfns, void **virt,
 	void *vaddr;
 	int rc;
 	unsigned int i;
+	unsigned long nr_pages;
+	xen_pfn_t xen_pfn = 0;
 
 	BUG_ON(nr_grant_frames == 0);
-	pages = kcalloc(nr_grant_frames, sizeof(pages[0]), GFP_KERNEL);
+	nr_pages = DIV_ROUND_UP(nr_grant_frames, XEN_PFN_PER_PAGE);
+	pages = kcalloc(nr_pages, sizeof(pages[0]), GFP_KERNEL);
 	if (!pages)
 		return -ENOMEM;
 
@@ -218,22 +221,25 @@ int __init xen_xlate_map_ballooned_pages(xen_pfn_t **gfns, void **virt,
 		kfree(pages);
 		return -ENOMEM;
 	}
-	rc = alloc_xenballooned_pages(nr_grant_frames, pages);
+	rc = alloc_xenballooned_pages(nr_pages, pages);
 	if (rc) {
-		pr_warn("%s Couldn't balloon alloc %ld pfns rc:%d\n", __func__,
-			nr_grant_frames, rc);
+		pr_warn("%s Couldn't balloon alloc %ld pages rc:%d\n", __func__,
+			nr_pages, rc);
 		kfree(pages);
 		kfree(pfns);
 		return rc;
 	}
-	for (i = 0; i < nr_grant_frames; i++)
-		pfns[i] = page_to_pfn(pages[i]);
+	for (i = 0; i < nr_grant_frames; i++) {
+		if ((i % XEN_PFN_PER_PAGE) == 0)
+			xen_pfn = page_to_xen_pfn(pages[i / XEN_PFN_PER_PAGE]);
+		pfns[i] = pfn_to_gfn(xen_pfn++);
+	}
 
-	vaddr = vmap(pages, nr_grant_frames, 0, PAGE_KERNEL);
+	vaddr = vmap(pages, nr_pages, 0, PAGE_KERNEL);
 	if (!vaddr) {
-		pr_warn("%s Couldn't map %ld pfns rc:%d\n", __func__,
-			nr_grant_frames, rc);
-		free_xenballooned_pages(nr_grant_frames, pages);
+		pr_warn("%s Couldn't map %ld pages rc:%d\n", __func__,
+			nr_pages, rc);
+		free_xenballooned_pages(nr_pages, pages);
 		kfree(pages);
 		kfree(pfns);
 		return -ENOMEM;
-- 
2.0.4

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

* [PATCH v3 03/17] Xen: xlate: Use page_to_xen_pfn instead of page_to_pfn
@ 2016-01-23  3:19   ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	stefano.stabellini-Sxgqhf6Nn4DQT0dZR+AlfA,
	david.vrabel-Sxgqhf6Nn4DQT0dZR+AlfA
  Cc: catalin.marinas-5wv7dgnIgG8, will.deacon-5wv7dgnIgG8,
	julien.grall-Sxgqhf6Nn4DQT0dZR+AlfA,
	xen-devel-GuqFBffKawuEi8DpZVb4nw,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-efi-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	ian.campbell-Sxgqhf6Nn4DQT0dZR+AlfA,
	shannon.zhao-QSEj5FYQhm4dnm+yROfE0A,
	peter.huangpeng-hv44wF8Li93QT0dZR+AlfA

From: Shannon Zhao <shannon.zhao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>

Use page_to_xen_pfn in case of 64KB page.

Signed-off-by: Shannon Zhao <shannon.zhao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
 drivers/xen/xlate_mmu.c | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/drivers/xen/xlate_mmu.c b/drivers/xen/xlate_mmu.c
index 9692656..28f728b 100644
--- a/drivers/xen/xlate_mmu.c
+++ b/drivers/xen/xlate_mmu.c
@@ -207,9 +207,12 @@ int __init xen_xlate_map_ballooned_pages(xen_pfn_t **gfns, void **virt,
 	void *vaddr;
 	int rc;
 	unsigned int i;
+	unsigned long nr_pages;
+	xen_pfn_t xen_pfn = 0;
 
 	BUG_ON(nr_grant_frames == 0);
-	pages = kcalloc(nr_grant_frames, sizeof(pages[0]), GFP_KERNEL);
+	nr_pages = DIV_ROUND_UP(nr_grant_frames, XEN_PFN_PER_PAGE);
+	pages = kcalloc(nr_pages, sizeof(pages[0]), GFP_KERNEL);
 	if (!pages)
 		return -ENOMEM;
 
@@ -218,22 +221,25 @@ int __init xen_xlate_map_ballooned_pages(xen_pfn_t **gfns, void **virt,
 		kfree(pages);
 		return -ENOMEM;
 	}
-	rc = alloc_xenballooned_pages(nr_grant_frames, pages);
+	rc = alloc_xenballooned_pages(nr_pages, pages);
 	if (rc) {
-		pr_warn("%s Couldn't balloon alloc %ld pfns rc:%d\n", __func__,
-			nr_grant_frames, rc);
+		pr_warn("%s Couldn't balloon alloc %ld pages rc:%d\n", __func__,
+			nr_pages, rc);
 		kfree(pages);
 		kfree(pfns);
 		return rc;
 	}
-	for (i = 0; i < nr_grant_frames; i++)
-		pfns[i] = page_to_pfn(pages[i]);
+	for (i = 0; i < nr_grant_frames; i++) {
+		if ((i % XEN_PFN_PER_PAGE) == 0)
+			xen_pfn = page_to_xen_pfn(pages[i / XEN_PFN_PER_PAGE]);
+		pfns[i] = pfn_to_gfn(xen_pfn++);
+	}
 
-	vaddr = vmap(pages, nr_grant_frames, 0, PAGE_KERNEL);
+	vaddr = vmap(pages, nr_pages, 0, PAGE_KERNEL);
 	if (!vaddr) {
-		pr_warn("%s Couldn't map %ld pfns rc:%d\n", __func__,
-			nr_grant_frames, rc);
-		free_xenballooned_pages(nr_grant_frames, pages);
+		pr_warn("%s Couldn't map %ld pages rc:%d\n", __func__,
+			nr_pages, rc);
+		free_xenballooned_pages(nr_pages, pages);
 		kfree(pages);
 		kfree(pfns);
 		return -ENOMEM;
-- 
2.0.4


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v3 03/17] Xen: xlate: Use page_to_xen_pfn instead of page_to_pfn
@ 2016-01-23  3:19   ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel

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

Use page_to_xen_pfn in case of 64KB page.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 drivers/xen/xlate_mmu.c | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/drivers/xen/xlate_mmu.c b/drivers/xen/xlate_mmu.c
index 9692656..28f728b 100644
--- a/drivers/xen/xlate_mmu.c
+++ b/drivers/xen/xlate_mmu.c
@@ -207,9 +207,12 @@ int __init xen_xlate_map_ballooned_pages(xen_pfn_t **gfns, void **virt,
 	void *vaddr;
 	int rc;
 	unsigned int i;
+	unsigned long nr_pages;
+	xen_pfn_t xen_pfn = 0;
 
 	BUG_ON(nr_grant_frames == 0);
-	pages = kcalloc(nr_grant_frames, sizeof(pages[0]), GFP_KERNEL);
+	nr_pages = DIV_ROUND_UP(nr_grant_frames, XEN_PFN_PER_PAGE);
+	pages = kcalloc(nr_pages, sizeof(pages[0]), GFP_KERNEL);
 	if (!pages)
 		return -ENOMEM;
 
@@ -218,22 +221,25 @@ int __init xen_xlate_map_ballooned_pages(xen_pfn_t **gfns, void **virt,
 		kfree(pages);
 		return -ENOMEM;
 	}
-	rc = alloc_xenballooned_pages(nr_grant_frames, pages);
+	rc = alloc_xenballooned_pages(nr_pages, pages);
 	if (rc) {
-		pr_warn("%s Couldn't balloon alloc %ld pfns rc:%d\n", __func__,
-			nr_grant_frames, rc);
+		pr_warn("%s Couldn't balloon alloc %ld pages rc:%d\n", __func__,
+			nr_pages, rc);
 		kfree(pages);
 		kfree(pfns);
 		return rc;
 	}
-	for (i = 0; i < nr_grant_frames; i++)
-		pfns[i] = page_to_pfn(pages[i]);
+	for (i = 0; i < nr_grant_frames; i++) {
+		if ((i % XEN_PFN_PER_PAGE) == 0)
+			xen_pfn = page_to_xen_pfn(pages[i / XEN_PFN_PER_PAGE]);
+		pfns[i] = pfn_to_gfn(xen_pfn++);
+	}
 
-	vaddr = vmap(pages, nr_grant_frames, 0, PAGE_KERNEL);
+	vaddr = vmap(pages, nr_pages, 0, PAGE_KERNEL);
 	if (!vaddr) {
-		pr_warn("%s Couldn't map %ld pfns rc:%d\n", __func__,
-			nr_grant_frames, rc);
-		free_xenballooned_pages(nr_grant_frames, pages);
+		pr_warn("%s Couldn't map %ld pages rc:%d\n", __func__,
+			nr_pages, rc);
+		free_xenballooned_pages(nr_pages, pages);
 		kfree(pages);
 		kfree(pfns);
 		return -ENOMEM;
-- 
2.0.4

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

* [PATCH v3 03/17] Xen: xlate: Use page_to_xen_pfn instead of page_to_pfn
  2016-01-23  3:19 ` Shannon Zhao
                   ` (4 preceding siblings ...)
  (?)
@ 2016-01-23  3:19 ` Shannon Zhao
  -1 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: devicetree, linux-efi, ian.campbell, catalin.marinas,
	will.deacon, linux-kernel, xen-devel, julien.grall, shannon.zhao,
	peter.huangpeng

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

Use page_to_xen_pfn in case of 64KB page.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 drivers/xen/xlate_mmu.c | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/drivers/xen/xlate_mmu.c b/drivers/xen/xlate_mmu.c
index 9692656..28f728b 100644
--- a/drivers/xen/xlate_mmu.c
+++ b/drivers/xen/xlate_mmu.c
@@ -207,9 +207,12 @@ int __init xen_xlate_map_ballooned_pages(xen_pfn_t **gfns, void **virt,
 	void *vaddr;
 	int rc;
 	unsigned int i;
+	unsigned long nr_pages;
+	xen_pfn_t xen_pfn = 0;
 
 	BUG_ON(nr_grant_frames == 0);
-	pages = kcalloc(nr_grant_frames, sizeof(pages[0]), GFP_KERNEL);
+	nr_pages = DIV_ROUND_UP(nr_grant_frames, XEN_PFN_PER_PAGE);
+	pages = kcalloc(nr_pages, sizeof(pages[0]), GFP_KERNEL);
 	if (!pages)
 		return -ENOMEM;
 
@@ -218,22 +221,25 @@ int __init xen_xlate_map_ballooned_pages(xen_pfn_t **gfns, void **virt,
 		kfree(pages);
 		return -ENOMEM;
 	}
-	rc = alloc_xenballooned_pages(nr_grant_frames, pages);
+	rc = alloc_xenballooned_pages(nr_pages, pages);
 	if (rc) {
-		pr_warn("%s Couldn't balloon alloc %ld pfns rc:%d\n", __func__,
-			nr_grant_frames, rc);
+		pr_warn("%s Couldn't balloon alloc %ld pages rc:%d\n", __func__,
+			nr_pages, rc);
 		kfree(pages);
 		kfree(pfns);
 		return rc;
 	}
-	for (i = 0; i < nr_grant_frames; i++)
-		pfns[i] = page_to_pfn(pages[i]);
+	for (i = 0; i < nr_grant_frames; i++) {
+		if ((i % XEN_PFN_PER_PAGE) == 0)
+			xen_pfn = page_to_xen_pfn(pages[i / XEN_PFN_PER_PAGE]);
+		pfns[i] = pfn_to_gfn(xen_pfn++);
+	}
 
-	vaddr = vmap(pages, nr_grant_frames, 0, PAGE_KERNEL);
+	vaddr = vmap(pages, nr_pages, 0, PAGE_KERNEL);
 	if (!vaddr) {
-		pr_warn("%s Couldn't map %ld pfns rc:%d\n", __func__,
-			nr_grant_frames, rc);
-		free_xenballooned_pages(nr_grant_frames, pages);
+		pr_warn("%s Couldn't map %ld pages rc:%d\n", __func__,
+			nr_pages, rc);
+		free_xenballooned_pages(nr_pages, pages);
 		kfree(pages);
 		kfree(pfns);
 		return -ENOMEM;
-- 
2.0.4

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

* [PATCH v3 04/17] arm/xen: Use xen_xlate_map_ballooned_pages to setup grant table
  2016-01-23  3:19 ` Shannon Zhao
  (?)
@ 2016-01-23  3:19   ` Shannon Zhao
  -1 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: catalin.marinas, will.deacon, julien.grall, xen-devel,
	devicetree, linux-efi, linux-kernel, ian.campbell, shannon.zhao,
	peter.huangpeng

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

Use xen_xlate_map_ballooned_pages to setup grant table. Then it doesn't
rely on DT or ACPI to pass the start address and size of grant table.

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

diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
index afe6175..6d90a62 100644
--- a/arch/arm/xen/enlighten.c
+++ b/arch/arm/xen/enlighten.c
@@ -266,18 +266,10 @@ static int __init xen_guest_init(void)
 {
 	struct xen_add_to_physmap xatp;
 	struct shared_info *shared_info_page = NULL;
-	struct resource res;
-	phys_addr_t grant_frames;
 
 	if (!xen_domain())
 		return 0;
 
-	if (of_address_to_resource(xen_node, GRANT_TABLE_PHYSADDR, &res)) {
-		pr_err("Xen grant table base address not found\n");
-		return -ENODEV;
-	}
-	grant_frames = res.start;
-
 	xen_events_irq = irq_of_parse_and_map(xen_node, 0);
 	if (!xen_events_irq) {
 		pr_err("Xen event channel interrupt not found\n");
@@ -312,7 +304,10 @@ static int __init xen_guest_init(void)
 	if (xen_vcpu_info == NULL)
 		return -ENOMEM;
 
-	if (gnttab_setup_auto_xlat_frames(grant_frames)) {
+	xen_auto_xlat_grant_frames.count = gnttab_max_grant_frames();
+	if (xen_xlate_map_ballooned_pages(&xen_auto_xlat_grant_frames.pfn,
+					  &xen_auto_xlat_grant_frames.vaddr,
+					  xen_auto_xlat_grant_frames.count)) {
 		free_percpu(xen_vcpu_info);
 		return -ENOMEM;
 	}
-- 
2.0.4

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

* [PATCH v3 04/17] arm/xen: Use xen_xlate_map_ballooned_pages to setup grant table
@ 2016-01-23  3:19   ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: catalin.marinas, will.deacon, julien.grall, xen-devel,
	devicetree, linux-efi, linux-kernel, ian.campbell, shannon.zhao,
	peter.huangpeng

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

Use xen_xlate_map_ballooned_pages to setup grant table. Then it doesn't
rely on DT or ACPI to pass the start address and size of grant table.

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

diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
index afe6175..6d90a62 100644
--- a/arch/arm/xen/enlighten.c
+++ b/arch/arm/xen/enlighten.c
@@ -266,18 +266,10 @@ static int __init xen_guest_init(void)
 {
 	struct xen_add_to_physmap xatp;
 	struct shared_info *shared_info_page = NULL;
-	struct resource res;
-	phys_addr_t grant_frames;
 
 	if (!xen_domain())
 		return 0;
 
-	if (of_address_to_resource(xen_node, GRANT_TABLE_PHYSADDR, &res)) {
-		pr_err("Xen grant table base address not found\n");
-		return -ENODEV;
-	}
-	grant_frames = res.start;
-
 	xen_events_irq = irq_of_parse_and_map(xen_node, 0);
 	if (!xen_events_irq) {
 		pr_err("Xen event channel interrupt not found\n");
@@ -312,7 +304,10 @@ static int __init xen_guest_init(void)
 	if (xen_vcpu_info == NULL)
 		return -ENOMEM;
 
-	if (gnttab_setup_auto_xlat_frames(grant_frames)) {
+	xen_auto_xlat_grant_frames.count = gnttab_max_grant_frames();
+	if (xen_xlate_map_ballooned_pages(&xen_auto_xlat_grant_frames.pfn,
+					  &xen_auto_xlat_grant_frames.vaddr,
+					  xen_auto_xlat_grant_frames.count)) {
 		free_percpu(xen_vcpu_info);
 		return -ENOMEM;
 	}
-- 
2.0.4

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

* [PATCH v3 04/17] arm/xen: Use xen_xlate_map_ballooned_pages to setup grant table
@ 2016-01-23  3:19   ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel

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

Use xen_xlate_map_ballooned_pages to setup grant table. Then it doesn't
rely on DT or ACPI to pass the start address and size of grant table.

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

diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
index afe6175..6d90a62 100644
--- a/arch/arm/xen/enlighten.c
+++ b/arch/arm/xen/enlighten.c
@@ -266,18 +266,10 @@ static int __init xen_guest_init(void)
 {
 	struct xen_add_to_physmap xatp;
 	struct shared_info *shared_info_page = NULL;
-	struct resource res;
-	phys_addr_t grant_frames;
 
 	if (!xen_domain())
 		return 0;
 
-	if (of_address_to_resource(xen_node, GRANT_TABLE_PHYSADDR, &res)) {
-		pr_err("Xen grant table base address not found\n");
-		return -ENODEV;
-	}
-	grant_frames = res.start;
-
 	xen_events_irq = irq_of_parse_and_map(xen_node, 0);
 	if (!xen_events_irq) {
 		pr_err("Xen event channel interrupt not found\n");
@@ -312,7 +304,10 @@ static int __init xen_guest_init(void)
 	if (xen_vcpu_info == NULL)
 		return -ENOMEM;
 
-	if (gnttab_setup_auto_xlat_frames(grant_frames)) {
+	xen_auto_xlat_grant_frames.count = gnttab_max_grant_frames();
+	if (xen_xlate_map_ballooned_pages(&xen_auto_xlat_grant_frames.pfn,
+					  &xen_auto_xlat_grant_frames.vaddr,
+					  xen_auto_xlat_grant_frames.count)) {
 		free_percpu(xen_vcpu_info);
 		return -ENOMEM;
 	}
-- 
2.0.4

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

* [PATCH v3 04/17] arm/xen: Use xen_xlate_map_ballooned_pages to setup grant table
  2016-01-23  3:19 ` Shannon Zhao
                   ` (6 preceding siblings ...)
  (?)
@ 2016-01-23  3:19 ` Shannon Zhao
  -1 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: devicetree, linux-efi, ian.campbell, catalin.marinas,
	will.deacon, linux-kernel, xen-devel, julien.grall, shannon.zhao,
	peter.huangpeng

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

Use xen_xlate_map_ballooned_pages to setup grant table. Then it doesn't
rely on DT or ACPI to pass the start address and size of grant table.

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

diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
index afe6175..6d90a62 100644
--- a/arch/arm/xen/enlighten.c
+++ b/arch/arm/xen/enlighten.c
@@ -266,18 +266,10 @@ static int __init xen_guest_init(void)
 {
 	struct xen_add_to_physmap xatp;
 	struct shared_info *shared_info_page = NULL;
-	struct resource res;
-	phys_addr_t grant_frames;
 
 	if (!xen_domain())
 		return 0;
 
-	if (of_address_to_resource(xen_node, GRANT_TABLE_PHYSADDR, &res)) {
-		pr_err("Xen grant table base address not found\n");
-		return -ENODEV;
-	}
-	grant_frames = res.start;
-
 	xen_events_irq = irq_of_parse_and_map(xen_node, 0);
 	if (!xen_events_irq) {
 		pr_err("Xen event channel interrupt not found\n");
@@ -312,7 +304,10 @@ static int __init xen_guest_init(void)
 	if (xen_vcpu_info == NULL)
 		return -ENOMEM;
 
-	if (gnttab_setup_auto_xlat_frames(grant_frames)) {
+	xen_auto_xlat_grant_frames.count = gnttab_max_grant_frames();
+	if (xen_xlate_map_ballooned_pages(&xen_auto_xlat_grant_frames.pfn,
+					  &xen_auto_xlat_grant_frames.vaddr,
+					  xen_auto_xlat_grant_frames.count)) {
 		free_percpu(xen_vcpu_info);
 		return -ENOMEM;
 	}
-- 
2.0.4

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

* [PATCH v3 05/17] xen: memory : Add new XENMAPSPACE type XENMAPSPACE_dev_mmio
@ 2016-01-23  3:19   ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: catalin.marinas, will.deacon, julien.grall, xen-devel,
	devicetree, linux-efi, linux-kernel, ian.campbell, shannon.zhao,
	peter.huangpeng

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

Add a new type of Xen map space for Dom0 to map device's MMIO region.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 include/xen/interface/memory.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/xen/interface/memory.h b/include/xen/interface/memory.h
index 2ecfe4f..9aa8988 100644
--- a/include/xen/interface/memory.h
+++ b/include/xen/interface/memory.h
@@ -160,6 +160,7 @@ DEFINE_GUEST_HANDLE_STRUCT(xen_machphys_mapping_t);
 #define XENMAPSPACE_gmfn_foreign 4 /* GMFN from another dom,
 				    * XENMEM_add_to_physmap_range only.
 				    */
+#define XENMAPSPACE_dev_mmio     5 /* device mmio region */
 
 /*
  * Sets the GPFN at which a particular page appears in the specified guest's
-- 
2.0.4

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

* [PATCH v3 05/17] xen: memory : Add new XENMAPSPACE type XENMAPSPACE_dev_mmio
@ 2016-01-23  3:19   ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	stefano.stabellini-Sxgqhf6Nn4DQT0dZR+AlfA,
	david.vrabel-Sxgqhf6Nn4DQT0dZR+AlfA
  Cc: catalin.marinas-5wv7dgnIgG8, will.deacon-5wv7dgnIgG8,
	julien.grall-Sxgqhf6Nn4DQT0dZR+AlfA,
	xen-devel-GuqFBffKawuEi8DpZVb4nw,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-efi-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	ian.campbell-Sxgqhf6Nn4DQT0dZR+AlfA,
	shannon.zhao-QSEj5FYQhm4dnm+yROfE0A,
	peter.huangpeng-hv44wF8Li93QT0dZR+AlfA

From: Shannon Zhao <shannon.zhao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>

Add a new type of Xen map space for Dom0 to map device's MMIO region.

Signed-off-by: Shannon Zhao <shannon.zhao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
 include/xen/interface/memory.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/xen/interface/memory.h b/include/xen/interface/memory.h
index 2ecfe4f..9aa8988 100644
--- a/include/xen/interface/memory.h
+++ b/include/xen/interface/memory.h
@@ -160,6 +160,7 @@ DEFINE_GUEST_HANDLE_STRUCT(xen_machphys_mapping_t);
 #define XENMAPSPACE_gmfn_foreign 4 /* GMFN from another dom,
 				    * XENMEM_add_to_physmap_range only.
 				    */
+#define XENMAPSPACE_dev_mmio     5 /* device mmio region */
 
 /*
  * Sets the GPFN at which a particular page appears in the specified guest's
-- 
2.0.4


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v3 05/17] xen: memory : Add new XENMAPSPACE type XENMAPSPACE_dev_mmio
@ 2016-01-23  3:19   ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel

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

Add a new type of Xen map space for Dom0 to map device's MMIO region.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 include/xen/interface/memory.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/xen/interface/memory.h b/include/xen/interface/memory.h
index 2ecfe4f..9aa8988 100644
--- a/include/xen/interface/memory.h
+++ b/include/xen/interface/memory.h
@@ -160,6 +160,7 @@ DEFINE_GUEST_HANDLE_STRUCT(xen_machphys_mapping_t);
 #define XENMAPSPACE_gmfn_foreign 4 /* GMFN from another dom,
 				    * XENMEM_add_to_physmap_range only.
 				    */
+#define XENMAPSPACE_dev_mmio     5 /* device mmio region */
 
 /*
  * Sets the GPFN at which a particular page appears in the specified guest's
-- 
2.0.4

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

* [PATCH v3 05/17] xen: memory : Add new XENMAPSPACE type XENMAPSPACE_dev_mmio
  2016-01-23  3:19 ` Shannon Zhao
                   ` (8 preceding siblings ...)
  (?)
@ 2016-01-23  3:19 ` Shannon Zhao
  -1 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: devicetree, linux-efi, ian.campbell, catalin.marinas,
	will.deacon, linux-kernel, xen-devel, julien.grall, shannon.zhao,
	peter.huangpeng

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

Add a new type of Xen map space for Dom0 to map device's MMIO region.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 include/xen/interface/memory.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/xen/interface/memory.h b/include/xen/interface/memory.h
index 2ecfe4f..9aa8988 100644
--- a/include/xen/interface/memory.h
+++ b/include/xen/interface/memory.h
@@ -160,6 +160,7 @@ DEFINE_GUEST_HANDLE_STRUCT(xen_machphys_mapping_t);
 #define XENMAPSPACE_gmfn_foreign 4 /* GMFN from another dom,
 				    * XENMEM_add_to_physmap_range only.
 				    */
+#define XENMAPSPACE_dev_mmio     5 /* device mmio region */
 
 /*
  * Sets the GPFN at which a particular page appears in the specified guest's
-- 
2.0.4

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

* [PATCH v3 06/17] Xen: ARM: Add support for mapping platform device mmio
  2016-01-23  3:19 ` Shannon Zhao
  (?)
@ 2016-01-23  3:19   ` Shannon Zhao
  -1 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: catalin.marinas, will.deacon, julien.grall, xen-devel,
	devicetree, linux-efi, linux-kernel, ian.campbell, shannon.zhao,
	peter.huangpeng

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

Add a bus_notifier for platform bus device in order to map the device
mmio regions when DOM0 booting with ACPI.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
 drivers/xen/Makefile     |   1 +
 drivers/xen/arm-device.c | 141 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 142 insertions(+)
 create mode 100644 drivers/xen/arm-device.c

diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile
index aa8a7f7..0c087b1 100644
--- a/drivers/xen/Makefile
+++ b/drivers/xen/Makefile
@@ -9,6 +9,7 @@ CFLAGS_features.o			:= $(nostackp)
 
 CFLAGS_efi.o				+= -fshort-wchar
 
+dom0-$(CONFIG_ARM64) += arm-device.o
 dom0-$(CONFIG_PCI) += pci.o
 dom0-$(CONFIG_USB_SUPPORT) += dbgp.o
 dom0-$(CONFIG_XEN_ACPI) += acpi.o $(xen-pad-y)
diff --git a/drivers/xen/arm-device.c b/drivers/xen/arm-device.c
new file mode 100644
index 0000000..76e26e5
--- /dev/null
+++ b/drivers/xen/arm-device.c
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2015, Linaro Limited, Shannon Zhao
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <linux/platform_device.h>
+#include <linux/acpi.h>
+#include <xen/xen.h>
+#include <xen/page.h>
+#include <xen/interface/memory.h>
+#include <asm/xen/hypervisor.h>
+#include <asm/xen/hypercall.h>
+
+static int xen_unmap_device_mmio(struct resource *resource, unsigned int count)
+{
+	unsigned int i, j, nr;
+	int rc = 0;
+	struct resource *r;
+	struct xen_remove_from_physmap xrp;
+
+	for (i = 0; i < count; i++) {
+		r = &resource[i];
+		nr = DIV_ROUND_UP(resource_size(r), XEN_PAGE_SIZE);
+		if ((resource_type(r) != IORESOURCE_MEM) || (nr == 0))
+			continue;
+
+		for (j = 0; j < nr; j++) {
+			xrp.domid = DOMID_SELF;
+			xrp.gpfn = XEN_PFN_DOWN(r->start) + j;
+			rc = HYPERVISOR_memory_op(XENMEM_remove_from_physmap,
+						  &xrp);
+			if (rc)
+				return rc;
+		}
+	}
+
+	return rc;
+}
+
+static int xen_map_device_mmio(struct resource *resource, unsigned int count)
+{
+	unsigned int i, j, nr;
+	int rc = 0;
+	struct resource *r;
+	xen_pfn_t *gpfns;
+	xen_ulong_t *idxs;
+	int *errs;
+	struct xen_add_to_physmap_range xatp;
+
+	for (i = 0; i < count; i++) {
+		r = &resource[i];
+		nr = DIV_ROUND_UP(resource_size(r), XEN_PAGE_SIZE);
+		if ((resource_type(r) != IORESOURCE_MEM) || (nr == 0))
+			continue;
+
+		gpfns = kzalloc(sizeof(xen_pfn_t) * nr, GFP_KERNEL);
+		idxs = kzalloc(sizeof(xen_ulong_t) * nr, GFP_KERNEL);
+		errs = kzalloc(sizeof(int) * nr, GFP_KERNEL);
+		if (!gpfns || !idxs || !errs) {
+			kfree(gpfns);
+			kfree(idxs);
+			kfree(errs);
+			return -ENOMEM;
+		}
+
+		for (j = 0; j < nr; j++) {
+			gpfns[j] = XEN_PFN_DOWN(r->start) + j;
+			idxs[j] = XEN_PFN_DOWN(r->start) + j;
+		}
+
+		xatp.domid = DOMID_SELF;
+		xatp.size = nr;
+		xatp.space = XENMAPSPACE_dev_mmio;
+
+		set_xen_guest_handle(xatp.gpfns, gpfns);
+		set_xen_guest_handle(xatp.idxs, idxs);
+		set_xen_guest_handle(xatp.errs, errs);
+
+		rc = HYPERVISOR_memory_op(XENMEM_add_to_physmap_range, &xatp);
+		kfree(gpfns);
+		kfree(idxs);
+		kfree(errs);
+		if (rc)
+			return rc;
+	}
+
+	return rc;
+}
+
+static int xen_platform_notifier(struct notifier_block *nb,
+				 unsigned long action, void *data)
+{
+	struct platform_device *pdev = to_platform_device(data);
+	int r = 0;
+
+	if (pdev->num_resources == 0 || pdev->resource == NULL)
+		return NOTIFY_OK;
+
+	switch (action) {
+	case BUS_NOTIFY_ADD_DEVICE:
+		r = xen_map_device_mmio(pdev->resource, pdev->num_resources);
+		break;
+	case BUS_NOTIFY_DEL_DEVICE:
+		r = xen_unmap_device_mmio(pdev->resource, pdev->num_resources);
+		break;
+	default:
+		return NOTIFY_DONE;
+	}
+	if (r)
+		dev_err(&pdev->dev, "Platform: Failed to %s device %s MMIO!\n",
+			action == BUS_NOTIFY_ADD_DEVICE ? "map" :
+			(action == BUS_NOTIFY_DEL_DEVICE ? "unmap" : "?"),
+			pdev->name);
+
+	return NOTIFY_OK;
+}
+
+static struct notifier_block platform_device_nb = {
+	.notifier_call = xen_platform_notifier,
+};
+
+static int __init register_xen_platform_notifier(void)
+{
+	if (!xen_initial_domain() || acpi_disabled)
+		return 0;
+
+	return bus_register_notifier(&platform_bus_type, &platform_device_nb);
+}
+
+arch_initcall(register_xen_platform_notifier);
-- 
2.0.4

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

* [PATCH v3 06/17] Xen: ARM: Add support for mapping platform device mmio
@ 2016-01-23  3:19   ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: devicetree, linux-efi, ian.campbell, catalin.marinas,
	will.deacon, linux-kernel, xen-devel, julien.grall, shannon.zhao,
	peter.huangpeng

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

Add a bus_notifier for platform bus device in order to map the device
mmio regions when DOM0 booting with ACPI.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
 drivers/xen/Makefile     |   1 +
 drivers/xen/arm-device.c | 141 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 142 insertions(+)
 create mode 100644 drivers/xen/arm-device.c

diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile
index aa8a7f7..0c087b1 100644
--- a/drivers/xen/Makefile
+++ b/drivers/xen/Makefile
@@ -9,6 +9,7 @@ CFLAGS_features.o			:= $(nostackp)
 
 CFLAGS_efi.o				+= -fshort-wchar
 
+dom0-$(CONFIG_ARM64) += arm-device.o
 dom0-$(CONFIG_PCI) += pci.o
 dom0-$(CONFIG_USB_SUPPORT) += dbgp.o
 dom0-$(CONFIG_XEN_ACPI) += acpi.o $(xen-pad-y)
diff --git a/drivers/xen/arm-device.c b/drivers/xen/arm-device.c
new file mode 100644
index 0000000..76e26e5
--- /dev/null
+++ b/drivers/xen/arm-device.c
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2015, Linaro Limited, Shannon Zhao
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <linux/platform_device.h>
+#include <linux/acpi.h>
+#include <xen/xen.h>
+#include <xen/page.h>
+#include <xen/interface/memory.h>
+#include <asm/xen/hypervisor.h>
+#include <asm/xen/hypercall.h>
+
+static int xen_unmap_device_mmio(struct resource *resource, unsigned int count)
+{
+	unsigned int i, j, nr;
+	int rc = 0;
+	struct resource *r;
+	struct xen_remove_from_physmap xrp;
+
+	for (i = 0; i < count; i++) {
+		r = &resource[i];
+		nr = DIV_ROUND_UP(resource_size(r), XEN_PAGE_SIZE);
+		if ((resource_type(r) != IORESOURCE_MEM) || (nr == 0))
+			continue;
+
+		for (j = 0; j < nr; j++) {
+			xrp.domid = DOMID_SELF;
+			xrp.gpfn = XEN_PFN_DOWN(r->start) + j;
+			rc = HYPERVISOR_memory_op(XENMEM_remove_from_physmap,
+						  &xrp);
+			if (rc)
+				return rc;
+		}
+	}
+
+	return rc;
+}
+
+static int xen_map_device_mmio(struct resource *resource, unsigned int count)
+{
+	unsigned int i, j, nr;
+	int rc = 0;
+	struct resource *r;
+	xen_pfn_t *gpfns;
+	xen_ulong_t *idxs;
+	int *errs;
+	struct xen_add_to_physmap_range xatp;
+
+	for (i = 0; i < count; i++) {
+		r = &resource[i];
+		nr = DIV_ROUND_UP(resource_size(r), XEN_PAGE_SIZE);
+		if ((resource_type(r) != IORESOURCE_MEM) || (nr == 0))
+			continue;
+
+		gpfns = kzalloc(sizeof(xen_pfn_t) * nr, GFP_KERNEL);
+		idxs = kzalloc(sizeof(xen_ulong_t) * nr, GFP_KERNEL);
+		errs = kzalloc(sizeof(int) * nr, GFP_KERNEL);
+		if (!gpfns || !idxs || !errs) {
+			kfree(gpfns);
+			kfree(idxs);
+			kfree(errs);
+			return -ENOMEM;
+		}
+
+		for (j = 0; j < nr; j++) {
+			gpfns[j] = XEN_PFN_DOWN(r->start) + j;
+			idxs[j] = XEN_PFN_DOWN(r->start) + j;
+		}
+
+		xatp.domid = DOMID_SELF;
+		xatp.size = nr;
+		xatp.space = XENMAPSPACE_dev_mmio;
+
+		set_xen_guest_handle(xatp.gpfns, gpfns);
+		set_xen_guest_handle(xatp.idxs, idxs);
+		set_xen_guest_handle(xatp.errs, errs);
+
+		rc = HYPERVISOR_memory_op(XENMEM_add_to_physmap_range, &xatp);
+		kfree(gpfns);
+		kfree(idxs);
+		kfree(errs);
+		if (rc)
+			return rc;
+	}
+
+	return rc;
+}
+
+static int xen_platform_notifier(struct notifier_block *nb,
+				 unsigned long action, void *data)
+{
+	struct platform_device *pdev = to_platform_device(data);
+	int r = 0;
+
+	if (pdev->num_resources == 0 || pdev->resource == NULL)
+		return NOTIFY_OK;
+
+	switch (action) {
+	case BUS_NOTIFY_ADD_DEVICE:
+		r = xen_map_device_mmio(pdev->resource, pdev->num_resources);
+		break;
+	case BUS_NOTIFY_DEL_DEVICE:
+		r = xen_unmap_device_mmio(pdev->resource, pdev->num_resources);
+		break;
+	default:
+		return NOTIFY_DONE;
+	}
+	if (r)
+		dev_err(&pdev->dev, "Platform: Failed to %s device %s MMIO!\n",
+			action == BUS_NOTIFY_ADD_DEVICE ? "map" :
+			(action == BUS_NOTIFY_DEL_DEVICE ? "unmap" : "?"),
+			pdev->name);
+
+	return NOTIFY_OK;
+}
+
+static struct notifier_block platform_device_nb = {
+	.notifier_call = xen_platform_notifier,
+};
+
+static int __init register_xen_platform_notifier(void)
+{
+	if (!xen_initial_domain() || acpi_disabled)
+		return 0;
+
+	return bus_register_notifier(&platform_bus_type, &platform_device_nb);
+}
+
+arch_initcall(register_xen_platform_notifier);
-- 
2.0.4

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

* [PATCH v3 06/17] Xen: ARM: Add support for mapping platform device mmio
@ 2016-01-23  3:19   ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel

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

Add a bus_notifier for platform bus device in order to map the device
mmio regions when DOM0 booting with ACPI.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
 drivers/xen/Makefile     |   1 +
 drivers/xen/arm-device.c | 141 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 142 insertions(+)
 create mode 100644 drivers/xen/arm-device.c

diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile
index aa8a7f7..0c087b1 100644
--- a/drivers/xen/Makefile
+++ b/drivers/xen/Makefile
@@ -9,6 +9,7 @@ CFLAGS_features.o			:= $(nostackp)
 
 CFLAGS_efi.o				+= -fshort-wchar
 
+dom0-$(CONFIG_ARM64) += arm-device.o
 dom0-$(CONFIG_PCI) += pci.o
 dom0-$(CONFIG_USB_SUPPORT) += dbgp.o
 dom0-$(CONFIG_XEN_ACPI) += acpi.o $(xen-pad-y)
diff --git a/drivers/xen/arm-device.c b/drivers/xen/arm-device.c
new file mode 100644
index 0000000..76e26e5
--- /dev/null
+++ b/drivers/xen/arm-device.c
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2015, Linaro Limited, Shannon Zhao
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <linux/platform_device.h>
+#include <linux/acpi.h>
+#include <xen/xen.h>
+#include <xen/page.h>
+#include <xen/interface/memory.h>
+#include <asm/xen/hypervisor.h>
+#include <asm/xen/hypercall.h>
+
+static int xen_unmap_device_mmio(struct resource *resource, unsigned int count)
+{
+	unsigned int i, j, nr;
+	int rc = 0;
+	struct resource *r;
+	struct xen_remove_from_physmap xrp;
+
+	for (i = 0; i < count; i++) {
+		r = &resource[i];
+		nr = DIV_ROUND_UP(resource_size(r), XEN_PAGE_SIZE);
+		if ((resource_type(r) != IORESOURCE_MEM) || (nr == 0))
+			continue;
+
+		for (j = 0; j < nr; j++) {
+			xrp.domid = DOMID_SELF;
+			xrp.gpfn = XEN_PFN_DOWN(r->start) + j;
+			rc = HYPERVISOR_memory_op(XENMEM_remove_from_physmap,
+						  &xrp);
+			if (rc)
+				return rc;
+		}
+	}
+
+	return rc;
+}
+
+static int xen_map_device_mmio(struct resource *resource, unsigned int count)
+{
+	unsigned int i, j, nr;
+	int rc = 0;
+	struct resource *r;
+	xen_pfn_t *gpfns;
+	xen_ulong_t *idxs;
+	int *errs;
+	struct xen_add_to_physmap_range xatp;
+
+	for (i = 0; i < count; i++) {
+		r = &resource[i];
+		nr = DIV_ROUND_UP(resource_size(r), XEN_PAGE_SIZE);
+		if ((resource_type(r) != IORESOURCE_MEM) || (nr == 0))
+			continue;
+
+		gpfns = kzalloc(sizeof(xen_pfn_t) * nr, GFP_KERNEL);
+		idxs = kzalloc(sizeof(xen_ulong_t) * nr, GFP_KERNEL);
+		errs = kzalloc(sizeof(int) * nr, GFP_KERNEL);
+		if (!gpfns || !idxs || !errs) {
+			kfree(gpfns);
+			kfree(idxs);
+			kfree(errs);
+			return -ENOMEM;
+		}
+
+		for (j = 0; j < nr; j++) {
+			gpfns[j] = XEN_PFN_DOWN(r->start) + j;
+			idxs[j] = XEN_PFN_DOWN(r->start) + j;
+		}
+
+		xatp.domid = DOMID_SELF;
+		xatp.size = nr;
+		xatp.space = XENMAPSPACE_dev_mmio;
+
+		set_xen_guest_handle(xatp.gpfns, gpfns);
+		set_xen_guest_handle(xatp.idxs, idxs);
+		set_xen_guest_handle(xatp.errs, errs);
+
+		rc = HYPERVISOR_memory_op(XENMEM_add_to_physmap_range, &xatp);
+		kfree(gpfns);
+		kfree(idxs);
+		kfree(errs);
+		if (rc)
+			return rc;
+	}
+
+	return rc;
+}
+
+static int xen_platform_notifier(struct notifier_block *nb,
+				 unsigned long action, void *data)
+{
+	struct platform_device *pdev = to_platform_device(data);
+	int r = 0;
+
+	if (pdev->num_resources == 0 || pdev->resource == NULL)
+		return NOTIFY_OK;
+
+	switch (action) {
+	case BUS_NOTIFY_ADD_DEVICE:
+		r = xen_map_device_mmio(pdev->resource, pdev->num_resources);
+		break;
+	case BUS_NOTIFY_DEL_DEVICE:
+		r = xen_unmap_device_mmio(pdev->resource, pdev->num_resources);
+		break;
+	default:
+		return NOTIFY_DONE;
+	}
+	if (r)
+		dev_err(&pdev->dev, "Platform: Failed to %s device %s MMIO!\n",
+			action == BUS_NOTIFY_ADD_DEVICE ? "map" :
+			(action == BUS_NOTIFY_DEL_DEVICE ? "unmap" : "?"),
+			pdev->name);
+
+	return NOTIFY_OK;
+}
+
+static struct notifier_block platform_device_nb = {
+	.notifier_call = xen_platform_notifier,
+};
+
+static int __init register_xen_platform_notifier(void)
+{
+	if (!xen_initial_domain() || acpi_disabled)
+		return 0;
+
+	return bus_register_notifier(&platform_bus_type, &platform_device_nb);
+}
+
+arch_initcall(register_xen_platform_notifier);
-- 
2.0.4

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

* [PATCH v3 07/17] Xen: ARM: Add support for mapping AMBA device mmio
  2016-01-23  3:19 ` Shannon Zhao
  (?)
@ 2016-01-23  3:19   ` Shannon Zhao
  -1 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: catalin.marinas, will.deacon, julien.grall, xen-devel,
	devicetree, linux-efi, linux-kernel, ian.campbell, shannon.zhao,
	peter.huangpeng

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

Add a bus_notifier for AMBA bus device in order to map the device
mmio regions when DOM0 booting with ACPI.

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

diff --git a/drivers/xen/arm-device.c b/drivers/xen/arm-device.c
index 76e26e5..3854043 100644
--- a/drivers/xen/arm-device.c
+++ b/drivers/xen/arm-device.c
@@ -139,3 +139,46 @@ static int __init register_xen_platform_notifier(void)
 }
 
 arch_initcall(register_xen_platform_notifier);
+
+#ifdef CONFIG_ARM_AMBA
+#include <linux/amba/bus.h>
+
+static int xen_amba_notifier(struct notifier_block *nb,
+			     unsigned long action, void *data)
+{
+	struct amba_device *adev = to_amba_device(data);
+	int r = 0;
+
+	switch (action) {
+	case BUS_NOTIFY_ADD_DEVICE:
+		r = xen_map_device_mmio(&adev->res, 1);
+		break;
+	case BUS_NOTIFY_DEL_DEVICE:
+		r = xen_unmap_device_mmio(&adev->res, 1);
+		break;
+	default:
+		return NOTIFY_DONE;
+	}
+	if (r)
+		dev_err(&adev->dev, "AMBA: Failed to %s device %s MMIO!\n",
+			action == BUS_NOTIFY_ADD_DEVICE ? "map" :
+			(action == BUS_NOTIFY_DEL_DEVICE ? "unmap" : "?"),
+			adev->dev.init_name);
+
+	return NOTIFY_OK;
+}
+
+static struct notifier_block amba_device_nb = {
+	.notifier_call = xen_amba_notifier,
+};
+
+static int __init register_xen_amba_notifier(void)
+{
+	if (!xen_initial_domain() || acpi_disabled)
+		return 0;
+
+	return bus_register_notifier(&amba_bustype, &amba_device_nb);
+}
+
+arch_initcall(register_xen_amba_notifier);
+#endif
-- 
2.0.4

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

* [PATCH v3 07/17] Xen: ARM: Add support for mapping AMBA device mmio
@ 2016-01-23  3:19   ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: devicetree, linux-efi, ian.campbell, catalin.marinas,
	will.deacon, linux-kernel, xen-devel, julien.grall, shannon.zhao,
	peter.huangpeng

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

Add a bus_notifier for AMBA bus device in order to map the device
mmio regions when DOM0 booting with ACPI.

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

diff --git a/drivers/xen/arm-device.c b/drivers/xen/arm-device.c
index 76e26e5..3854043 100644
--- a/drivers/xen/arm-device.c
+++ b/drivers/xen/arm-device.c
@@ -139,3 +139,46 @@ static int __init register_xen_platform_notifier(void)
 }
 
 arch_initcall(register_xen_platform_notifier);
+
+#ifdef CONFIG_ARM_AMBA
+#include <linux/amba/bus.h>
+
+static int xen_amba_notifier(struct notifier_block *nb,
+			     unsigned long action, void *data)
+{
+	struct amba_device *adev = to_amba_device(data);
+	int r = 0;
+
+	switch (action) {
+	case BUS_NOTIFY_ADD_DEVICE:
+		r = xen_map_device_mmio(&adev->res, 1);
+		break;
+	case BUS_NOTIFY_DEL_DEVICE:
+		r = xen_unmap_device_mmio(&adev->res, 1);
+		break;
+	default:
+		return NOTIFY_DONE;
+	}
+	if (r)
+		dev_err(&adev->dev, "AMBA: Failed to %s device %s MMIO!\n",
+			action == BUS_NOTIFY_ADD_DEVICE ? "map" :
+			(action == BUS_NOTIFY_DEL_DEVICE ? "unmap" : "?"),
+			adev->dev.init_name);
+
+	return NOTIFY_OK;
+}
+
+static struct notifier_block amba_device_nb = {
+	.notifier_call = xen_amba_notifier,
+};
+
+static int __init register_xen_amba_notifier(void)
+{
+	if (!xen_initial_domain() || acpi_disabled)
+		return 0;
+
+	return bus_register_notifier(&amba_bustype, &amba_device_nb);
+}
+
+arch_initcall(register_xen_amba_notifier);
+#endif
-- 
2.0.4

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

* [PATCH v3 07/17] Xen: ARM: Add support for mapping AMBA device mmio
@ 2016-01-23  3:19   ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel

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

Add a bus_notifier for AMBA bus device in order to map the device
mmio regions when DOM0 booting with ACPI.

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

diff --git a/drivers/xen/arm-device.c b/drivers/xen/arm-device.c
index 76e26e5..3854043 100644
--- a/drivers/xen/arm-device.c
+++ b/drivers/xen/arm-device.c
@@ -139,3 +139,46 @@ static int __init register_xen_platform_notifier(void)
 }
 
 arch_initcall(register_xen_platform_notifier);
+
+#ifdef CONFIG_ARM_AMBA
+#include <linux/amba/bus.h>
+
+static int xen_amba_notifier(struct notifier_block *nb,
+			     unsigned long action, void *data)
+{
+	struct amba_device *adev = to_amba_device(data);
+	int r = 0;
+
+	switch (action) {
+	case BUS_NOTIFY_ADD_DEVICE:
+		r = xen_map_device_mmio(&adev->res, 1);
+		break;
+	case BUS_NOTIFY_DEL_DEVICE:
+		r = xen_unmap_device_mmio(&adev->res, 1);
+		break;
+	default:
+		return NOTIFY_DONE;
+	}
+	if (r)
+		dev_err(&adev->dev, "AMBA: Failed to %s device %s MMIO!\n",
+			action == BUS_NOTIFY_ADD_DEVICE ? "map" :
+			(action == BUS_NOTIFY_DEL_DEVICE ? "unmap" : "?"),
+			adev->dev.init_name);
+
+	return NOTIFY_OK;
+}
+
+static struct notifier_block amba_device_nb = {
+	.notifier_call = xen_amba_notifier,
+};
+
+static int __init register_xen_amba_notifier(void)
+{
+	if (!xen_initial_domain() || acpi_disabled)
+		return 0;
+
+	return bus_register_notifier(&amba_bustype, &amba_device_nb);
+}
+
+arch_initcall(register_xen_amba_notifier);
+#endif
-- 
2.0.4

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

* [PATCH v3 08/17] Xen: public/hvm: sync changes of HVM_PARAM_CALLBACK_VIA ABI from Xen
  2016-01-23  3:19 ` Shannon Zhao
  (?)
@ 2016-01-23  3:19   ` Shannon Zhao
  -1 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: catalin.marinas, will.deacon, julien.grall, xen-devel,
	devicetree, linux-efi, linux-kernel, ian.campbell, shannon.zhao,
	peter.huangpeng

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

Sync the changes of HVM_PARAM_CALLBACK_VIA ABI introduced by
Xen commit <ca5c54b6ff05> (public/hvm: export the HVM_PARAM_CALLBACK_VIA
ABI in the API).

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

diff --git a/include/xen/interface/hvm/params.h b/include/xen/interface/hvm/params.h
index a6c7991..70ad208 100644
--- a/include/xen/interface/hvm/params.h
+++ b/include/xen/interface/hvm/params.h
@@ -27,16 +27,31 @@
  * Parameter space for HVMOP_{set,get}_param.
  */
 
+#define HVM_PARAM_CALLBACK_IRQ 0
 /*
  * How should CPU0 event-channel notifications be delivered?
- * val[63:56] == 0: val[55:0] is a delivery GSI (Global System Interrupt).
- * val[63:56] == 1: val[55:0] is a delivery PCI INTx line, as follows:
- *                  Domain = val[47:32], Bus  = val[31:16],
- *                  DevFn  = val[15: 8], IntX = val[ 1: 0]
- * val[63:56] == 2: val[7:0] is a vector number.
+ *
  * If val == 0 then CPU0 event-channel notifications are not delivered.
+ * If val != 0, val[63:56] encodes the type, as follows:
+ */
+
+#define HVM_PARAM_CALLBACK_TYPE_GSI      0
+/*
+ * val[55:0] is a delivery GSI.  GSI 0 cannot be used, as it aliases val == 0,
+ * and disables all notifications.
+ */
+
+#define HVM_PARAM_CALLBACK_TYPE_PCI_INTX 1
+/*
+ * val[55:0] is a delivery PCI INTx line:
+ * Domain = val[47:32], Bus = val[31:16] DevFn = val[15:8], IntX = val[1:0]
+ */
+
+#define HVM_PARAM_CALLBACK_TYPE_VECTOR   2
+/*
+ * val[7:0] is a vector number.  Check for XENFEAT_hvm_callback_vector to know
+ * if this delivery method is available.
  */
-#define HVM_PARAM_CALLBACK_IRQ 0
 
 #define HVM_PARAM_STORE_PFN    1
 #define HVM_PARAM_STORE_EVTCHN 2
-- 
2.0.4

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

* [PATCH v3 08/17] Xen: public/hvm: sync changes of HVM_PARAM_CALLBACK_VIA ABI from Xen
@ 2016-01-23  3:19   ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: devicetree, linux-efi, ian.campbell, catalin.marinas,
	will.deacon, linux-kernel, xen-devel, julien.grall, shannon.zhao,
	peter.huangpeng

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

Sync the changes of HVM_PARAM_CALLBACK_VIA ABI introduced by
Xen commit <ca5c54b6ff05> (public/hvm: export the HVM_PARAM_CALLBACK_VIA
ABI in the API).

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

diff --git a/include/xen/interface/hvm/params.h b/include/xen/interface/hvm/params.h
index a6c7991..70ad208 100644
--- a/include/xen/interface/hvm/params.h
+++ b/include/xen/interface/hvm/params.h
@@ -27,16 +27,31 @@
  * Parameter space for HVMOP_{set,get}_param.
  */
 
+#define HVM_PARAM_CALLBACK_IRQ 0
 /*
  * How should CPU0 event-channel notifications be delivered?
- * val[63:56] == 0: val[55:0] is a delivery GSI (Global System Interrupt).
- * val[63:56] == 1: val[55:0] is a delivery PCI INTx line, as follows:
- *                  Domain = val[47:32], Bus  = val[31:16],
- *                  DevFn  = val[15: 8], IntX = val[ 1: 0]
- * val[63:56] == 2: val[7:0] is a vector number.
+ *
  * If val == 0 then CPU0 event-channel notifications are not delivered.
+ * If val != 0, val[63:56] encodes the type, as follows:
+ */
+
+#define HVM_PARAM_CALLBACK_TYPE_GSI      0
+/*
+ * val[55:0] is a delivery GSI.  GSI 0 cannot be used, as it aliases val == 0,
+ * and disables all notifications.
+ */
+
+#define HVM_PARAM_CALLBACK_TYPE_PCI_INTX 1
+/*
+ * val[55:0] is a delivery PCI INTx line:
+ * Domain = val[47:32], Bus = val[31:16] DevFn = val[15:8], IntX = val[1:0]
+ */
+
+#define HVM_PARAM_CALLBACK_TYPE_VECTOR   2
+/*
+ * val[7:0] is a vector number.  Check for XENFEAT_hvm_callback_vector to know
+ * if this delivery method is available.
  */
-#define HVM_PARAM_CALLBACK_IRQ 0
 
 #define HVM_PARAM_STORE_PFN    1
 #define HVM_PARAM_STORE_EVTCHN 2
-- 
2.0.4

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

* [PATCH v3 08/17] Xen: public/hvm: sync changes of HVM_PARAM_CALLBACK_VIA ABI from Xen
@ 2016-01-23  3:19   ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel

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

Sync the changes of HVM_PARAM_CALLBACK_VIA ABI introduced by
Xen commit <ca5c54b6ff05> (public/hvm: export the HVM_PARAM_CALLBACK_VIA
ABI in the API).

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

diff --git a/include/xen/interface/hvm/params.h b/include/xen/interface/hvm/params.h
index a6c7991..70ad208 100644
--- a/include/xen/interface/hvm/params.h
+++ b/include/xen/interface/hvm/params.h
@@ -27,16 +27,31 @@
  * Parameter space for HVMOP_{set,get}_param.
  */
 
+#define HVM_PARAM_CALLBACK_IRQ 0
 /*
  * How should CPU0 event-channel notifications be delivered?
- * val[63:56] == 0: val[55:0] is a delivery GSI (Global System Interrupt).
- * val[63:56] == 1: val[55:0] is a delivery PCI INTx line, as follows:
- *                  Domain = val[47:32], Bus  = val[31:16],
- *                  DevFn  = val[15: 8], IntX = val[ 1: 0]
- * val[63:56] == 2: val[7:0] is a vector number.
+ *
  * If val == 0 then CPU0 event-channel notifications are not delivered.
+ * If val != 0, val[63:56] encodes the type, as follows:
+ */
+
+#define HVM_PARAM_CALLBACK_TYPE_GSI      0
+/*
+ * val[55:0] is a delivery GSI.  GSI 0 cannot be used, as it aliases val == 0,
+ * and disables all notifications.
+ */
+
+#define HVM_PARAM_CALLBACK_TYPE_PCI_INTX 1
+/*
+ * val[55:0] is a delivery PCI INTx line:
+ * Domain = val[47:32], Bus = val[31:16] DevFn = val[15:8], IntX = val[1:0]
+ */
+
+#define HVM_PARAM_CALLBACK_TYPE_VECTOR   2
+/*
+ * val[7:0] is a vector number.  Check for XENFEAT_hvm_callback_vector to know
+ * if this delivery method is available.
  */
-#define HVM_PARAM_CALLBACK_IRQ 0
 
 #define HVM_PARAM_STORE_PFN    1
 #define HVM_PARAM_STORE_EVTCHN 2
-- 
2.0.4

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

* [PATCH v3 09/17] xen/hvm/params: Add a new delivery type for event-channel in HVM_PARAM_CALLBACK_IRQ
@ 2016-01-23  3:19   ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: catalin.marinas, will.deacon, julien.grall, xen-devel,
	devicetree, linux-efi, linux-kernel, ian.campbell, shannon.zhao,
	peter.huangpeng

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

Add a new delivery 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>
---
 include/xen/interface/hvm/params.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/include/xen/interface/hvm/params.h b/include/xen/interface/hvm/params.h
index 70ad208..5dd629f 100644
--- a/include/xen/interface/hvm/params.h
+++ b/include/xen/interface/hvm/params.h
@@ -53,6 +53,15 @@
  * if this delivery method is available.
  */
 
+#define HVM_PARAM_CALLBACK_TYPE_EVENT    3
+/*
+ * val[15:8] is flag of event-channel interrupt:
+ *  bit 0: interrupt is edge(1) or level(0) triggered
+ *  bit 1: interrupt is active low(1) or high(0)
+ * val[7:0] is PPI number used by event-channel.
+ * This is only used by ARM/ARM64.
+ */
+
 #define HVM_PARAM_STORE_PFN    1
 #define HVM_PARAM_STORE_EVTCHN 2
 
-- 
2.0.4

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

* [PATCH v3 09/17] xen/hvm/params: Add a new delivery type for event-channel in HVM_PARAM_CALLBACK_IRQ
@ 2016-01-23  3:19   ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	stefano.stabellini-Sxgqhf6Nn4DQT0dZR+AlfA,
	david.vrabel-Sxgqhf6Nn4DQT0dZR+AlfA
  Cc: catalin.marinas-5wv7dgnIgG8, will.deacon-5wv7dgnIgG8,
	julien.grall-Sxgqhf6Nn4DQT0dZR+AlfA,
	xen-devel-GuqFBffKawuEi8DpZVb4nw,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-efi-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	ian.campbell-Sxgqhf6Nn4DQT0dZR+AlfA,
	shannon.zhao-QSEj5FYQhm4dnm+yROfE0A,
	peter.huangpeng-hv44wF8Li93QT0dZR+AlfA

From: Shannon Zhao <shannon.zhao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>

Add a new delivery 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-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
 include/xen/interface/hvm/params.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/include/xen/interface/hvm/params.h b/include/xen/interface/hvm/params.h
index 70ad208..5dd629f 100644
--- a/include/xen/interface/hvm/params.h
+++ b/include/xen/interface/hvm/params.h
@@ -53,6 +53,15 @@
  * if this delivery method is available.
  */
 
+#define HVM_PARAM_CALLBACK_TYPE_EVENT    3
+/*
+ * val[15:8] is flag of event-channel interrupt:
+ *  bit 0: interrupt is edge(1) or level(0) triggered
+ *  bit 1: interrupt is active low(1) or high(0)
+ * val[7:0] is PPI number used by event-channel.
+ * This is only used by ARM/ARM64.
+ */
+
 #define HVM_PARAM_STORE_PFN    1
 #define HVM_PARAM_STORE_EVTCHN 2
 
-- 
2.0.4


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v3 09/17] xen/hvm/params: Add a new delivery type for event-channel in HVM_PARAM_CALLBACK_IRQ
@ 2016-01-23  3:19   ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel

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

Add a new delivery 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>
---
 include/xen/interface/hvm/params.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/include/xen/interface/hvm/params.h b/include/xen/interface/hvm/params.h
index 70ad208..5dd629f 100644
--- a/include/xen/interface/hvm/params.h
+++ b/include/xen/interface/hvm/params.h
@@ -53,6 +53,15 @@
  * if this delivery method is available.
  */
 
+#define HVM_PARAM_CALLBACK_TYPE_EVENT    3
+/*
+ * val[15:8] is flag of event-channel interrupt:
+ *  bit 0: interrupt is edge(1) or level(0) triggered
+ *  bit 1: interrupt is active low(1) or high(0)
+ * val[7:0] is PPI number used by event-channel.
+ * This is only used by ARM/ARM64.
+ */
+
 #define HVM_PARAM_STORE_PFN    1
 #define HVM_PARAM_STORE_EVTCHN 2
 
-- 
2.0.4

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

* [PATCH v3 09/17] xen/hvm/params: Add a new delivery type for event-channel in HVM_PARAM_CALLBACK_IRQ
  2016-01-23  3:19 ` Shannon Zhao
                   ` (14 preceding siblings ...)
  (?)
@ 2016-01-23  3:19 ` Shannon Zhao
  -1 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: devicetree, linux-efi, ian.campbell, catalin.marinas,
	will.deacon, linux-kernel, xen-devel, julien.grall, shannon.zhao,
	peter.huangpeng

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

Add a new delivery 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>
---
 include/xen/interface/hvm/params.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/include/xen/interface/hvm/params.h b/include/xen/interface/hvm/params.h
index 70ad208..5dd629f 100644
--- a/include/xen/interface/hvm/params.h
+++ b/include/xen/interface/hvm/params.h
@@ -53,6 +53,15 @@
  * if this delivery method is available.
  */
 
+#define HVM_PARAM_CALLBACK_TYPE_EVENT    3
+/*
+ * val[15:8] is flag of event-channel interrupt:
+ *  bit 0: interrupt is edge(1) or level(0) triggered
+ *  bit 1: interrupt is active low(1) or high(0)
+ * val[7:0] is PPI number used by event-channel.
+ * This is only used by ARM/ARM64.
+ */
+
 #define HVM_PARAM_STORE_PFN    1
 #define HVM_PARAM_STORE_EVTCHN 2
 
-- 
2.0.4

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

* [PATCH v3 10/17] arm/xen: Get event-channel irq through HVM_PARAM when booting with ACPI
  2016-01-23  3:19 ` Shannon Zhao
  (?)
@ 2016-01-23  3:19   ` Shannon Zhao
  -1 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: catalin.marinas, will.deacon, julien.grall, xen-devel,
	devicetree, linux-efi, linux-kernel, ian.campbell, shannon.zhao,
	peter.huangpeng

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

When booting with ACPI, it could get the event-channel irq through
HVM_PARAM_CALLBACK_IRQ.

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

diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
index 6d90a62..0e010bb 100644
--- a/arch/arm/xen/enlighten.c
+++ b/arch/arm/xen/enlighten.c
@@ -29,6 +29,7 @@
 #include <linux/time64.h>
 #include <linux/timekeeping.h>
 #include <linux/timekeeper_internal.h>
+#include <linux/acpi.h>
 
 #include <linux/mm.h>
 
@@ -262,6 +263,35 @@ void __init xen_early_init(void)
 		add_preferred_console("hvc", 0, NULL);
 }
 
+static void __init xen_acpi_guest_init_events_irq(void)
+{
+#ifdef CONFIG_ACPI
+	struct xen_hvm_param a;
+	int interrupt, trigger, polarity;
+
+	a.domid = DOMID_SELF;
+	a.index = HVM_PARAM_CALLBACK_IRQ;
+	xen_events_irq = 0;
+
+	if (!HYPERVISOR_hvm_op(HVMOP_get_param, &a)) {
+		if ((a.value >> 56) == HVM_PARAM_CALLBACK_TYPE_EVENT) {
+			interrupt = a.value & 0xff;
+			trigger = ((a.value >> 8) & 0x1) ? ACPI_EDGE_SENSITIVE
+							 : ACPI_LEVEL_SENSITIVE;
+			polarity = ((a.value >> 8) & 0x2) ? ACPI_ACTIVE_LOW
+							  : ACPI_ACTIVE_HIGH;
+			xen_events_irq = acpi_register_gsi(NULL, interrupt,
+							   trigger, polarity);
+		}
+	}
+#endif
+}
+
+static void __init xen_dt_guest_init_events_irq(void)
+{
+	xen_events_irq = irq_of_parse_and_map(xen_node, 0);
+}
+
 static int __init xen_guest_init(void)
 {
 	struct xen_add_to_physmap xatp;
@@ -270,7 +300,11 @@ static int __init xen_guest_init(void)
 	if (!xen_domain())
 		return 0;
 
-	xen_events_irq = irq_of_parse_and_map(xen_node, 0);
+	if (!acpi_disabled)
+		xen_acpi_guest_init_events_irq();
+	else
+		xen_dt_guest_init_events_irq();
+
 	if (!xen_events_irq) {
 		pr_err("Xen event channel interrupt not found\n");
 		return -ENODEV;
-- 
2.0.4

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

* [PATCH v3 10/17] arm/xen: Get event-channel irq through HVM_PARAM when booting with ACPI
@ 2016-01-23  3:19   ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: devicetree, linux-efi, ian.campbell, catalin.marinas,
	will.deacon, linux-kernel, xen-devel, julien.grall, shannon.zhao,
	peter.huangpeng

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

When booting with ACPI, it could get the event-channel irq through
HVM_PARAM_CALLBACK_IRQ.

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

diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
index 6d90a62..0e010bb 100644
--- a/arch/arm/xen/enlighten.c
+++ b/arch/arm/xen/enlighten.c
@@ -29,6 +29,7 @@
 #include <linux/time64.h>
 #include <linux/timekeeping.h>
 #include <linux/timekeeper_internal.h>
+#include <linux/acpi.h>
 
 #include <linux/mm.h>
 
@@ -262,6 +263,35 @@ void __init xen_early_init(void)
 		add_preferred_console("hvc", 0, NULL);
 }
 
+static void __init xen_acpi_guest_init_events_irq(void)
+{
+#ifdef CONFIG_ACPI
+	struct xen_hvm_param a;
+	int interrupt, trigger, polarity;
+
+	a.domid = DOMID_SELF;
+	a.index = HVM_PARAM_CALLBACK_IRQ;
+	xen_events_irq = 0;
+
+	if (!HYPERVISOR_hvm_op(HVMOP_get_param, &a)) {
+		if ((a.value >> 56) == HVM_PARAM_CALLBACK_TYPE_EVENT) {
+			interrupt = a.value & 0xff;
+			trigger = ((a.value >> 8) & 0x1) ? ACPI_EDGE_SENSITIVE
+							 : ACPI_LEVEL_SENSITIVE;
+			polarity = ((a.value >> 8) & 0x2) ? ACPI_ACTIVE_LOW
+							  : ACPI_ACTIVE_HIGH;
+			xen_events_irq = acpi_register_gsi(NULL, interrupt,
+							   trigger, polarity);
+		}
+	}
+#endif
+}
+
+static void __init xen_dt_guest_init_events_irq(void)
+{
+	xen_events_irq = irq_of_parse_and_map(xen_node, 0);
+}
+
 static int __init xen_guest_init(void)
 {
 	struct xen_add_to_physmap xatp;
@@ -270,7 +300,11 @@ static int __init xen_guest_init(void)
 	if (!xen_domain())
 		return 0;
 
-	xen_events_irq = irq_of_parse_and_map(xen_node, 0);
+	if (!acpi_disabled)
+		xen_acpi_guest_init_events_irq();
+	else
+		xen_dt_guest_init_events_irq();
+
 	if (!xen_events_irq) {
 		pr_err("Xen event channel interrupt not found\n");
 		return -ENODEV;
-- 
2.0.4

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

* [PATCH v3 10/17] arm/xen: Get event-channel irq through HVM_PARAM when booting with ACPI
@ 2016-01-23  3:19   ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel

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

When booting with ACPI, it could get the event-channel irq through
HVM_PARAM_CALLBACK_IRQ.

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

diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
index 6d90a62..0e010bb 100644
--- a/arch/arm/xen/enlighten.c
+++ b/arch/arm/xen/enlighten.c
@@ -29,6 +29,7 @@
 #include <linux/time64.h>
 #include <linux/timekeeping.h>
 #include <linux/timekeeper_internal.h>
+#include <linux/acpi.h>
 
 #include <linux/mm.h>
 
@@ -262,6 +263,35 @@ void __init xen_early_init(void)
 		add_preferred_console("hvc", 0, NULL);
 }
 
+static void __init xen_acpi_guest_init_events_irq(void)
+{
+#ifdef CONFIG_ACPI
+	struct xen_hvm_param a;
+	int interrupt, trigger, polarity;
+
+	a.domid = DOMID_SELF;
+	a.index = HVM_PARAM_CALLBACK_IRQ;
+	xen_events_irq = 0;
+
+	if (!HYPERVISOR_hvm_op(HVMOP_get_param, &a)) {
+		if ((a.value >> 56) == HVM_PARAM_CALLBACK_TYPE_EVENT) {
+			interrupt = a.value & 0xff;
+			trigger = ((a.value >> 8) & 0x1) ? ACPI_EDGE_SENSITIVE
+							 : ACPI_LEVEL_SENSITIVE;
+			polarity = ((a.value >> 8) & 0x2) ? ACPI_ACTIVE_LOW
+							  : ACPI_ACTIVE_HIGH;
+			xen_events_irq = acpi_register_gsi(NULL, interrupt,
+							   trigger, polarity);
+		}
+	}
+#endif
+}
+
+static void __init xen_dt_guest_init_events_irq(void)
+{
+	xen_events_irq = irq_of_parse_and_map(xen_node, 0);
+}
+
 static int __init xen_guest_init(void)
 {
 	struct xen_add_to_physmap xatp;
@@ -270,7 +300,11 @@ static int __init xen_guest_init(void)
 	if (!xen_domain())
 		return 0;
 
-	xen_events_irq = irq_of_parse_and_map(xen_node, 0);
+	if (!acpi_disabled)
+		xen_acpi_guest_init_events_irq();
+	else
+		xen_dt_guest_init_events_irq();
+
 	if (!xen_events_irq) {
 		pr_err("Xen event channel interrupt not found\n");
 		return -ENODEV;
-- 
2.0.4

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

* [PATCH v3 11/17] ARM: XEN: Move xen_early_init() before efi_init()
@ 2016-01-23  3:19   ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: catalin.marinas, will.deacon, julien.grall, xen-devel,
	devicetree, linux-efi, linux-kernel, ian.campbell, shannon.zhao,
	peter.huangpeng

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

Move xen_early_init() before efi_init(), then when calling efi_init()
could initialize Xen specific UEFI.

Check if it runs on Xen hypervisor through the flat dts.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 arch/arm/xen/enlighten.c  | 56 ++++++++++++++++++++++++++++++++++-------------
 arch/arm64/kernel/setup.c |  2 +-
 2 files changed, 42 insertions(+), 16 deletions(-)

diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
index 0e010bb..cdc0bd2 100644
--- a/arch/arm/xen/enlighten.c
+++ b/arch/arm/xen/enlighten.c
@@ -19,6 +19,7 @@
 #include <linux/irqreturn.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/of_fdt.h>
 #include <linux/of_irq.h>
 #include <linux/of_address.h>
 #include <linux/cpuidle.h>
@@ -52,8 +53,6 @@ struct xen_memory_region xen_extra_mem[XEN_EXTRA_MEM_MAX_REGIONS] __initdata;
 
 static __read_mostly unsigned int xen_events_irq;
 
-static __initdata struct device_node *xen_node;
-
 int xen_remap_domain_gfn_array(struct vm_area_struct *vma,
 			       unsigned long addr,
 			       xen_pfn_t *gfn, int nr,
@@ -222,6 +221,33 @@ static irqreturn_t xen_arm_callback(int irq, void *arg)
 	return IRQ_HANDLED;
 }
 
+static __initdata struct {
+	const char *compat;
+	const char *prefix;
+	const char *version;
+	bool found;
+} hyper_node = {"xen,xen", "xen,xen-", NULL, false};
+
+static int __init fdt_find_hyper_node(unsigned long node, const char *uname,
+				      int depth, void *data)
+{
+	const void *s = NULL;
+	int len;
+
+	if (depth != 1 || strcmp(uname, "hypervisor") != 0)
+		return 0;
+
+	if (of_flat_dt_is_compatible(node, hyper_node.compat))
+		hyper_node.found = true;
+
+	s = of_get_flat_dt_prop(node, "compatible", &len);
+	if (strlen(hyper_node.prefix) + 3  < len &&
+	    !strncmp(hyper_node.prefix, s, strlen(hyper_node.prefix)))
+		hyper_node.version = s + strlen(hyper_node.prefix);
+
+	return 0;
+}
+
 /*
  * see Documentation/devicetree/bindings/arm/xen.txt for the
  * documentation of the Xen Device Tree format.
@@ -229,26 +255,18 @@ static irqreturn_t xen_arm_callback(int irq, void *arg)
 #define GRANT_TABLE_PHYSADDR 0
 void __init xen_early_init(void)
 {
-	int len;
-	const char *s = NULL;
-	const char *version = NULL;
-	const char *xen_prefix = "xen,xen-";
-
-	xen_node = of_find_compatible_node(NULL, NULL, "xen,xen");
-	if (!xen_node) {
+	of_scan_flat_dt(fdt_find_hyper_node, NULL);
+	if (!hyper_node.found) {
 		pr_debug("No Xen support\n");
 		return;
 	}
-	s = of_get_property(xen_node, "compatible", &len);
-	if (strlen(xen_prefix) + 3  < len &&
-			!strncmp(xen_prefix, s, strlen(xen_prefix)))
-		version = s + strlen(xen_prefix);
-	if (version == NULL) {
+
+	if (hyper_node.version == NULL) {
 		pr_debug("Xen version not found\n");
 		return;
 	}
 
-	pr_info("Xen %s support found\n", version);
+	pr_info("Xen %s support found\n", hyper_node.version);
 
 	xen_domain_type = XEN_HVM_DOMAIN;
 
@@ -289,6 +307,14 @@ static void __init xen_acpi_guest_init_events_irq(void)
 
 static void __init xen_dt_guest_init_events_irq(void)
 {
+	struct device_node *xen_node;
+
+	xen_node = of_find_compatible_node(NULL, NULL, "xen,xen");
+	if (!xen_node) {
+		pr_err("Xen support was detected before, but it has disappeared\n");
+		return;
+	}
+
 	xen_events_irq = irq_of_parse_and_map(xen_node, 0);
 }
 
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index 8119479..a4a2878 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -313,6 +313,7 @@ void __init setup_arch(char **cmdline_p)
 	 */
 	local_async_enable();
 
+	xen_early_init();
 	efi_init();
 	arm64_memblock_init();
 
@@ -334,7 +335,6 @@ void __init setup_arch(char **cmdline_p)
 	} else {
 		psci_acpi_init();
 	}
-	xen_early_init();
 
 	cpu_read_bootcpu_ops();
 	smp_init_cpus();
-- 
2.0.4

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

* [PATCH v3 11/17] ARM: XEN: Move xen_early_init() before efi_init()
@ 2016-01-23  3:19   ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	stefano.stabellini-Sxgqhf6Nn4DQT0dZR+AlfA,
	david.vrabel-Sxgqhf6Nn4DQT0dZR+AlfA
  Cc: catalin.marinas-5wv7dgnIgG8, will.deacon-5wv7dgnIgG8,
	julien.grall-Sxgqhf6Nn4DQT0dZR+AlfA,
	xen-devel-GuqFBffKawuEi8DpZVb4nw,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-efi-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	ian.campbell-Sxgqhf6Nn4DQT0dZR+AlfA,
	shannon.zhao-QSEj5FYQhm4dnm+yROfE0A,
	peter.huangpeng-hv44wF8Li93QT0dZR+AlfA

From: Shannon Zhao <shannon.zhao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>

Move xen_early_init() before efi_init(), then when calling efi_init()
could initialize Xen specific UEFI.

Check if it runs on Xen hypervisor through the flat dts.

Signed-off-by: Shannon Zhao <shannon.zhao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
 arch/arm/xen/enlighten.c  | 56 ++++++++++++++++++++++++++++++++++-------------
 arch/arm64/kernel/setup.c |  2 +-
 2 files changed, 42 insertions(+), 16 deletions(-)

diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
index 0e010bb..cdc0bd2 100644
--- a/arch/arm/xen/enlighten.c
+++ b/arch/arm/xen/enlighten.c
@@ -19,6 +19,7 @@
 #include <linux/irqreturn.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/of_fdt.h>
 #include <linux/of_irq.h>
 #include <linux/of_address.h>
 #include <linux/cpuidle.h>
@@ -52,8 +53,6 @@ struct xen_memory_region xen_extra_mem[XEN_EXTRA_MEM_MAX_REGIONS] __initdata;
 
 static __read_mostly unsigned int xen_events_irq;
 
-static __initdata struct device_node *xen_node;
-
 int xen_remap_domain_gfn_array(struct vm_area_struct *vma,
 			       unsigned long addr,
 			       xen_pfn_t *gfn, int nr,
@@ -222,6 +221,33 @@ static irqreturn_t xen_arm_callback(int irq, void *arg)
 	return IRQ_HANDLED;
 }
 
+static __initdata struct {
+	const char *compat;
+	const char *prefix;
+	const char *version;
+	bool found;
+} hyper_node = {"xen,xen", "xen,xen-", NULL, false};
+
+static int __init fdt_find_hyper_node(unsigned long node, const char *uname,
+				      int depth, void *data)
+{
+	const void *s = NULL;
+	int len;
+
+	if (depth != 1 || strcmp(uname, "hypervisor") != 0)
+		return 0;
+
+	if (of_flat_dt_is_compatible(node, hyper_node.compat))
+		hyper_node.found = true;
+
+	s = of_get_flat_dt_prop(node, "compatible", &len);
+	if (strlen(hyper_node.prefix) + 3  < len &&
+	    !strncmp(hyper_node.prefix, s, strlen(hyper_node.prefix)))
+		hyper_node.version = s + strlen(hyper_node.prefix);
+
+	return 0;
+}
+
 /*
  * see Documentation/devicetree/bindings/arm/xen.txt for the
  * documentation of the Xen Device Tree format.
@@ -229,26 +255,18 @@ static irqreturn_t xen_arm_callback(int irq, void *arg)
 #define GRANT_TABLE_PHYSADDR 0
 void __init xen_early_init(void)
 {
-	int len;
-	const char *s = NULL;
-	const char *version = NULL;
-	const char *xen_prefix = "xen,xen-";
-
-	xen_node = of_find_compatible_node(NULL, NULL, "xen,xen");
-	if (!xen_node) {
+	of_scan_flat_dt(fdt_find_hyper_node, NULL);
+	if (!hyper_node.found) {
 		pr_debug("No Xen support\n");
 		return;
 	}
-	s = of_get_property(xen_node, "compatible", &len);
-	if (strlen(xen_prefix) + 3  < len &&
-			!strncmp(xen_prefix, s, strlen(xen_prefix)))
-		version = s + strlen(xen_prefix);
-	if (version == NULL) {
+
+	if (hyper_node.version == NULL) {
 		pr_debug("Xen version not found\n");
 		return;
 	}
 
-	pr_info("Xen %s support found\n", version);
+	pr_info("Xen %s support found\n", hyper_node.version);
 
 	xen_domain_type = XEN_HVM_DOMAIN;
 
@@ -289,6 +307,14 @@ static void __init xen_acpi_guest_init_events_irq(void)
 
 static void __init xen_dt_guest_init_events_irq(void)
 {
+	struct device_node *xen_node;
+
+	xen_node = of_find_compatible_node(NULL, NULL, "xen,xen");
+	if (!xen_node) {
+		pr_err("Xen support was detected before, but it has disappeared\n");
+		return;
+	}
+
 	xen_events_irq = irq_of_parse_and_map(xen_node, 0);
 }
 
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index 8119479..a4a2878 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -313,6 +313,7 @@ void __init setup_arch(char **cmdline_p)
 	 */
 	local_async_enable();
 
+	xen_early_init();
 	efi_init();
 	arm64_memblock_init();
 
@@ -334,7 +335,6 @@ void __init setup_arch(char **cmdline_p)
 	} else {
 		psci_acpi_init();
 	}
-	xen_early_init();
 
 	cpu_read_bootcpu_ops();
 	smp_init_cpus();
-- 
2.0.4


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v3 11/17] ARM: XEN: Move xen_early_init() before efi_init()
@ 2016-01-23  3:19   ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel

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

Move xen_early_init() before efi_init(), then when calling efi_init()
could initialize Xen specific UEFI.

Check if it runs on Xen hypervisor through the flat dts.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 arch/arm/xen/enlighten.c  | 56 ++++++++++++++++++++++++++++++++++-------------
 arch/arm64/kernel/setup.c |  2 +-
 2 files changed, 42 insertions(+), 16 deletions(-)

diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
index 0e010bb..cdc0bd2 100644
--- a/arch/arm/xen/enlighten.c
+++ b/arch/arm/xen/enlighten.c
@@ -19,6 +19,7 @@
 #include <linux/irqreturn.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/of_fdt.h>
 #include <linux/of_irq.h>
 #include <linux/of_address.h>
 #include <linux/cpuidle.h>
@@ -52,8 +53,6 @@ struct xen_memory_region xen_extra_mem[XEN_EXTRA_MEM_MAX_REGIONS] __initdata;
 
 static __read_mostly unsigned int xen_events_irq;
 
-static __initdata struct device_node *xen_node;
-
 int xen_remap_domain_gfn_array(struct vm_area_struct *vma,
 			       unsigned long addr,
 			       xen_pfn_t *gfn, int nr,
@@ -222,6 +221,33 @@ static irqreturn_t xen_arm_callback(int irq, void *arg)
 	return IRQ_HANDLED;
 }
 
+static __initdata struct {
+	const char *compat;
+	const char *prefix;
+	const char *version;
+	bool found;
+} hyper_node = {"xen,xen", "xen,xen-", NULL, false};
+
+static int __init fdt_find_hyper_node(unsigned long node, const char *uname,
+				      int depth, void *data)
+{
+	const void *s = NULL;
+	int len;
+
+	if (depth != 1 || strcmp(uname, "hypervisor") != 0)
+		return 0;
+
+	if (of_flat_dt_is_compatible(node, hyper_node.compat))
+		hyper_node.found = true;
+
+	s = of_get_flat_dt_prop(node, "compatible", &len);
+	if (strlen(hyper_node.prefix) + 3  < len &&
+	    !strncmp(hyper_node.prefix, s, strlen(hyper_node.prefix)))
+		hyper_node.version = s + strlen(hyper_node.prefix);
+
+	return 0;
+}
+
 /*
  * see Documentation/devicetree/bindings/arm/xen.txt for the
  * documentation of the Xen Device Tree format.
@@ -229,26 +255,18 @@ static irqreturn_t xen_arm_callback(int irq, void *arg)
 #define GRANT_TABLE_PHYSADDR 0
 void __init xen_early_init(void)
 {
-	int len;
-	const char *s = NULL;
-	const char *version = NULL;
-	const char *xen_prefix = "xen,xen-";
-
-	xen_node = of_find_compatible_node(NULL, NULL, "xen,xen");
-	if (!xen_node) {
+	of_scan_flat_dt(fdt_find_hyper_node, NULL);
+	if (!hyper_node.found) {
 		pr_debug("No Xen support\n");
 		return;
 	}
-	s = of_get_property(xen_node, "compatible", &len);
-	if (strlen(xen_prefix) + 3  < len &&
-			!strncmp(xen_prefix, s, strlen(xen_prefix)))
-		version = s + strlen(xen_prefix);
-	if (version == NULL) {
+
+	if (hyper_node.version == NULL) {
 		pr_debug("Xen version not found\n");
 		return;
 	}
 
-	pr_info("Xen %s support found\n", version);
+	pr_info("Xen %s support found\n", hyper_node.version);
 
 	xen_domain_type = XEN_HVM_DOMAIN;
 
@@ -289,6 +307,14 @@ static void __init xen_acpi_guest_init_events_irq(void)
 
 static void __init xen_dt_guest_init_events_irq(void)
 {
+	struct device_node *xen_node;
+
+	xen_node = of_find_compatible_node(NULL, NULL, "xen,xen");
+	if (!xen_node) {
+		pr_err("Xen support was detected before, but it has disappeared\n");
+		return;
+	}
+
 	xen_events_irq = irq_of_parse_and_map(xen_node, 0);
 }
 
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index 8119479..a4a2878 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -313,6 +313,7 @@ void __init setup_arch(char **cmdline_p)
 	 */
 	local_async_enable();
 
+	xen_early_init();
 	efi_init();
 	arm64_memblock_init();
 
@@ -334,7 +335,6 @@ void __init setup_arch(char **cmdline_p)
 	} else {
 		psci_acpi_init();
 	}
-	xen_early_init();
 
 	cpu_read_bootcpu_ops();
 	smp_init_cpus();
-- 
2.0.4

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

* [PATCH v3 11/17] ARM: XEN: Move xen_early_init() before efi_init()
  2016-01-23  3:19 ` Shannon Zhao
                   ` (16 preceding siblings ...)
  (?)
@ 2016-01-23  3:19 ` Shannon Zhao
  -1 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: devicetree, linux-efi, ian.campbell, catalin.marinas,
	will.deacon, linux-kernel, xen-devel, julien.grall, shannon.zhao,
	peter.huangpeng

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

Move xen_early_init() before efi_init(), then when calling efi_init()
could initialize Xen specific UEFI.

Check if it runs on Xen hypervisor through the flat dts.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 arch/arm/xen/enlighten.c  | 56 ++++++++++++++++++++++++++++++++++-------------
 arch/arm64/kernel/setup.c |  2 +-
 2 files changed, 42 insertions(+), 16 deletions(-)

diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
index 0e010bb..cdc0bd2 100644
--- a/arch/arm/xen/enlighten.c
+++ b/arch/arm/xen/enlighten.c
@@ -19,6 +19,7 @@
 #include <linux/irqreturn.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/of_fdt.h>
 #include <linux/of_irq.h>
 #include <linux/of_address.h>
 #include <linux/cpuidle.h>
@@ -52,8 +53,6 @@ struct xen_memory_region xen_extra_mem[XEN_EXTRA_MEM_MAX_REGIONS] __initdata;
 
 static __read_mostly unsigned int xen_events_irq;
 
-static __initdata struct device_node *xen_node;
-
 int xen_remap_domain_gfn_array(struct vm_area_struct *vma,
 			       unsigned long addr,
 			       xen_pfn_t *gfn, int nr,
@@ -222,6 +221,33 @@ static irqreturn_t xen_arm_callback(int irq, void *arg)
 	return IRQ_HANDLED;
 }
 
+static __initdata struct {
+	const char *compat;
+	const char *prefix;
+	const char *version;
+	bool found;
+} hyper_node = {"xen,xen", "xen,xen-", NULL, false};
+
+static int __init fdt_find_hyper_node(unsigned long node, const char *uname,
+				      int depth, void *data)
+{
+	const void *s = NULL;
+	int len;
+
+	if (depth != 1 || strcmp(uname, "hypervisor") != 0)
+		return 0;
+
+	if (of_flat_dt_is_compatible(node, hyper_node.compat))
+		hyper_node.found = true;
+
+	s = of_get_flat_dt_prop(node, "compatible", &len);
+	if (strlen(hyper_node.prefix) + 3  < len &&
+	    !strncmp(hyper_node.prefix, s, strlen(hyper_node.prefix)))
+		hyper_node.version = s + strlen(hyper_node.prefix);
+
+	return 0;
+}
+
 /*
  * see Documentation/devicetree/bindings/arm/xen.txt for the
  * documentation of the Xen Device Tree format.
@@ -229,26 +255,18 @@ static irqreturn_t xen_arm_callback(int irq, void *arg)
 #define GRANT_TABLE_PHYSADDR 0
 void __init xen_early_init(void)
 {
-	int len;
-	const char *s = NULL;
-	const char *version = NULL;
-	const char *xen_prefix = "xen,xen-";
-
-	xen_node = of_find_compatible_node(NULL, NULL, "xen,xen");
-	if (!xen_node) {
+	of_scan_flat_dt(fdt_find_hyper_node, NULL);
+	if (!hyper_node.found) {
 		pr_debug("No Xen support\n");
 		return;
 	}
-	s = of_get_property(xen_node, "compatible", &len);
-	if (strlen(xen_prefix) + 3  < len &&
-			!strncmp(xen_prefix, s, strlen(xen_prefix)))
-		version = s + strlen(xen_prefix);
-	if (version == NULL) {
+
+	if (hyper_node.version == NULL) {
 		pr_debug("Xen version not found\n");
 		return;
 	}
 
-	pr_info("Xen %s support found\n", version);
+	pr_info("Xen %s support found\n", hyper_node.version);
 
 	xen_domain_type = XEN_HVM_DOMAIN;
 
@@ -289,6 +307,14 @@ static void __init xen_acpi_guest_init_events_irq(void)
 
 static void __init xen_dt_guest_init_events_irq(void)
 {
+	struct device_node *xen_node;
+
+	xen_node = of_find_compatible_node(NULL, NULL, "xen,xen");
+	if (!xen_node) {
+		pr_err("Xen support was detected before, but it has disappeared\n");
+		return;
+	}
+
 	xen_events_irq = irq_of_parse_and_map(xen_node, 0);
 }
 
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index 8119479..a4a2878 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -313,6 +313,7 @@ void __init setup_arch(char **cmdline_p)
 	 */
 	local_async_enable();
 
+	xen_early_init();
 	efi_init();
 	arm64_memblock_init();
 
@@ -334,7 +335,6 @@ void __init setup_arch(char **cmdline_p)
 	} else {
 		psci_acpi_init();
 	}
-	xen_early_init();
 
 	cpu_read_bootcpu_ops();
 	smp_init_cpus();
-- 
2.0.4

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

* [PATCH v3 12/17] ARM64: ACPI: Check if it runs on Xen to enable or disable ACPI
  2016-01-23  3:19 ` Shannon Zhao
  (?)
@ 2016-01-23  3:19   ` Shannon Zhao
  -1 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: catalin.marinas, will.deacon, julien.grall, xen-devel,
	devicetree, linux-efi, linux-kernel, ian.campbell, shannon.zhao,
	peter.huangpeng, Hanjun Guo

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

When it's a Xen domain0 booting with ACPI, it will supply a /chosen and
a /hypervisor node in DT. So check if it needs to enable ACPI.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
CC: Hanjun Guo <hanjun.guo@linaro.org>
---
 arch/arm64/kernel/acpi.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
index d1ce8e2..4e92be0 100644
--- a/arch/arm64/kernel/acpi.c
+++ b/arch/arm64/kernel/acpi.c
@@ -67,10 +67,13 @@ static int __init dt_scan_depth1_nodes(unsigned long node,
 {
 	/*
 	 * Return 1 as soon as we encounter a node at depth 1 that is
-	 * not the /chosen node.
+	 * not the /chosen node, or /hypervisor node when running on Xen.
 	 */
-	if (depth == 1 && (strcmp(uname, "chosen") != 0))
-		return 1;
+	if (depth == 1 && (strcmp(uname, "chosen") != 0)) {
+		if (!xen_initial_domain() || (strcmp(uname, "hypervisor") != 0))
+			return 1;
+	}
+
 	return 0;
 }
 
@@ -184,7 +187,8 @@ void __init acpi_boot_table_init(void)
 	/*
 	 * Enable ACPI instead of device tree unless
 	 * - ACPI has been disabled explicitly (acpi=off), or
-	 * - the device tree is not empty (it has more than just a /chosen node)
+	 * - the device tree is not empty (it has more than just a /chosen node,
+	 *   and a /hypervisor node when running on Xen)
 	 *   and ACPI has not been force enabled (acpi=force)
 	 */
 	if (param_acpi_off ||
-- 
2.0.4

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

* [PATCH v3 12/17] ARM64: ACPI: Check if it runs on Xen to enable or disable ACPI
@ 2016-01-23  3:19   ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: catalin.marinas, will.deacon, julien.grall, xen-devel,
	devicetree, linux-efi, linux-kernel, ian.campbell, shannon.zhao,
	peter.huangpeng, Hanjun Guo

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

When it's a Xen domain0 booting with ACPI, it will supply a /chosen and
a /hypervisor node in DT. So check if it needs to enable ACPI.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
CC: Hanjun Guo <hanjun.guo@linaro.org>
---
 arch/arm64/kernel/acpi.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
index d1ce8e2..4e92be0 100644
--- a/arch/arm64/kernel/acpi.c
+++ b/arch/arm64/kernel/acpi.c
@@ -67,10 +67,13 @@ static int __init dt_scan_depth1_nodes(unsigned long node,
 {
 	/*
 	 * Return 1 as soon as we encounter a node at depth 1 that is
-	 * not the /chosen node.
+	 * not the /chosen node, or /hypervisor node when running on Xen.
 	 */
-	if (depth == 1 && (strcmp(uname, "chosen") != 0))
-		return 1;
+	if (depth == 1 && (strcmp(uname, "chosen") != 0)) {
+		if (!xen_initial_domain() || (strcmp(uname, "hypervisor") != 0))
+			return 1;
+	}
+
 	return 0;
 }
 
@@ -184,7 +187,8 @@ void __init acpi_boot_table_init(void)
 	/*
 	 * Enable ACPI instead of device tree unless
 	 * - ACPI has been disabled explicitly (acpi=off), or
-	 * - the device tree is not empty (it has more than just a /chosen node)
+	 * - the device tree is not empty (it has more than just a /chosen node,
+	 *   and a /hypervisor node when running on Xen)
 	 *   and ACPI has not been force enabled (acpi=force)
 	 */
 	if (param_acpi_off ||
-- 
2.0.4

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

* [PATCH v3 12/17] ARM64: ACPI: Check if it runs on Xen to enable or disable ACPI
@ 2016-01-23  3:19   ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel

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

When it's a Xen domain0 booting with ACPI, it will supply a /chosen and
a /hypervisor node in DT. So check if it needs to enable ACPI.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
CC: Hanjun Guo <hanjun.guo@linaro.org>
---
 arch/arm64/kernel/acpi.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
index d1ce8e2..4e92be0 100644
--- a/arch/arm64/kernel/acpi.c
+++ b/arch/arm64/kernel/acpi.c
@@ -67,10 +67,13 @@ static int __init dt_scan_depth1_nodes(unsigned long node,
 {
 	/*
 	 * Return 1 as soon as we encounter a node at depth 1 that is
-	 * not the /chosen node.
+	 * not the /chosen node, or /hypervisor node when running on Xen.
 	 */
-	if (depth == 1 && (strcmp(uname, "chosen") != 0))
-		return 1;
+	if (depth == 1 && (strcmp(uname, "chosen") != 0)) {
+		if (!xen_initial_domain() || (strcmp(uname, "hypervisor") != 0))
+			return 1;
+	}
+
 	return 0;
 }
 
@@ -184,7 +187,8 @@ void __init acpi_boot_table_init(void)
 	/*
 	 * Enable ACPI instead of device tree unless
 	 * - ACPI has been disabled explicitly (acpi=off), or
-	 * - the device tree is not empty (it has more than just a /chosen node)
+	 * - the device tree is not empty (it has more than just a /chosen node,
+	 *   and a /hypervisor node when running on Xen)
 	 *   and ACPI has not been force enabled (acpi=force)
 	 */
 	if (param_acpi_off ||
-- 
2.0.4

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

* [PATCH v3 12/17] ARM64: ACPI: Check if it runs on Xen to enable or disable ACPI
  2016-01-23  3:19 ` Shannon Zhao
                   ` (18 preceding siblings ...)
  (?)
@ 2016-01-23  3:19 ` Shannon Zhao
  -1 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: devicetree, linux-efi, ian.campbell, catalin.marinas,
	will.deacon, linux-kernel, xen-devel, julien.grall, shannon.zhao,
	peter.huangpeng, Hanjun Guo

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

When it's a Xen domain0 booting with ACPI, it will supply a /chosen and
a /hypervisor node in DT. So check if it needs to enable ACPI.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
CC: Hanjun Guo <hanjun.guo@linaro.org>
---
 arch/arm64/kernel/acpi.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
index d1ce8e2..4e92be0 100644
--- a/arch/arm64/kernel/acpi.c
+++ b/arch/arm64/kernel/acpi.c
@@ -67,10 +67,13 @@ static int __init dt_scan_depth1_nodes(unsigned long node,
 {
 	/*
 	 * Return 1 as soon as we encounter a node at depth 1 that is
-	 * not the /chosen node.
+	 * not the /chosen node, or /hypervisor node when running on Xen.
 	 */
-	if (depth == 1 && (strcmp(uname, "chosen") != 0))
-		return 1;
+	if (depth == 1 && (strcmp(uname, "chosen") != 0)) {
+		if (!xen_initial_domain() || (strcmp(uname, "hypervisor") != 0))
+			return 1;
+	}
+
 	return 0;
 }
 
@@ -184,7 +187,8 @@ void __init acpi_boot_table_init(void)
 	/*
 	 * Enable ACPI instead of device tree unless
 	 * - ACPI has been disabled explicitly (acpi=off), or
-	 * - the device tree is not empty (it has more than just a /chosen node)
+	 * - the device tree is not empty (it has more than just a /chosen node,
+	 *   and a /hypervisor node when running on Xen)
 	 *   and ACPI has not been force enabled (acpi=force)
 	 */
 	if (param_acpi_off ||
-- 
2.0.4

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

* [PATCH v3 13/17] ARM: Xen: Document UEFI support on Xen ARM virtual platforms
  2016-01-23  3:19 ` Shannon Zhao
  (?)
@ 2016-01-23  3:19   ` Shannon Zhao
  -1 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: catalin.marinas, will.deacon, julien.grall, xen-devel,
	devicetree, linux-efi, linux-kernel, ian.campbell, shannon.zhao,
	peter.huangpeng, Rob Herring

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

Add a "uefi" node under /hypervisor node in FDT, then Linux kernel could
scan this to get the UEFI information.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Acked-by: Rob Herring <robh@kernel.org>
---
CC: Rob Herring <robh@kernel.org>
---
 Documentation/devicetree/bindings/arm/xen.txt | 34 +++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/Documentation/devicetree/bindings/arm/xen.txt b/Documentation/devicetree/bindings/arm/xen.txt
index 0f7b9c2..aa69405 100644
--- a/Documentation/devicetree/bindings/arm/xen.txt
+++ b/Documentation/devicetree/bindings/arm/xen.txt
@@ -15,6 +15,26 @@ the following properties:
 - interrupts: the interrupt used by Xen to inject event notifications.
   A GIC node is also required.
 
+To support UEFI on Xen ARM virtual platforms, Xen populates the FDT "uefi" node
+under /hypervisor with following parameters:
+
+________________________________________________________________________________
+Name                      | Size   | Description
+================================================================================
+xen,uefi-system-table     | 64-bit | Guest physical address of the UEFI System
+			  |	   | Table.
+--------------------------------------------------------------------------------
+xen,uefi-mmap-start       | 64-bit | Guest physical address of the UEFI memory
+			  |	   | map.
+--------------------------------------------------------------------------------
+xen,uefi-mmap-size        | 32-bit | Size in bytes of the UEFI memory map
+                          |        | pointed to in previous entry.
+--------------------------------------------------------------------------------
+xen,uefi-mmap-desc-size   | 32-bit | Size in bytes of each entry in the UEFI
+                          |        | memory map.
+--------------------------------------------------------------------------------
+xen,uefi-mmap-desc-ver    | 32-bit | Version of the mmap descriptor format.
+--------------------------------------------------------------------------------
 
 Example (assuming #address-cells = <2> and #size-cells = <2>):
 
@@ -22,4 +42,18 @@ hypervisor {
 	compatible = "xen,xen-4.3", "xen,xen";
 	reg = <0 0xb0000000 0 0x20000>;
 	interrupts = <1 15 0xf08>;
+	uefi {
+		xen,uefi-system-table = <0xXXXXXXXX>;
+		xen,uefi-mmap-start = <0xXXXXXXXX>;
+		xen,uefi-mmap-size = <0xXXXXXXXX>;
+		xen,uefi-mmap-desc-size = <0xXXXXXXXX>;
+		xen,uefi-mmap-desc-ver = <0xXXXXXXXX>;
+        };
 };
+
+The format and meaning of these "xen,uefi-*" parameters are similar to those in
+Documentation/arm/uefi.txt which are used by normal UEFI. But to distinguish
+from normal UEFI, for Xen ARM virtual platforms it needs to introduce a Xen
+specific UEFI which requires Xen hypervisor to provide hypercalls for Dom0 to
+make use of the runtime services. Therefore, it defines these parameters under
+/hypervisor node.
-- 
2.0.4

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

* [PATCH v3 13/17] ARM: Xen: Document UEFI support on Xen ARM virtual platforms
@ 2016-01-23  3:19   ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: catalin.marinas, will.deacon, julien.grall, xen-devel,
	devicetree, linux-efi, linux-kernel, ian.campbell, shannon.zhao,
	peter.huangpeng, Rob Herring

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

Add a "uefi" node under /hypervisor node in FDT, then Linux kernel could
scan this to get the UEFI information.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Acked-by: Rob Herring <robh@kernel.org>
---
CC: Rob Herring <robh@kernel.org>
---
 Documentation/devicetree/bindings/arm/xen.txt | 34 +++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/Documentation/devicetree/bindings/arm/xen.txt b/Documentation/devicetree/bindings/arm/xen.txt
index 0f7b9c2..aa69405 100644
--- a/Documentation/devicetree/bindings/arm/xen.txt
+++ b/Documentation/devicetree/bindings/arm/xen.txt
@@ -15,6 +15,26 @@ the following properties:
 - interrupts: the interrupt used by Xen to inject event notifications.
   A GIC node is also required.
 
+To support UEFI on Xen ARM virtual platforms, Xen populates the FDT "uefi" node
+under /hypervisor with following parameters:
+
+________________________________________________________________________________
+Name                      | Size   | Description
+================================================================================
+xen,uefi-system-table     | 64-bit | Guest physical address of the UEFI System
+			  |	   | Table.
+--------------------------------------------------------------------------------
+xen,uefi-mmap-start       | 64-bit | Guest physical address of the UEFI memory
+			  |	   | map.
+--------------------------------------------------------------------------------
+xen,uefi-mmap-size        | 32-bit | Size in bytes of the UEFI memory map
+                          |        | pointed to in previous entry.
+--------------------------------------------------------------------------------
+xen,uefi-mmap-desc-size   | 32-bit | Size in bytes of each entry in the UEFI
+                          |        | memory map.
+--------------------------------------------------------------------------------
+xen,uefi-mmap-desc-ver    | 32-bit | Version of the mmap descriptor format.
+--------------------------------------------------------------------------------
 
 Example (assuming #address-cells = <2> and #size-cells = <2>):
 
@@ -22,4 +42,18 @@ hypervisor {
 	compatible = "xen,xen-4.3", "xen,xen";
 	reg = <0 0xb0000000 0 0x20000>;
 	interrupts = <1 15 0xf08>;
+	uefi {
+		xen,uefi-system-table = <0xXXXXXXXX>;
+		xen,uefi-mmap-start = <0xXXXXXXXX>;
+		xen,uefi-mmap-size = <0xXXXXXXXX>;
+		xen,uefi-mmap-desc-size = <0xXXXXXXXX>;
+		xen,uefi-mmap-desc-ver = <0xXXXXXXXX>;
+        };
 };
+
+The format and meaning of these "xen,uefi-*" parameters are similar to those in
+Documentation/arm/uefi.txt which are used by normal UEFI. But to distinguish
+from normal UEFI, for Xen ARM virtual platforms it needs to introduce a Xen
+specific UEFI which requires Xen hypervisor to provide hypercalls for Dom0 to
+make use of the runtime services. Therefore, it defines these parameters under
+/hypervisor node.
-- 
2.0.4

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

* [PATCH v3 13/17] ARM: Xen: Document UEFI support on Xen ARM virtual platforms
@ 2016-01-23  3:19   ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel

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

Add a "uefi" node under /hypervisor node in FDT, then Linux kernel could
scan this to get the UEFI information.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Acked-by: Rob Herring <robh@kernel.org>
---
CC: Rob Herring <robh@kernel.org>
---
 Documentation/devicetree/bindings/arm/xen.txt | 34 +++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/Documentation/devicetree/bindings/arm/xen.txt b/Documentation/devicetree/bindings/arm/xen.txt
index 0f7b9c2..aa69405 100644
--- a/Documentation/devicetree/bindings/arm/xen.txt
+++ b/Documentation/devicetree/bindings/arm/xen.txt
@@ -15,6 +15,26 @@ the following properties:
 - interrupts: the interrupt used by Xen to inject event notifications.
   A GIC node is also required.
 
+To support UEFI on Xen ARM virtual platforms, Xen populates the FDT "uefi" node
+under /hypervisor with following parameters:
+
+________________________________________________________________________________
+Name                      | Size   | Description
+================================================================================
+xen,uefi-system-table     | 64-bit | Guest physical address of the UEFI System
+			  |	   | Table.
+--------------------------------------------------------------------------------
+xen,uefi-mmap-start       | 64-bit | Guest physical address of the UEFI memory
+			  |	   | map.
+--------------------------------------------------------------------------------
+xen,uefi-mmap-size        | 32-bit | Size in bytes of the UEFI memory map
+                          |        | pointed to in previous entry.
+--------------------------------------------------------------------------------
+xen,uefi-mmap-desc-size   | 32-bit | Size in bytes of each entry in the UEFI
+                          |        | memory map.
+--------------------------------------------------------------------------------
+xen,uefi-mmap-desc-ver    | 32-bit | Version of the mmap descriptor format.
+--------------------------------------------------------------------------------
 
 Example (assuming #address-cells = <2> and #size-cells = <2>):
 
@@ -22,4 +42,18 @@ hypervisor {
 	compatible = "xen,xen-4.3", "xen,xen";
 	reg = <0 0xb0000000 0 0x20000>;
 	interrupts = <1 15 0xf08>;
+	uefi {
+		xen,uefi-system-table = <0xXXXXXXXX>;
+		xen,uefi-mmap-start = <0xXXXXXXXX>;
+		xen,uefi-mmap-size = <0xXXXXXXXX>;
+		xen,uefi-mmap-desc-size = <0xXXXXXXXX>;
+		xen,uefi-mmap-desc-ver = <0xXXXXXXXX>;
+        };
 };
+
+The format and meaning of these "xen,uefi-*" parameters are similar to those in
+Documentation/arm/uefi.txt which are used by normal UEFI. But to distinguish
+from normal UEFI, for Xen ARM virtual platforms it needs to introduce a Xen
+specific UEFI which requires Xen hypervisor to provide hypercalls for Dom0 to
+make use of the runtime services. Therefore, it defines these parameters under
+/hypervisor node.
-- 
2.0.4

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

* [PATCH v3 13/17] ARM: Xen: Document UEFI support on Xen ARM virtual platforms
  2016-01-23  3:19 ` Shannon Zhao
                   ` (20 preceding siblings ...)
  (?)
@ 2016-01-23  3:19 ` Shannon Zhao
  -1 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: devicetree, linux-efi, ian.campbell, Rob Herring,
	catalin.marinas, will.deacon, linux-kernel, xen-devel,
	julien.grall, shannon.zhao, peter.huangpeng

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

Add a "uefi" node under /hypervisor node in FDT, then Linux kernel could
scan this to get the UEFI information.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Acked-by: Rob Herring <robh@kernel.org>
---
CC: Rob Herring <robh@kernel.org>
---
 Documentation/devicetree/bindings/arm/xen.txt | 34 +++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/Documentation/devicetree/bindings/arm/xen.txt b/Documentation/devicetree/bindings/arm/xen.txt
index 0f7b9c2..aa69405 100644
--- a/Documentation/devicetree/bindings/arm/xen.txt
+++ b/Documentation/devicetree/bindings/arm/xen.txt
@@ -15,6 +15,26 @@ the following properties:
 - interrupts: the interrupt used by Xen to inject event notifications.
   A GIC node is also required.
 
+To support UEFI on Xen ARM virtual platforms, Xen populates the FDT "uefi" node
+under /hypervisor with following parameters:
+
+________________________________________________________________________________
+Name                      | Size   | Description
+================================================================================
+xen,uefi-system-table     | 64-bit | Guest physical address of the UEFI System
+			  |	   | Table.
+--------------------------------------------------------------------------------
+xen,uefi-mmap-start       | 64-bit | Guest physical address of the UEFI memory
+			  |	   | map.
+--------------------------------------------------------------------------------
+xen,uefi-mmap-size        | 32-bit | Size in bytes of the UEFI memory map
+                          |        | pointed to in previous entry.
+--------------------------------------------------------------------------------
+xen,uefi-mmap-desc-size   | 32-bit | Size in bytes of each entry in the UEFI
+                          |        | memory map.
+--------------------------------------------------------------------------------
+xen,uefi-mmap-desc-ver    | 32-bit | Version of the mmap descriptor format.
+--------------------------------------------------------------------------------
 
 Example (assuming #address-cells = <2> and #size-cells = <2>):
 
@@ -22,4 +42,18 @@ hypervisor {
 	compatible = "xen,xen-4.3", "xen,xen";
 	reg = <0 0xb0000000 0 0x20000>;
 	interrupts = <1 15 0xf08>;
+	uefi {
+		xen,uefi-system-table = <0xXXXXXXXX>;
+		xen,uefi-mmap-start = <0xXXXXXXXX>;
+		xen,uefi-mmap-size = <0xXXXXXXXX>;
+		xen,uefi-mmap-desc-size = <0xXXXXXXXX>;
+		xen,uefi-mmap-desc-ver = <0xXXXXXXXX>;
+        };
 };
+
+The format and meaning of these "xen,uefi-*" parameters are similar to those in
+Documentation/arm/uefi.txt which are used by normal UEFI. But to distinguish
+from normal UEFI, for Xen ARM virtual platforms it needs to introduce a Xen
+specific UEFI which requires Xen hypervisor to provide hypercalls for Dom0 to
+make use of the runtime services. Therefore, it defines these parameters under
+/hypervisor node.
-- 
2.0.4

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

* [PATCH v3 14/17] XEN: EFI: Move x86 specific codes to architecture directory
  2016-01-23  3:19 ` Shannon Zhao
  (?)
@ 2016-01-23  3:19   ` Shannon Zhao
  -1 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: catalin.marinas, will.deacon, julien.grall, xen-devel,
	devicetree, linux-efi, linux-kernel, ian.campbell, shannon.zhao,
	peter.huangpeng

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

Move x86 specific codes to architecture directory and export those EFI
runtime service functions. This will be useful for initializing runtime
service on ARM later.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 arch/x86/xen/efi.c    | 112 ++++++++++++++++++++++++++++++++
 drivers/xen/efi.c     | 174 ++++++++++----------------------------------------
 include/xen/xen-ops.h |  30 ++++++---
 3 files changed, 168 insertions(+), 148 deletions(-)

diff --git a/arch/x86/xen/efi.c b/arch/x86/xen/efi.c
index be14cc3..86527f1 100644
--- a/arch/x86/xen/efi.c
+++ b/arch/x86/xen/efi.c
@@ -20,10 +20,122 @@
 #include <linux/init.h>
 #include <linux/string.h>
 
+#include <xen/xen.h>
 #include <xen/xen-ops.h>
+#include <xen/interface/platform.h>
 
 #include <asm/page.h>
 #include <asm/setup.h>
+#include <asm/xen/hypercall.h>
+
+static efi_char16_t vendor[100] __initdata;
+
+static efi_system_table_t efi_systab_xen __initdata = {
+	.hdr = {
+		.signature	= EFI_SYSTEM_TABLE_SIGNATURE,
+		.revision	= 0, /* Initialized later. */
+		.headersize	= 0, /* Ignored by Linux Kernel. */
+		.crc32		= 0, /* Ignored by Linux Kernel. */
+		.reserved	= 0
+	},
+	.fw_vendor	= EFI_INVALID_TABLE_ADDR, /* Initialized later. */
+	.fw_revision	= 0,			  /* Initialized later. */
+	.con_in_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
+	.con_in		= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
+	.con_out_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
+	.con_out	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
+	.stderr_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
+	.stderr		= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
+	.runtime	= (efi_runtime_services_t *)EFI_INVALID_TABLE_ADDR,
+						  /* Not used under Xen. */
+	.boottime	= (efi_boot_services_t *)EFI_INVALID_TABLE_ADDR,
+						  /* Not used under Xen. */
+	.nr_tables	= 0,			  /* Initialized later. */
+	.tables		= EFI_INVALID_TABLE_ADDR  /* Initialized later. */
+};
+
+static const struct efi efi_xen __initconst = {
+	.systab                   = NULL, /* Initialized later. */
+	.runtime_version	  = 0,    /* Initialized later. */
+	.mps                      = EFI_INVALID_TABLE_ADDR,
+	.acpi                     = EFI_INVALID_TABLE_ADDR,
+	.acpi20                   = EFI_INVALID_TABLE_ADDR,
+	.smbios                   = EFI_INVALID_TABLE_ADDR,
+	.smbios3                  = EFI_INVALID_TABLE_ADDR,
+	.sal_systab               = EFI_INVALID_TABLE_ADDR,
+	.boot_info                = EFI_INVALID_TABLE_ADDR,
+	.hcdp                     = EFI_INVALID_TABLE_ADDR,
+	.uga                      = EFI_INVALID_TABLE_ADDR,
+	.uv_systab                = EFI_INVALID_TABLE_ADDR,
+	.fw_vendor                = EFI_INVALID_TABLE_ADDR,
+	.runtime                  = EFI_INVALID_TABLE_ADDR,
+	.config_table             = EFI_INVALID_TABLE_ADDR,
+	.get_time                 = xen_efi_get_time,
+	.set_time                 = xen_efi_set_time,
+	.get_wakeup_time          = xen_efi_get_wakeup_time,
+	.set_wakeup_time          = xen_efi_set_wakeup_time,
+	.get_variable             = xen_efi_get_variable,
+	.get_next_variable        = xen_efi_get_next_variable,
+	.set_variable             = xen_efi_set_variable,
+	.query_variable_info      = xen_efi_query_variable_info,
+	.update_capsule           = xen_efi_update_capsule,
+	.query_capsule_caps       = xen_efi_query_capsule_caps,
+	.get_next_high_mono_count = xen_efi_get_next_high_mono_count,
+	.reset_system             = NULL, /* Functionality provided by Xen. */
+	.set_virtual_address_map  = NULL, /* Not used under Xen. */
+	.memmap                   = NULL, /* Not used under Xen. */
+	.flags			  = 0     /* Initialized later. */
+};
+
+static efi_system_table_t __init *xen_efi_probe(void)
+{
+	struct xen_platform_op op = {
+		.cmd = XENPF_firmware_info,
+		.u.firmware_info = {
+			.type = XEN_FW_EFI_INFO,
+			.index = XEN_FW_EFI_CONFIG_TABLE
+		}
+	};
+	union xenpf_efi_info *info = &op.u.firmware_info.u.efi_info;
+
+	if (!xen_initial_domain() || HYPERVISOR_platform_op(&op) < 0)
+		return NULL;
+
+	/* Here we know that Xen runs on EFI platform. */
+
+	efi = efi_xen;
+
+	efi_systab_xen.tables = info->cfg.addr;
+	efi_systab_xen.nr_tables = info->cfg.nent;
+
+	op.cmd = XENPF_firmware_info;
+	op.u.firmware_info.type = XEN_FW_EFI_INFO;
+	op.u.firmware_info.index = XEN_FW_EFI_VENDOR;
+	info->vendor.bufsz = sizeof(vendor);
+	set_xen_guest_handle(info->vendor.name, vendor);
+
+	if (HYPERVISOR_platform_op(&op) == 0) {
+		efi_systab_xen.fw_vendor = __pa_symbol(vendor);
+		efi_systab_xen.fw_revision = info->vendor.revision;
+	} else
+		efi_systab_xen.fw_vendor = __pa_symbol(L"UNKNOWN");
+
+	op.cmd = XENPF_firmware_info;
+	op.u.firmware_info.type = XEN_FW_EFI_INFO;
+	op.u.firmware_info.index = XEN_FW_EFI_VERSION;
+
+	if (HYPERVISOR_platform_op(&op) == 0)
+		efi_systab_xen.hdr.revision = info->version;
+
+	op.cmd = XENPF_firmware_info;
+	op.u.firmware_info.type = XEN_FW_EFI_INFO;
+	op.u.firmware_info.index = XEN_FW_EFI_RT_VERSION;
+
+	if (HYPERVISOR_platform_op(&op) == 0)
+		efi.runtime_version = info->version;
+
+	return &efi_systab_xen;
+}
 
 void __init xen_efi_init(void)
 {
diff --git a/drivers/xen/efi.c b/drivers/xen/efi.c
index be7e56a..22f71ff 100644
--- a/drivers/xen/efi.c
+++ b/drivers/xen/efi.c
@@ -38,7 +38,7 @@
 
 #define efi_data(op)	(op.u.efi_runtime_call)
 
-static efi_status_t xen_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc)
+efi_status_t xen_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc)
 {
 	struct xen_platform_op op = INIT_EFI_OP(get_time);
 
@@ -59,8 +59,9 @@ static efi_status_t xen_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc)
 
 	return efi_data(op).status;
 }
+EXPORT_SYMBOL_GPL(xen_efi_get_time);
 
-static efi_status_t xen_efi_set_time(efi_time_t *tm)
+efi_status_t xen_efi_set_time(efi_time_t *tm)
 {
 	struct xen_platform_op op = INIT_EFI_OP(set_time);
 
@@ -72,10 +73,10 @@ static efi_status_t xen_efi_set_time(efi_time_t *tm)
 
 	return efi_data(op).status;
 }
+EXPORT_SYMBOL_GPL(xen_efi_set_time);
 
-static efi_status_t xen_efi_get_wakeup_time(efi_bool_t *enabled,
-					    efi_bool_t *pending,
-					    efi_time_t *tm)
+efi_status_t xen_efi_get_wakeup_time(efi_bool_t *enabled, efi_bool_t *pending,
+				     efi_time_t *tm)
 {
 	struct xen_platform_op op = INIT_EFI_OP(get_wakeup_time);
 
@@ -95,8 +96,9 @@ static efi_status_t xen_efi_get_wakeup_time(efi_bool_t *enabled,
 
 	return efi_data(op).status;
 }
+EXPORT_SYMBOL_GPL(xen_efi_get_wakeup_time);
 
-static efi_status_t xen_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm)
+efi_status_t xen_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm)
 {
 	struct xen_platform_op op = INIT_EFI_OP(set_wakeup_time);
 
@@ -113,12 +115,11 @@ static efi_status_t xen_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm)
 
 	return efi_data(op).status;
 }
+EXPORT_SYMBOL_GPL(xen_efi_set_wakeup_time);
 
-static efi_status_t xen_efi_get_variable(efi_char16_t *name,
-					 efi_guid_t *vendor,
-					 u32 *attr,
-					 unsigned long *data_size,
-					 void *data)
+efi_status_t xen_efi_get_variable(efi_char16_t *name, efi_guid_t *vendor,
+				  u32 *attr, unsigned long *data_size,
+				  void *data)
 {
 	struct xen_platform_op op = INIT_EFI_OP(get_variable);
 
@@ -138,10 +139,11 @@ static efi_status_t xen_efi_get_variable(efi_char16_t *name,
 
 	return efi_data(op).status;
 }
+EXPORT_SYMBOL_GPL(xen_efi_get_variable);
 
-static efi_status_t xen_efi_get_next_variable(unsigned long *name_size,
-					      efi_char16_t *name,
-					      efi_guid_t *vendor)
+efi_status_t xen_efi_get_next_variable(unsigned long *name_size,
+				       efi_char16_t *name,
+				       efi_guid_t *vendor)
 {
 	struct xen_platform_op op = INIT_EFI_OP(get_next_variable_name);
 
@@ -161,12 +163,11 @@ static efi_status_t xen_efi_get_next_variable(unsigned long *name_size,
 
 	return efi_data(op).status;
 }
+EXPORT_SYMBOL_GPL(xen_efi_get_next_variable);
 
-static efi_status_t xen_efi_set_variable(efi_char16_t *name,
-					 efi_guid_t *vendor,
-					 u32 attr,
-					 unsigned long data_size,
-					 void *data)
+efi_status_t xen_efi_set_variable(efi_char16_t *name, efi_guid_t *vendor,
+				 u32 attr, unsigned long data_size,
+				 void *data)
 {
 	struct xen_platform_op op = INIT_EFI_OP(set_variable);
 
@@ -183,11 +184,11 @@ static efi_status_t xen_efi_set_variable(efi_char16_t *name,
 
 	return efi_data(op).status;
 }
+EXPORT_SYMBOL_GPL(xen_efi_set_variable);
 
-static efi_status_t xen_efi_query_variable_info(u32 attr,
-						u64 *storage_space,
-						u64 *remaining_space,
-						u64 *max_variable_size)
+efi_status_t xen_efi_query_variable_info(u32 attr, u64 *storage_space,
+					 u64 *remaining_space,
+					 u64 *max_variable_size)
 {
 	struct xen_platform_op op = INIT_EFI_OP(query_variable_info);
 
@@ -205,8 +206,9 @@ static efi_status_t xen_efi_query_variable_info(u32 attr,
 
 	return efi_data(op).status;
 }
+EXPORT_SYMBOL_GPL(xen_efi_query_variable_info);
 
-static efi_status_t xen_efi_get_next_high_mono_count(u32 *count)
+efi_status_t xen_efi_get_next_high_mono_count(u32 *count)
 {
 	struct xen_platform_op op = INIT_EFI_OP(get_next_high_monotonic_count);
 
@@ -217,10 +219,10 @@ static efi_status_t xen_efi_get_next_high_mono_count(u32 *count)
 
 	return efi_data(op).status;
 }
+EXPORT_SYMBOL_GPL(xen_efi_get_next_high_mono_count);
 
-static efi_status_t xen_efi_update_capsule(efi_capsule_header_t **capsules,
-					   unsigned long count,
-					   unsigned long sg_list)
+efi_status_t xen_efi_update_capsule(efi_capsule_header_t **capsules,
+				    unsigned long count, unsigned long sg_list)
 {
 	struct xen_platform_op op = INIT_EFI_OP(update_capsule);
 
@@ -237,11 +239,11 @@ static efi_status_t xen_efi_update_capsule(efi_capsule_header_t **capsules,
 
 	return efi_data(op).status;
 }
+EXPORT_SYMBOL_GPL(xen_efi_update_capsule);
 
-static efi_status_t xen_efi_query_capsule_caps(efi_capsule_header_t **capsules,
-					       unsigned long count,
-					       u64 *max_size,
-					       int *reset_type)
+efi_status_t xen_efi_query_capsule_caps(efi_capsule_header_t **capsules,
+					unsigned long count, u64 *max_size,
+					int *reset_type)
 {
 	struct xen_platform_op op = INIT_EFI_OP(query_capsule_capabilities);
 
@@ -260,112 +262,4 @@ static efi_status_t xen_efi_query_capsule_caps(efi_capsule_header_t **capsules,
 
 	return efi_data(op).status;
 }
-
-static efi_char16_t vendor[100] __initdata;
-
-static efi_system_table_t efi_systab_xen __initdata = {
-	.hdr = {
-		.signature	= EFI_SYSTEM_TABLE_SIGNATURE,
-		.revision	= 0, /* Initialized later. */
-		.headersize	= 0, /* Ignored by Linux Kernel. */
-		.crc32		= 0, /* Ignored by Linux Kernel. */
-		.reserved	= 0
-	},
-	.fw_vendor	= EFI_INVALID_TABLE_ADDR, /* Initialized later. */
-	.fw_revision	= 0,			  /* Initialized later. */
-	.con_in_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
-	.con_in		= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
-	.con_out_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
-	.con_out	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
-	.stderr_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
-	.stderr		= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
-	.runtime	= (efi_runtime_services_t *)EFI_INVALID_TABLE_ADDR,
-						  /* Not used under Xen. */
-	.boottime	= (efi_boot_services_t *)EFI_INVALID_TABLE_ADDR,
-						  /* Not used under Xen. */
-	.nr_tables	= 0,			  /* Initialized later. */
-	.tables		= EFI_INVALID_TABLE_ADDR  /* Initialized later. */
-};
-
-static const struct efi efi_xen __initconst = {
-	.systab                   = NULL, /* Initialized later. */
-	.runtime_version	  = 0,    /* Initialized later. */
-	.mps                      = EFI_INVALID_TABLE_ADDR,
-	.acpi                     = EFI_INVALID_TABLE_ADDR,
-	.acpi20                   = EFI_INVALID_TABLE_ADDR,
-	.smbios                   = EFI_INVALID_TABLE_ADDR,
-	.smbios3                  = EFI_INVALID_TABLE_ADDR,
-	.sal_systab               = EFI_INVALID_TABLE_ADDR,
-	.boot_info                = EFI_INVALID_TABLE_ADDR,
-	.hcdp                     = EFI_INVALID_TABLE_ADDR,
-	.uga                      = EFI_INVALID_TABLE_ADDR,
-	.uv_systab                = EFI_INVALID_TABLE_ADDR,
-	.fw_vendor                = EFI_INVALID_TABLE_ADDR,
-	.runtime                  = EFI_INVALID_TABLE_ADDR,
-	.config_table             = EFI_INVALID_TABLE_ADDR,
-	.get_time                 = xen_efi_get_time,
-	.set_time                 = xen_efi_set_time,
-	.get_wakeup_time          = xen_efi_get_wakeup_time,
-	.set_wakeup_time          = xen_efi_set_wakeup_time,
-	.get_variable             = xen_efi_get_variable,
-	.get_next_variable        = xen_efi_get_next_variable,
-	.set_variable             = xen_efi_set_variable,
-	.query_variable_info      = xen_efi_query_variable_info,
-	.update_capsule           = xen_efi_update_capsule,
-	.query_capsule_caps       = xen_efi_query_capsule_caps,
-	.get_next_high_mono_count = xen_efi_get_next_high_mono_count,
-	.reset_system             = NULL, /* Functionality provided by Xen. */
-	.set_virtual_address_map  = NULL, /* Not used under Xen. */
-	.memmap                   = NULL, /* Not used under Xen. */
-	.flags			  = 0     /* Initialized later. */
-};
-
-efi_system_table_t __init *xen_efi_probe(void)
-{
-	struct xen_platform_op op = {
-		.cmd = XENPF_firmware_info,
-		.u.firmware_info = {
-			.type = XEN_FW_EFI_INFO,
-			.index = XEN_FW_EFI_CONFIG_TABLE
-		}
-	};
-	union xenpf_efi_info *info = &op.u.firmware_info.u.efi_info;
-
-	if (!xen_initial_domain() || HYPERVISOR_platform_op(&op) < 0)
-		return NULL;
-
-	/* Here we know that Xen runs on EFI platform. */
-
-	efi = efi_xen;
-
-	efi_systab_xen.tables = info->cfg.addr;
-	efi_systab_xen.nr_tables = info->cfg.nent;
-
-	op.cmd = XENPF_firmware_info;
-	op.u.firmware_info.type = XEN_FW_EFI_INFO;
-	op.u.firmware_info.index = XEN_FW_EFI_VENDOR;
-	info->vendor.bufsz = sizeof(vendor);
-	set_xen_guest_handle(info->vendor.name, vendor);
-
-	if (HYPERVISOR_platform_op(&op) == 0) {
-		efi_systab_xen.fw_vendor = __pa_symbol(vendor);
-		efi_systab_xen.fw_revision = info->vendor.revision;
-	} else
-		efi_systab_xen.fw_vendor = __pa_symbol(L"UNKNOWN");
-
-	op.cmd = XENPF_firmware_info;
-	op.u.firmware_info.type = XEN_FW_EFI_INFO;
-	op.u.firmware_info.index = XEN_FW_EFI_VERSION;
-
-	if (HYPERVISOR_platform_op(&op) == 0)
-		efi_systab_xen.hdr.revision = info->version;
-
-	op.cmd = XENPF_firmware_info;
-	op.u.firmware_info.type = XEN_FW_EFI_INFO;
-	op.u.firmware_info.index = XEN_FW_EFI_RT_VERSION;
-
-	if (HYPERVISOR_platform_op(&op) == 0)
-		efi.runtime_version = info->version;
-
-	return &efi_systab_xen;
-}
+EXPORT_SYMBOL_GPL(xen_efi_query_capsule_caps);
diff --git a/include/xen/xen-ops.h b/include/xen/xen-ops.h
index 42be31a..c83a338 100644
--- a/include/xen/xen-ops.h
+++ b/include/xen/xen-ops.h
@@ -85,14 +85,28 @@ int xen_xlate_map_ballooned_pages(xen_pfn_t **pfns, void **vaddr,
 
 bool xen_running_on_version_or_later(unsigned int major, unsigned int minor);
 
-#ifdef CONFIG_XEN_EFI
-extern efi_system_table_t *xen_efi_probe(void);
-#else
-static inline efi_system_table_t __init *xen_efi_probe(void)
-{
-	return NULL;
-}
-#endif
+efi_status_t xen_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc);
+efi_status_t xen_efi_set_time(efi_time_t *tm);
+efi_status_t xen_efi_get_wakeup_time(efi_bool_t *enabled, efi_bool_t *pending,
+				     efi_time_t *tm);
+efi_status_t xen_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm);
+efi_status_t xen_efi_get_variable(efi_char16_t *name, efi_guid_t *vendor,
+				  u32 *attr, unsigned long *data_size,
+				  void *data);
+efi_status_t xen_efi_get_next_variable(unsigned long *name_size,
+				       efi_char16_t *name, efi_guid_t *vendor);
+efi_status_t xen_efi_set_variable(efi_char16_t *name, efi_guid_t *vendor,
+				  u32 attr, unsigned long data_size,
+				  void *data);
+efi_status_t xen_efi_query_variable_info(u32 attr, u64 *storage_space,
+					 u64 *remaining_space,
+					 u64 *max_variable_size);
+efi_status_t xen_efi_get_next_high_mono_count(u32 *count);
+efi_status_t xen_efi_update_capsule(efi_capsule_header_t **capsules,
+				    unsigned long count, unsigned long sg_list);
+efi_status_t xen_efi_query_capsule_caps(efi_capsule_header_t **capsules,
+					unsigned long count, u64 *max_size,
+					int *reset_type);
 
 #ifdef CONFIG_PREEMPT
 
-- 
2.0.4

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

* [PATCH v3 14/17] XEN: EFI: Move x86 specific codes to architecture directory
@ 2016-01-23  3:19   ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: devicetree, linux-efi, ian.campbell, catalin.marinas,
	will.deacon, linux-kernel, xen-devel, julien.grall, shannon.zhao,
	peter.huangpeng

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

Move x86 specific codes to architecture directory and export those EFI
runtime service functions. This will be useful for initializing runtime
service on ARM later.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 arch/x86/xen/efi.c    | 112 ++++++++++++++++++++++++++++++++
 drivers/xen/efi.c     | 174 ++++++++++----------------------------------------
 include/xen/xen-ops.h |  30 ++++++---
 3 files changed, 168 insertions(+), 148 deletions(-)

diff --git a/arch/x86/xen/efi.c b/arch/x86/xen/efi.c
index be14cc3..86527f1 100644
--- a/arch/x86/xen/efi.c
+++ b/arch/x86/xen/efi.c
@@ -20,10 +20,122 @@
 #include <linux/init.h>
 #include <linux/string.h>
 
+#include <xen/xen.h>
 #include <xen/xen-ops.h>
+#include <xen/interface/platform.h>
 
 #include <asm/page.h>
 #include <asm/setup.h>
+#include <asm/xen/hypercall.h>
+
+static efi_char16_t vendor[100] __initdata;
+
+static efi_system_table_t efi_systab_xen __initdata = {
+	.hdr = {
+		.signature	= EFI_SYSTEM_TABLE_SIGNATURE,
+		.revision	= 0, /* Initialized later. */
+		.headersize	= 0, /* Ignored by Linux Kernel. */
+		.crc32		= 0, /* Ignored by Linux Kernel. */
+		.reserved	= 0
+	},
+	.fw_vendor	= EFI_INVALID_TABLE_ADDR, /* Initialized later. */
+	.fw_revision	= 0,			  /* Initialized later. */
+	.con_in_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
+	.con_in		= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
+	.con_out_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
+	.con_out	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
+	.stderr_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
+	.stderr		= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
+	.runtime	= (efi_runtime_services_t *)EFI_INVALID_TABLE_ADDR,
+						  /* Not used under Xen. */
+	.boottime	= (efi_boot_services_t *)EFI_INVALID_TABLE_ADDR,
+						  /* Not used under Xen. */
+	.nr_tables	= 0,			  /* Initialized later. */
+	.tables		= EFI_INVALID_TABLE_ADDR  /* Initialized later. */
+};
+
+static const struct efi efi_xen __initconst = {
+	.systab                   = NULL, /* Initialized later. */
+	.runtime_version	  = 0,    /* Initialized later. */
+	.mps                      = EFI_INVALID_TABLE_ADDR,
+	.acpi                     = EFI_INVALID_TABLE_ADDR,
+	.acpi20                   = EFI_INVALID_TABLE_ADDR,
+	.smbios                   = EFI_INVALID_TABLE_ADDR,
+	.smbios3                  = EFI_INVALID_TABLE_ADDR,
+	.sal_systab               = EFI_INVALID_TABLE_ADDR,
+	.boot_info                = EFI_INVALID_TABLE_ADDR,
+	.hcdp                     = EFI_INVALID_TABLE_ADDR,
+	.uga                      = EFI_INVALID_TABLE_ADDR,
+	.uv_systab                = EFI_INVALID_TABLE_ADDR,
+	.fw_vendor                = EFI_INVALID_TABLE_ADDR,
+	.runtime                  = EFI_INVALID_TABLE_ADDR,
+	.config_table             = EFI_INVALID_TABLE_ADDR,
+	.get_time                 = xen_efi_get_time,
+	.set_time                 = xen_efi_set_time,
+	.get_wakeup_time          = xen_efi_get_wakeup_time,
+	.set_wakeup_time          = xen_efi_set_wakeup_time,
+	.get_variable             = xen_efi_get_variable,
+	.get_next_variable        = xen_efi_get_next_variable,
+	.set_variable             = xen_efi_set_variable,
+	.query_variable_info      = xen_efi_query_variable_info,
+	.update_capsule           = xen_efi_update_capsule,
+	.query_capsule_caps       = xen_efi_query_capsule_caps,
+	.get_next_high_mono_count = xen_efi_get_next_high_mono_count,
+	.reset_system             = NULL, /* Functionality provided by Xen. */
+	.set_virtual_address_map  = NULL, /* Not used under Xen. */
+	.memmap                   = NULL, /* Not used under Xen. */
+	.flags			  = 0     /* Initialized later. */
+};
+
+static efi_system_table_t __init *xen_efi_probe(void)
+{
+	struct xen_platform_op op = {
+		.cmd = XENPF_firmware_info,
+		.u.firmware_info = {
+			.type = XEN_FW_EFI_INFO,
+			.index = XEN_FW_EFI_CONFIG_TABLE
+		}
+	};
+	union xenpf_efi_info *info = &op.u.firmware_info.u.efi_info;
+
+	if (!xen_initial_domain() || HYPERVISOR_platform_op(&op) < 0)
+		return NULL;
+
+	/* Here we know that Xen runs on EFI platform. */
+
+	efi = efi_xen;
+
+	efi_systab_xen.tables = info->cfg.addr;
+	efi_systab_xen.nr_tables = info->cfg.nent;
+
+	op.cmd = XENPF_firmware_info;
+	op.u.firmware_info.type = XEN_FW_EFI_INFO;
+	op.u.firmware_info.index = XEN_FW_EFI_VENDOR;
+	info->vendor.bufsz = sizeof(vendor);
+	set_xen_guest_handle(info->vendor.name, vendor);
+
+	if (HYPERVISOR_platform_op(&op) == 0) {
+		efi_systab_xen.fw_vendor = __pa_symbol(vendor);
+		efi_systab_xen.fw_revision = info->vendor.revision;
+	} else
+		efi_systab_xen.fw_vendor = __pa_symbol(L"UNKNOWN");
+
+	op.cmd = XENPF_firmware_info;
+	op.u.firmware_info.type = XEN_FW_EFI_INFO;
+	op.u.firmware_info.index = XEN_FW_EFI_VERSION;
+
+	if (HYPERVISOR_platform_op(&op) == 0)
+		efi_systab_xen.hdr.revision = info->version;
+
+	op.cmd = XENPF_firmware_info;
+	op.u.firmware_info.type = XEN_FW_EFI_INFO;
+	op.u.firmware_info.index = XEN_FW_EFI_RT_VERSION;
+
+	if (HYPERVISOR_platform_op(&op) == 0)
+		efi.runtime_version = info->version;
+
+	return &efi_systab_xen;
+}
 
 void __init xen_efi_init(void)
 {
diff --git a/drivers/xen/efi.c b/drivers/xen/efi.c
index be7e56a..22f71ff 100644
--- a/drivers/xen/efi.c
+++ b/drivers/xen/efi.c
@@ -38,7 +38,7 @@
 
 #define efi_data(op)	(op.u.efi_runtime_call)
 
-static efi_status_t xen_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc)
+efi_status_t xen_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc)
 {
 	struct xen_platform_op op = INIT_EFI_OP(get_time);
 
@@ -59,8 +59,9 @@ static efi_status_t xen_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc)
 
 	return efi_data(op).status;
 }
+EXPORT_SYMBOL_GPL(xen_efi_get_time);
 
-static efi_status_t xen_efi_set_time(efi_time_t *tm)
+efi_status_t xen_efi_set_time(efi_time_t *tm)
 {
 	struct xen_platform_op op = INIT_EFI_OP(set_time);
 
@@ -72,10 +73,10 @@ static efi_status_t xen_efi_set_time(efi_time_t *tm)
 
 	return efi_data(op).status;
 }
+EXPORT_SYMBOL_GPL(xen_efi_set_time);
 
-static efi_status_t xen_efi_get_wakeup_time(efi_bool_t *enabled,
-					    efi_bool_t *pending,
-					    efi_time_t *tm)
+efi_status_t xen_efi_get_wakeup_time(efi_bool_t *enabled, efi_bool_t *pending,
+				     efi_time_t *tm)
 {
 	struct xen_platform_op op = INIT_EFI_OP(get_wakeup_time);
 
@@ -95,8 +96,9 @@ static efi_status_t xen_efi_get_wakeup_time(efi_bool_t *enabled,
 
 	return efi_data(op).status;
 }
+EXPORT_SYMBOL_GPL(xen_efi_get_wakeup_time);
 
-static efi_status_t xen_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm)
+efi_status_t xen_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm)
 {
 	struct xen_platform_op op = INIT_EFI_OP(set_wakeup_time);
 
@@ -113,12 +115,11 @@ static efi_status_t xen_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm)
 
 	return efi_data(op).status;
 }
+EXPORT_SYMBOL_GPL(xen_efi_set_wakeup_time);
 
-static efi_status_t xen_efi_get_variable(efi_char16_t *name,
-					 efi_guid_t *vendor,
-					 u32 *attr,
-					 unsigned long *data_size,
-					 void *data)
+efi_status_t xen_efi_get_variable(efi_char16_t *name, efi_guid_t *vendor,
+				  u32 *attr, unsigned long *data_size,
+				  void *data)
 {
 	struct xen_platform_op op = INIT_EFI_OP(get_variable);
 
@@ -138,10 +139,11 @@ static efi_status_t xen_efi_get_variable(efi_char16_t *name,
 
 	return efi_data(op).status;
 }
+EXPORT_SYMBOL_GPL(xen_efi_get_variable);
 
-static efi_status_t xen_efi_get_next_variable(unsigned long *name_size,
-					      efi_char16_t *name,
-					      efi_guid_t *vendor)
+efi_status_t xen_efi_get_next_variable(unsigned long *name_size,
+				       efi_char16_t *name,
+				       efi_guid_t *vendor)
 {
 	struct xen_platform_op op = INIT_EFI_OP(get_next_variable_name);
 
@@ -161,12 +163,11 @@ static efi_status_t xen_efi_get_next_variable(unsigned long *name_size,
 
 	return efi_data(op).status;
 }
+EXPORT_SYMBOL_GPL(xen_efi_get_next_variable);
 
-static efi_status_t xen_efi_set_variable(efi_char16_t *name,
-					 efi_guid_t *vendor,
-					 u32 attr,
-					 unsigned long data_size,
-					 void *data)
+efi_status_t xen_efi_set_variable(efi_char16_t *name, efi_guid_t *vendor,
+				 u32 attr, unsigned long data_size,
+				 void *data)
 {
 	struct xen_platform_op op = INIT_EFI_OP(set_variable);
 
@@ -183,11 +184,11 @@ static efi_status_t xen_efi_set_variable(efi_char16_t *name,
 
 	return efi_data(op).status;
 }
+EXPORT_SYMBOL_GPL(xen_efi_set_variable);
 
-static efi_status_t xen_efi_query_variable_info(u32 attr,
-						u64 *storage_space,
-						u64 *remaining_space,
-						u64 *max_variable_size)
+efi_status_t xen_efi_query_variable_info(u32 attr, u64 *storage_space,
+					 u64 *remaining_space,
+					 u64 *max_variable_size)
 {
 	struct xen_platform_op op = INIT_EFI_OP(query_variable_info);
 
@@ -205,8 +206,9 @@ static efi_status_t xen_efi_query_variable_info(u32 attr,
 
 	return efi_data(op).status;
 }
+EXPORT_SYMBOL_GPL(xen_efi_query_variable_info);
 
-static efi_status_t xen_efi_get_next_high_mono_count(u32 *count)
+efi_status_t xen_efi_get_next_high_mono_count(u32 *count)
 {
 	struct xen_platform_op op = INIT_EFI_OP(get_next_high_monotonic_count);
 
@@ -217,10 +219,10 @@ static efi_status_t xen_efi_get_next_high_mono_count(u32 *count)
 
 	return efi_data(op).status;
 }
+EXPORT_SYMBOL_GPL(xen_efi_get_next_high_mono_count);
 
-static efi_status_t xen_efi_update_capsule(efi_capsule_header_t **capsules,
-					   unsigned long count,
-					   unsigned long sg_list)
+efi_status_t xen_efi_update_capsule(efi_capsule_header_t **capsules,
+				    unsigned long count, unsigned long sg_list)
 {
 	struct xen_platform_op op = INIT_EFI_OP(update_capsule);
 
@@ -237,11 +239,11 @@ static efi_status_t xen_efi_update_capsule(efi_capsule_header_t **capsules,
 
 	return efi_data(op).status;
 }
+EXPORT_SYMBOL_GPL(xen_efi_update_capsule);
 
-static efi_status_t xen_efi_query_capsule_caps(efi_capsule_header_t **capsules,
-					       unsigned long count,
-					       u64 *max_size,
-					       int *reset_type)
+efi_status_t xen_efi_query_capsule_caps(efi_capsule_header_t **capsules,
+					unsigned long count, u64 *max_size,
+					int *reset_type)
 {
 	struct xen_platform_op op = INIT_EFI_OP(query_capsule_capabilities);
 
@@ -260,112 +262,4 @@ static efi_status_t xen_efi_query_capsule_caps(efi_capsule_header_t **capsules,
 
 	return efi_data(op).status;
 }
-
-static efi_char16_t vendor[100] __initdata;
-
-static efi_system_table_t efi_systab_xen __initdata = {
-	.hdr = {
-		.signature	= EFI_SYSTEM_TABLE_SIGNATURE,
-		.revision	= 0, /* Initialized later. */
-		.headersize	= 0, /* Ignored by Linux Kernel. */
-		.crc32		= 0, /* Ignored by Linux Kernel. */
-		.reserved	= 0
-	},
-	.fw_vendor	= EFI_INVALID_TABLE_ADDR, /* Initialized later. */
-	.fw_revision	= 0,			  /* Initialized later. */
-	.con_in_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
-	.con_in		= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
-	.con_out_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
-	.con_out	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
-	.stderr_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
-	.stderr		= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
-	.runtime	= (efi_runtime_services_t *)EFI_INVALID_TABLE_ADDR,
-						  /* Not used under Xen. */
-	.boottime	= (efi_boot_services_t *)EFI_INVALID_TABLE_ADDR,
-						  /* Not used under Xen. */
-	.nr_tables	= 0,			  /* Initialized later. */
-	.tables		= EFI_INVALID_TABLE_ADDR  /* Initialized later. */
-};
-
-static const struct efi efi_xen __initconst = {
-	.systab                   = NULL, /* Initialized later. */
-	.runtime_version	  = 0,    /* Initialized later. */
-	.mps                      = EFI_INVALID_TABLE_ADDR,
-	.acpi                     = EFI_INVALID_TABLE_ADDR,
-	.acpi20                   = EFI_INVALID_TABLE_ADDR,
-	.smbios                   = EFI_INVALID_TABLE_ADDR,
-	.smbios3                  = EFI_INVALID_TABLE_ADDR,
-	.sal_systab               = EFI_INVALID_TABLE_ADDR,
-	.boot_info                = EFI_INVALID_TABLE_ADDR,
-	.hcdp                     = EFI_INVALID_TABLE_ADDR,
-	.uga                      = EFI_INVALID_TABLE_ADDR,
-	.uv_systab                = EFI_INVALID_TABLE_ADDR,
-	.fw_vendor                = EFI_INVALID_TABLE_ADDR,
-	.runtime                  = EFI_INVALID_TABLE_ADDR,
-	.config_table             = EFI_INVALID_TABLE_ADDR,
-	.get_time                 = xen_efi_get_time,
-	.set_time                 = xen_efi_set_time,
-	.get_wakeup_time          = xen_efi_get_wakeup_time,
-	.set_wakeup_time          = xen_efi_set_wakeup_time,
-	.get_variable             = xen_efi_get_variable,
-	.get_next_variable        = xen_efi_get_next_variable,
-	.set_variable             = xen_efi_set_variable,
-	.query_variable_info      = xen_efi_query_variable_info,
-	.update_capsule           = xen_efi_update_capsule,
-	.query_capsule_caps       = xen_efi_query_capsule_caps,
-	.get_next_high_mono_count = xen_efi_get_next_high_mono_count,
-	.reset_system             = NULL, /* Functionality provided by Xen. */
-	.set_virtual_address_map  = NULL, /* Not used under Xen. */
-	.memmap                   = NULL, /* Not used under Xen. */
-	.flags			  = 0     /* Initialized later. */
-};
-
-efi_system_table_t __init *xen_efi_probe(void)
-{
-	struct xen_platform_op op = {
-		.cmd = XENPF_firmware_info,
-		.u.firmware_info = {
-			.type = XEN_FW_EFI_INFO,
-			.index = XEN_FW_EFI_CONFIG_TABLE
-		}
-	};
-	union xenpf_efi_info *info = &op.u.firmware_info.u.efi_info;
-
-	if (!xen_initial_domain() || HYPERVISOR_platform_op(&op) < 0)
-		return NULL;
-
-	/* Here we know that Xen runs on EFI platform. */
-
-	efi = efi_xen;
-
-	efi_systab_xen.tables = info->cfg.addr;
-	efi_systab_xen.nr_tables = info->cfg.nent;
-
-	op.cmd = XENPF_firmware_info;
-	op.u.firmware_info.type = XEN_FW_EFI_INFO;
-	op.u.firmware_info.index = XEN_FW_EFI_VENDOR;
-	info->vendor.bufsz = sizeof(vendor);
-	set_xen_guest_handle(info->vendor.name, vendor);
-
-	if (HYPERVISOR_platform_op(&op) == 0) {
-		efi_systab_xen.fw_vendor = __pa_symbol(vendor);
-		efi_systab_xen.fw_revision = info->vendor.revision;
-	} else
-		efi_systab_xen.fw_vendor = __pa_symbol(L"UNKNOWN");
-
-	op.cmd = XENPF_firmware_info;
-	op.u.firmware_info.type = XEN_FW_EFI_INFO;
-	op.u.firmware_info.index = XEN_FW_EFI_VERSION;
-
-	if (HYPERVISOR_platform_op(&op) == 0)
-		efi_systab_xen.hdr.revision = info->version;
-
-	op.cmd = XENPF_firmware_info;
-	op.u.firmware_info.type = XEN_FW_EFI_INFO;
-	op.u.firmware_info.index = XEN_FW_EFI_RT_VERSION;
-
-	if (HYPERVISOR_platform_op(&op) == 0)
-		efi.runtime_version = info->version;
-
-	return &efi_systab_xen;
-}
+EXPORT_SYMBOL_GPL(xen_efi_query_capsule_caps);
diff --git a/include/xen/xen-ops.h b/include/xen/xen-ops.h
index 42be31a..c83a338 100644
--- a/include/xen/xen-ops.h
+++ b/include/xen/xen-ops.h
@@ -85,14 +85,28 @@ int xen_xlate_map_ballooned_pages(xen_pfn_t **pfns, void **vaddr,
 
 bool xen_running_on_version_or_later(unsigned int major, unsigned int minor);
 
-#ifdef CONFIG_XEN_EFI
-extern efi_system_table_t *xen_efi_probe(void);
-#else
-static inline efi_system_table_t __init *xen_efi_probe(void)
-{
-	return NULL;
-}
-#endif
+efi_status_t xen_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc);
+efi_status_t xen_efi_set_time(efi_time_t *tm);
+efi_status_t xen_efi_get_wakeup_time(efi_bool_t *enabled, efi_bool_t *pending,
+				     efi_time_t *tm);
+efi_status_t xen_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm);
+efi_status_t xen_efi_get_variable(efi_char16_t *name, efi_guid_t *vendor,
+				  u32 *attr, unsigned long *data_size,
+				  void *data);
+efi_status_t xen_efi_get_next_variable(unsigned long *name_size,
+				       efi_char16_t *name, efi_guid_t *vendor);
+efi_status_t xen_efi_set_variable(efi_char16_t *name, efi_guid_t *vendor,
+				  u32 attr, unsigned long data_size,
+				  void *data);
+efi_status_t xen_efi_query_variable_info(u32 attr, u64 *storage_space,
+					 u64 *remaining_space,
+					 u64 *max_variable_size);
+efi_status_t xen_efi_get_next_high_mono_count(u32 *count);
+efi_status_t xen_efi_update_capsule(efi_capsule_header_t **capsules,
+				    unsigned long count, unsigned long sg_list);
+efi_status_t xen_efi_query_capsule_caps(efi_capsule_header_t **capsules,
+					unsigned long count, u64 *max_size,
+					int *reset_type);
 
 #ifdef CONFIG_PREEMPT
 
-- 
2.0.4

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

* [PATCH v3 14/17] XEN: EFI: Move x86 specific codes to architecture directory
@ 2016-01-23  3:19   ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel

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

Move x86 specific codes to architecture directory and export those EFI
runtime service functions. This will be useful for initializing runtime
service on ARM later.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 arch/x86/xen/efi.c    | 112 ++++++++++++++++++++++++++++++++
 drivers/xen/efi.c     | 174 ++++++++++----------------------------------------
 include/xen/xen-ops.h |  30 ++++++---
 3 files changed, 168 insertions(+), 148 deletions(-)

diff --git a/arch/x86/xen/efi.c b/arch/x86/xen/efi.c
index be14cc3..86527f1 100644
--- a/arch/x86/xen/efi.c
+++ b/arch/x86/xen/efi.c
@@ -20,10 +20,122 @@
 #include <linux/init.h>
 #include <linux/string.h>
 
+#include <xen/xen.h>
 #include <xen/xen-ops.h>
+#include <xen/interface/platform.h>
 
 #include <asm/page.h>
 #include <asm/setup.h>
+#include <asm/xen/hypercall.h>
+
+static efi_char16_t vendor[100] __initdata;
+
+static efi_system_table_t efi_systab_xen __initdata = {
+	.hdr = {
+		.signature	= EFI_SYSTEM_TABLE_SIGNATURE,
+		.revision	= 0, /* Initialized later. */
+		.headersize	= 0, /* Ignored by Linux Kernel. */
+		.crc32		= 0, /* Ignored by Linux Kernel. */
+		.reserved	= 0
+	},
+	.fw_vendor	= EFI_INVALID_TABLE_ADDR, /* Initialized later. */
+	.fw_revision	= 0,			  /* Initialized later. */
+	.con_in_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
+	.con_in		= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
+	.con_out_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
+	.con_out	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
+	.stderr_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
+	.stderr		= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
+	.runtime	= (efi_runtime_services_t *)EFI_INVALID_TABLE_ADDR,
+						  /* Not used under Xen. */
+	.boottime	= (efi_boot_services_t *)EFI_INVALID_TABLE_ADDR,
+						  /* Not used under Xen. */
+	.nr_tables	= 0,			  /* Initialized later. */
+	.tables		= EFI_INVALID_TABLE_ADDR  /* Initialized later. */
+};
+
+static const struct efi efi_xen __initconst = {
+	.systab                   = NULL, /* Initialized later. */
+	.runtime_version	  = 0,    /* Initialized later. */
+	.mps                      = EFI_INVALID_TABLE_ADDR,
+	.acpi                     = EFI_INVALID_TABLE_ADDR,
+	.acpi20                   = EFI_INVALID_TABLE_ADDR,
+	.smbios                   = EFI_INVALID_TABLE_ADDR,
+	.smbios3                  = EFI_INVALID_TABLE_ADDR,
+	.sal_systab               = EFI_INVALID_TABLE_ADDR,
+	.boot_info                = EFI_INVALID_TABLE_ADDR,
+	.hcdp                     = EFI_INVALID_TABLE_ADDR,
+	.uga                      = EFI_INVALID_TABLE_ADDR,
+	.uv_systab                = EFI_INVALID_TABLE_ADDR,
+	.fw_vendor                = EFI_INVALID_TABLE_ADDR,
+	.runtime                  = EFI_INVALID_TABLE_ADDR,
+	.config_table             = EFI_INVALID_TABLE_ADDR,
+	.get_time                 = xen_efi_get_time,
+	.set_time                 = xen_efi_set_time,
+	.get_wakeup_time          = xen_efi_get_wakeup_time,
+	.set_wakeup_time          = xen_efi_set_wakeup_time,
+	.get_variable             = xen_efi_get_variable,
+	.get_next_variable        = xen_efi_get_next_variable,
+	.set_variable             = xen_efi_set_variable,
+	.query_variable_info      = xen_efi_query_variable_info,
+	.update_capsule           = xen_efi_update_capsule,
+	.query_capsule_caps       = xen_efi_query_capsule_caps,
+	.get_next_high_mono_count = xen_efi_get_next_high_mono_count,
+	.reset_system             = NULL, /* Functionality provided by Xen. */
+	.set_virtual_address_map  = NULL, /* Not used under Xen. */
+	.memmap                   = NULL, /* Not used under Xen. */
+	.flags			  = 0     /* Initialized later. */
+};
+
+static efi_system_table_t __init *xen_efi_probe(void)
+{
+	struct xen_platform_op op = {
+		.cmd = XENPF_firmware_info,
+		.u.firmware_info = {
+			.type = XEN_FW_EFI_INFO,
+			.index = XEN_FW_EFI_CONFIG_TABLE
+		}
+	};
+	union xenpf_efi_info *info = &op.u.firmware_info.u.efi_info;
+
+	if (!xen_initial_domain() || HYPERVISOR_platform_op(&op) < 0)
+		return NULL;
+
+	/* Here we know that Xen runs on EFI platform. */
+
+	efi = efi_xen;
+
+	efi_systab_xen.tables = info->cfg.addr;
+	efi_systab_xen.nr_tables = info->cfg.nent;
+
+	op.cmd = XENPF_firmware_info;
+	op.u.firmware_info.type = XEN_FW_EFI_INFO;
+	op.u.firmware_info.index = XEN_FW_EFI_VENDOR;
+	info->vendor.bufsz = sizeof(vendor);
+	set_xen_guest_handle(info->vendor.name, vendor);
+
+	if (HYPERVISOR_platform_op(&op) == 0) {
+		efi_systab_xen.fw_vendor = __pa_symbol(vendor);
+		efi_systab_xen.fw_revision = info->vendor.revision;
+	} else
+		efi_systab_xen.fw_vendor = __pa_symbol(L"UNKNOWN");
+
+	op.cmd = XENPF_firmware_info;
+	op.u.firmware_info.type = XEN_FW_EFI_INFO;
+	op.u.firmware_info.index = XEN_FW_EFI_VERSION;
+
+	if (HYPERVISOR_platform_op(&op) == 0)
+		efi_systab_xen.hdr.revision = info->version;
+
+	op.cmd = XENPF_firmware_info;
+	op.u.firmware_info.type = XEN_FW_EFI_INFO;
+	op.u.firmware_info.index = XEN_FW_EFI_RT_VERSION;
+
+	if (HYPERVISOR_platform_op(&op) == 0)
+		efi.runtime_version = info->version;
+
+	return &efi_systab_xen;
+}
 
 void __init xen_efi_init(void)
 {
diff --git a/drivers/xen/efi.c b/drivers/xen/efi.c
index be7e56a..22f71ff 100644
--- a/drivers/xen/efi.c
+++ b/drivers/xen/efi.c
@@ -38,7 +38,7 @@
 
 #define efi_data(op)	(op.u.efi_runtime_call)
 
-static efi_status_t xen_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc)
+efi_status_t xen_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc)
 {
 	struct xen_platform_op op = INIT_EFI_OP(get_time);
 
@@ -59,8 +59,9 @@ static efi_status_t xen_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc)
 
 	return efi_data(op).status;
 }
+EXPORT_SYMBOL_GPL(xen_efi_get_time);
 
-static efi_status_t xen_efi_set_time(efi_time_t *tm)
+efi_status_t xen_efi_set_time(efi_time_t *tm)
 {
 	struct xen_platform_op op = INIT_EFI_OP(set_time);
 
@@ -72,10 +73,10 @@ static efi_status_t xen_efi_set_time(efi_time_t *tm)
 
 	return efi_data(op).status;
 }
+EXPORT_SYMBOL_GPL(xen_efi_set_time);
 
-static efi_status_t xen_efi_get_wakeup_time(efi_bool_t *enabled,
-					    efi_bool_t *pending,
-					    efi_time_t *tm)
+efi_status_t xen_efi_get_wakeup_time(efi_bool_t *enabled, efi_bool_t *pending,
+				     efi_time_t *tm)
 {
 	struct xen_platform_op op = INIT_EFI_OP(get_wakeup_time);
 
@@ -95,8 +96,9 @@ static efi_status_t xen_efi_get_wakeup_time(efi_bool_t *enabled,
 
 	return efi_data(op).status;
 }
+EXPORT_SYMBOL_GPL(xen_efi_get_wakeup_time);
 
-static efi_status_t xen_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm)
+efi_status_t xen_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm)
 {
 	struct xen_platform_op op = INIT_EFI_OP(set_wakeup_time);
 
@@ -113,12 +115,11 @@ static efi_status_t xen_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm)
 
 	return efi_data(op).status;
 }
+EXPORT_SYMBOL_GPL(xen_efi_set_wakeup_time);
 
-static efi_status_t xen_efi_get_variable(efi_char16_t *name,
-					 efi_guid_t *vendor,
-					 u32 *attr,
-					 unsigned long *data_size,
-					 void *data)
+efi_status_t xen_efi_get_variable(efi_char16_t *name, efi_guid_t *vendor,
+				  u32 *attr, unsigned long *data_size,
+				  void *data)
 {
 	struct xen_platform_op op = INIT_EFI_OP(get_variable);
 
@@ -138,10 +139,11 @@ static efi_status_t xen_efi_get_variable(efi_char16_t *name,
 
 	return efi_data(op).status;
 }
+EXPORT_SYMBOL_GPL(xen_efi_get_variable);
 
-static efi_status_t xen_efi_get_next_variable(unsigned long *name_size,
-					      efi_char16_t *name,
-					      efi_guid_t *vendor)
+efi_status_t xen_efi_get_next_variable(unsigned long *name_size,
+				       efi_char16_t *name,
+				       efi_guid_t *vendor)
 {
 	struct xen_platform_op op = INIT_EFI_OP(get_next_variable_name);
 
@@ -161,12 +163,11 @@ static efi_status_t xen_efi_get_next_variable(unsigned long *name_size,
 
 	return efi_data(op).status;
 }
+EXPORT_SYMBOL_GPL(xen_efi_get_next_variable);
 
-static efi_status_t xen_efi_set_variable(efi_char16_t *name,
-					 efi_guid_t *vendor,
-					 u32 attr,
-					 unsigned long data_size,
-					 void *data)
+efi_status_t xen_efi_set_variable(efi_char16_t *name, efi_guid_t *vendor,
+				 u32 attr, unsigned long data_size,
+				 void *data)
 {
 	struct xen_platform_op op = INIT_EFI_OP(set_variable);
 
@@ -183,11 +184,11 @@ static efi_status_t xen_efi_set_variable(efi_char16_t *name,
 
 	return efi_data(op).status;
 }
+EXPORT_SYMBOL_GPL(xen_efi_set_variable);
 
-static efi_status_t xen_efi_query_variable_info(u32 attr,
-						u64 *storage_space,
-						u64 *remaining_space,
-						u64 *max_variable_size)
+efi_status_t xen_efi_query_variable_info(u32 attr, u64 *storage_space,
+					 u64 *remaining_space,
+					 u64 *max_variable_size)
 {
 	struct xen_platform_op op = INIT_EFI_OP(query_variable_info);
 
@@ -205,8 +206,9 @@ static efi_status_t xen_efi_query_variable_info(u32 attr,
 
 	return efi_data(op).status;
 }
+EXPORT_SYMBOL_GPL(xen_efi_query_variable_info);
 
-static efi_status_t xen_efi_get_next_high_mono_count(u32 *count)
+efi_status_t xen_efi_get_next_high_mono_count(u32 *count)
 {
 	struct xen_platform_op op = INIT_EFI_OP(get_next_high_monotonic_count);
 
@@ -217,10 +219,10 @@ static efi_status_t xen_efi_get_next_high_mono_count(u32 *count)
 
 	return efi_data(op).status;
 }
+EXPORT_SYMBOL_GPL(xen_efi_get_next_high_mono_count);
 
-static efi_status_t xen_efi_update_capsule(efi_capsule_header_t **capsules,
-					   unsigned long count,
-					   unsigned long sg_list)
+efi_status_t xen_efi_update_capsule(efi_capsule_header_t **capsules,
+				    unsigned long count, unsigned long sg_list)
 {
 	struct xen_platform_op op = INIT_EFI_OP(update_capsule);
 
@@ -237,11 +239,11 @@ static efi_status_t xen_efi_update_capsule(efi_capsule_header_t **capsules,
 
 	return efi_data(op).status;
 }
+EXPORT_SYMBOL_GPL(xen_efi_update_capsule);
 
-static efi_status_t xen_efi_query_capsule_caps(efi_capsule_header_t **capsules,
-					       unsigned long count,
-					       u64 *max_size,
-					       int *reset_type)
+efi_status_t xen_efi_query_capsule_caps(efi_capsule_header_t **capsules,
+					unsigned long count, u64 *max_size,
+					int *reset_type)
 {
 	struct xen_platform_op op = INIT_EFI_OP(query_capsule_capabilities);
 
@@ -260,112 +262,4 @@ static efi_status_t xen_efi_query_capsule_caps(efi_capsule_header_t **capsules,
 
 	return efi_data(op).status;
 }
-
-static efi_char16_t vendor[100] __initdata;
-
-static efi_system_table_t efi_systab_xen __initdata = {
-	.hdr = {
-		.signature	= EFI_SYSTEM_TABLE_SIGNATURE,
-		.revision	= 0, /* Initialized later. */
-		.headersize	= 0, /* Ignored by Linux Kernel. */
-		.crc32		= 0, /* Ignored by Linux Kernel. */
-		.reserved	= 0
-	},
-	.fw_vendor	= EFI_INVALID_TABLE_ADDR, /* Initialized later. */
-	.fw_revision	= 0,			  /* Initialized later. */
-	.con_in_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
-	.con_in		= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
-	.con_out_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
-	.con_out	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
-	.stderr_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
-	.stderr		= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
-	.runtime	= (efi_runtime_services_t *)EFI_INVALID_TABLE_ADDR,
-						  /* Not used under Xen. */
-	.boottime	= (efi_boot_services_t *)EFI_INVALID_TABLE_ADDR,
-						  /* Not used under Xen. */
-	.nr_tables	= 0,			  /* Initialized later. */
-	.tables		= EFI_INVALID_TABLE_ADDR  /* Initialized later. */
-};
-
-static const struct efi efi_xen __initconst = {
-	.systab                   = NULL, /* Initialized later. */
-	.runtime_version	  = 0,    /* Initialized later. */
-	.mps                      = EFI_INVALID_TABLE_ADDR,
-	.acpi                     = EFI_INVALID_TABLE_ADDR,
-	.acpi20                   = EFI_INVALID_TABLE_ADDR,
-	.smbios                   = EFI_INVALID_TABLE_ADDR,
-	.smbios3                  = EFI_INVALID_TABLE_ADDR,
-	.sal_systab               = EFI_INVALID_TABLE_ADDR,
-	.boot_info                = EFI_INVALID_TABLE_ADDR,
-	.hcdp                     = EFI_INVALID_TABLE_ADDR,
-	.uga                      = EFI_INVALID_TABLE_ADDR,
-	.uv_systab                = EFI_INVALID_TABLE_ADDR,
-	.fw_vendor                = EFI_INVALID_TABLE_ADDR,
-	.runtime                  = EFI_INVALID_TABLE_ADDR,
-	.config_table             = EFI_INVALID_TABLE_ADDR,
-	.get_time                 = xen_efi_get_time,
-	.set_time                 = xen_efi_set_time,
-	.get_wakeup_time          = xen_efi_get_wakeup_time,
-	.set_wakeup_time          = xen_efi_set_wakeup_time,
-	.get_variable             = xen_efi_get_variable,
-	.get_next_variable        = xen_efi_get_next_variable,
-	.set_variable             = xen_efi_set_variable,
-	.query_variable_info      = xen_efi_query_variable_info,
-	.update_capsule           = xen_efi_update_capsule,
-	.query_capsule_caps       = xen_efi_query_capsule_caps,
-	.get_next_high_mono_count = xen_efi_get_next_high_mono_count,
-	.reset_system             = NULL, /* Functionality provided by Xen. */
-	.set_virtual_address_map  = NULL, /* Not used under Xen. */
-	.memmap                   = NULL, /* Not used under Xen. */
-	.flags			  = 0     /* Initialized later. */
-};
-
-efi_system_table_t __init *xen_efi_probe(void)
-{
-	struct xen_platform_op op = {
-		.cmd = XENPF_firmware_info,
-		.u.firmware_info = {
-			.type = XEN_FW_EFI_INFO,
-			.index = XEN_FW_EFI_CONFIG_TABLE
-		}
-	};
-	union xenpf_efi_info *info = &op.u.firmware_info.u.efi_info;
-
-	if (!xen_initial_domain() || HYPERVISOR_platform_op(&op) < 0)
-		return NULL;
-
-	/* Here we know that Xen runs on EFI platform. */
-
-	efi = efi_xen;
-
-	efi_systab_xen.tables = info->cfg.addr;
-	efi_systab_xen.nr_tables = info->cfg.nent;
-
-	op.cmd = XENPF_firmware_info;
-	op.u.firmware_info.type = XEN_FW_EFI_INFO;
-	op.u.firmware_info.index = XEN_FW_EFI_VENDOR;
-	info->vendor.bufsz = sizeof(vendor);
-	set_xen_guest_handle(info->vendor.name, vendor);
-
-	if (HYPERVISOR_platform_op(&op) == 0) {
-		efi_systab_xen.fw_vendor = __pa_symbol(vendor);
-		efi_systab_xen.fw_revision = info->vendor.revision;
-	} else
-		efi_systab_xen.fw_vendor = __pa_symbol(L"UNKNOWN");
-
-	op.cmd = XENPF_firmware_info;
-	op.u.firmware_info.type = XEN_FW_EFI_INFO;
-	op.u.firmware_info.index = XEN_FW_EFI_VERSION;
-
-	if (HYPERVISOR_platform_op(&op) == 0)
-		efi_systab_xen.hdr.revision = info->version;
-
-	op.cmd = XENPF_firmware_info;
-	op.u.firmware_info.type = XEN_FW_EFI_INFO;
-	op.u.firmware_info.index = XEN_FW_EFI_RT_VERSION;
-
-	if (HYPERVISOR_platform_op(&op) == 0)
-		efi.runtime_version = info->version;
-
-	return &efi_systab_xen;
-}
+EXPORT_SYMBOL_GPL(xen_efi_query_capsule_caps);
diff --git a/include/xen/xen-ops.h b/include/xen/xen-ops.h
index 42be31a..c83a338 100644
--- a/include/xen/xen-ops.h
+++ b/include/xen/xen-ops.h
@@ -85,14 +85,28 @@ int xen_xlate_map_ballooned_pages(xen_pfn_t **pfns, void **vaddr,
 
 bool xen_running_on_version_or_later(unsigned int major, unsigned int minor);
 
-#ifdef CONFIG_XEN_EFI
-extern efi_system_table_t *xen_efi_probe(void);
-#else
-static inline efi_system_table_t __init *xen_efi_probe(void)
-{
-	return NULL;
-}
-#endif
+efi_status_t xen_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc);
+efi_status_t xen_efi_set_time(efi_time_t *tm);
+efi_status_t xen_efi_get_wakeup_time(efi_bool_t *enabled, efi_bool_t *pending,
+				     efi_time_t *tm);
+efi_status_t xen_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm);
+efi_status_t xen_efi_get_variable(efi_char16_t *name, efi_guid_t *vendor,
+				  u32 *attr, unsigned long *data_size,
+				  void *data);
+efi_status_t xen_efi_get_next_variable(unsigned long *name_size,
+				       efi_char16_t *name, efi_guid_t *vendor);
+efi_status_t xen_efi_set_variable(efi_char16_t *name, efi_guid_t *vendor,
+				  u32 attr, unsigned long data_size,
+				  void *data);
+efi_status_t xen_efi_query_variable_info(u32 attr, u64 *storage_space,
+					 u64 *remaining_space,
+					 u64 *max_variable_size);
+efi_status_t xen_efi_get_next_high_mono_count(u32 *count);
+efi_status_t xen_efi_update_capsule(efi_capsule_header_t **capsules,
+				    unsigned long count, unsigned long sg_list);
+efi_status_t xen_efi_query_capsule_caps(efi_capsule_header_t **capsules,
+					unsigned long count, u64 *max_size,
+					int *reset_type);
 
 #ifdef CONFIG_PREEMPT
 
-- 
2.0.4

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

* [PATCH v3 15/17] ARM64: XEN: Add a function to initialize Xen specific UEFI runtime services
  2016-01-23  3:19 ` Shannon Zhao
  (?)
@ 2016-01-23  3:19   ` Shannon Zhao
  -1 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: catalin.marinas, will.deacon, julien.grall, xen-devel,
	devicetree, linux-efi, linux-kernel, ian.campbell, shannon.zhao,
	peter.huangpeng

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

When running on Xen hypervisor, runtime services are supported through
hypercall. Add a Xen specific function to initialize runtime services.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 arch/arm64/include/asm/xen/xen-ops.h |  6 ++++++
 arch/arm64/xen/Makefile              |  1 +
 arch/arm64/xen/efi.c                 | 40 ++++++++++++++++++++++++++++++++++++
 drivers/xen/Kconfig                  |  2 +-
 4 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm64/include/asm/xen/xen-ops.h
 create mode 100644 arch/arm64/xen/efi.c

diff --git a/arch/arm64/include/asm/xen/xen-ops.h b/arch/arm64/include/asm/xen/xen-ops.h
new file mode 100644
index 0000000..ec154e7
--- /dev/null
+++ b/arch/arm64/include/asm/xen/xen-ops.h
@@ -0,0 +1,6 @@
+#ifndef _ASM_XEN_OPS_H
+#define _ASM_XEN_OPS_H
+
+void xen_efi_runtime_setup(void);
+
+#endif /* _ASM_XEN_OPS_H */
diff --git a/arch/arm64/xen/Makefile b/arch/arm64/xen/Makefile
index 74a8d87..62e6fe2 100644
--- a/arch/arm64/xen/Makefile
+++ b/arch/arm64/xen/Makefile
@@ -1,2 +1,3 @@
 xen-arm-y	+= $(addprefix ../../arm/xen/, enlighten.o grant-table.o p2m.o mm.o)
 obj-y		:= xen-arm.o hypercall.o
+obj-$(CONFIG_XEN_EFI) += efi.o
diff --git a/arch/arm64/xen/efi.c b/arch/arm64/xen/efi.c
new file mode 100644
index 0000000..b9cae65
--- /dev/null
+++ b/arch/arm64/xen/efi.c
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2015, Linaro Limited, Shannon Zhao
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <linux/efi.h>
+#include <xen/xen-ops.h>
+#include <asm/xen/xen-ops.h>
+
+/* Set XEN EFI runtime services function pointers. Other fileds of struct efi,
+ * e.g. efi.systab, will be set like normal EFI.
+ */
+void __init xen_efi_runtime_setup(void)
+{
+	efi.get_time                 = xen_efi_get_time;
+	efi.set_time                 = xen_efi_set_time;
+	efi.get_wakeup_time          = xen_efi_get_wakeup_time;
+	efi.set_wakeup_time          = xen_efi_set_wakeup_time;
+	efi.get_variable             = xen_efi_get_variable;
+	efi.get_next_variable        = xen_efi_get_next_variable;
+	efi.set_variable             = xen_efi_set_variable;
+	efi.query_variable_info      = xen_efi_query_variable_info;
+	efi.update_capsule           = xen_efi_update_capsule;
+	efi.query_capsule_caps       = xen_efi_query_capsule_caps;
+	efi.get_next_high_mono_count = xen_efi_get_next_high_mono_count;
+	efi.reset_system             = NULL; /* Functionality provided by Xen. */
+}
+EXPORT_SYMBOL_GPL(xen_efi_runtime_setup);
diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig
index 73708ac..27d216a 100644
--- a/drivers/xen/Kconfig
+++ b/drivers/xen/Kconfig
@@ -268,7 +268,7 @@ config XEN_HAVE_PVMMU
 
 config XEN_EFI
 	def_bool y
-	depends on X86_64 && EFI
+	depends on (ARM64 || X86_64) && EFI
 
 config XEN_AUTO_XLATE
 	def_bool y
-- 
2.0.4

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

* [PATCH v3 15/17] ARM64: XEN: Add a function to initialize Xen specific UEFI runtime services
@ 2016-01-23  3:19   ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: devicetree, linux-efi, ian.campbell, catalin.marinas,
	will.deacon, linux-kernel, xen-devel, julien.grall, shannon.zhao,
	peter.huangpeng

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

When running on Xen hypervisor, runtime services are supported through
hypercall. Add a Xen specific function to initialize runtime services.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 arch/arm64/include/asm/xen/xen-ops.h |  6 ++++++
 arch/arm64/xen/Makefile              |  1 +
 arch/arm64/xen/efi.c                 | 40 ++++++++++++++++++++++++++++++++++++
 drivers/xen/Kconfig                  |  2 +-
 4 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm64/include/asm/xen/xen-ops.h
 create mode 100644 arch/arm64/xen/efi.c

diff --git a/arch/arm64/include/asm/xen/xen-ops.h b/arch/arm64/include/asm/xen/xen-ops.h
new file mode 100644
index 0000000..ec154e7
--- /dev/null
+++ b/arch/arm64/include/asm/xen/xen-ops.h
@@ -0,0 +1,6 @@
+#ifndef _ASM_XEN_OPS_H
+#define _ASM_XEN_OPS_H
+
+void xen_efi_runtime_setup(void);
+
+#endif /* _ASM_XEN_OPS_H */
diff --git a/arch/arm64/xen/Makefile b/arch/arm64/xen/Makefile
index 74a8d87..62e6fe2 100644
--- a/arch/arm64/xen/Makefile
+++ b/arch/arm64/xen/Makefile
@@ -1,2 +1,3 @@
 xen-arm-y	+= $(addprefix ../../arm/xen/, enlighten.o grant-table.o p2m.o mm.o)
 obj-y		:= xen-arm.o hypercall.o
+obj-$(CONFIG_XEN_EFI) += efi.o
diff --git a/arch/arm64/xen/efi.c b/arch/arm64/xen/efi.c
new file mode 100644
index 0000000..b9cae65
--- /dev/null
+++ b/arch/arm64/xen/efi.c
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2015, Linaro Limited, Shannon Zhao
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <linux/efi.h>
+#include <xen/xen-ops.h>
+#include <asm/xen/xen-ops.h>
+
+/* Set XEN EFI runtime services function pointers. Other fileds of struct efi,
+ * e.g. efi.systab, will be set like normal EFI.
+ */
+void __init xen_efi_runtime_setup(void)
+{
+	efi.get_time                 = xen_efi_get_time;
+	efi.set_time                 = xen_efi_set_time;
+	efi.get_wakeup_time          = xen_efi_get_wakeup_time;
+	efi.set_wakeup_time          = xen_efi_set_wakeup_time;
+	efi.get_variable             = xen_efi_get_variable;
+	efi.get_next_variable        = xen_efi_get_next_variable;
+	efi.set_variable             = xen_efi_set_variable;
+	efi.query_variable_info      = xen_efi_query_variable_info;
+	efi.update_capsule           = xen_efi_update_capsule;
+	efi.query_capsule_caps       = xen_efi_query_capsule_caps;
+	efi.get_next_high_mono_count = xen_efi_get_next_high_mono_count;
+	efi.reset_system             = NULL; /* Functionality provided by Xen. */
+}
+EXPORT_SYMBOL_GPL(xen_efi_runtime_setup);
diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig
index 73708ac..27d216a 100644
--- a/drivers/xen/Kconfig
+++ b/drivers/xen/Kconfig
@@ -268,7 +268,7 @@ config XEN_HAVE_PVMMU
 
 config XEN_EFI
 	def_bool y
-	depends on X86_64 && EFI
+	depends on (ARM64 || X86_64) && EFI
 
 config XEN_AUTO_XLATE
 	def_bool y
-- 
2.0.4

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

* [PATCH v3 15/17] ARM64: XEN: Add a function to initialize Xen specific UEFI runtime services
@ 2016-01-23  3:19   ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel

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

When running on Xen hypervisor, runtime services are supported through
hypercall. Add a Xen specific function to initialize runtime services.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 arch/arm64/include/asm/xen/xen-ops.h |  6 ++++++
 arch/arm64/xen/Makefile              |  1 +
 arch/arm64/xen/efi.c                 | 40 ++++++++++++++++++++++++++++++++++++
 drivers/xen/Kconfig                  |  2 +-
 4 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm64/include/asm/xen/xen-ops.h
 create mode 100644 arch/arm64/xen/efi.c

diff --git a/arch/arm64/include/asm/xen/xen-ops.h b/arch/arm64/include/asm/xen/xen-ops.h
new file mode 100644
index 0000000..ec154e7
--- /dev/null
+++ b/arch/arm64/include/asm/xen/xen-ops.h
@@ -0,0 +1,6 @@
+#ifndef _ASM_XEN_OPS_H
+#define _ASM_XEN_OPS_H
+
+void xen_efi_runtime_setup(void);
+
+#endif /* _ASM_XEN_OPS_H */
diff --git a/arch/arm64/xen/Makefile b/arch/arm64/xen/Makefile
index 74a8d87..62e6fe2 100644
--- a/arch/arm64/xen/Makefile
+++ b/arch/arm64/xen/Makefile
@@ -1,2 +1,3 @@
 xen-arm-y	+= $(addprefix ../../arm/xen/, enlighten.o grant-table.o p2m.o mm.o)
 obj-y		:= xen-arm.o hypercall.o
+obj-$(CONFIG_XEN_EFI) += efi.o
diff --git a/arch/arm64/xen/efi.c b/arch/arm64/xen/efi.c
new file mode 100644
index 0000000..b9cae65
--- /dev/null
+++ b/arch/arm64/xen/efi.c
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2015, Linaro Limited, Shannon Zhao
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <linux/efi.h>
+#include <xen/xen-ops.h>
+#include <asm/xen/xen-ops.h>
+
+/* Set XEN EFI runtime services function pointers. Other fileds of struct efi,
+ * e.g. efi.systab, will be set like normal EFI.
+ */
+void __init xen_efi_runtime_setup(void)
+{
+	efi.get_time                 = xen_efi_get_time;
+	efi.set_time                 = xen_efi_set_time;
+	efi.get_wakeup_time          = xen_efi_get_wakeup_time;
+	efi.set_wakeup_time          = xen_efi_set_wakeup_time;
+	efi.get_variable             = xen_efi_get_variable;
+	efi.get_next_variable        = xen_efi_get_next_variable;
+	efi.set_variable             = xen_efi_set_variable;
+	efi.query_variable_info      = xen_efi_query_variable_info;
+	efi.update_capsule           = xen_efi_update_capsule;
+	efi.query_capsule_caps       = xen_efi_query_capsule_caps;
+	efi.get_next_high_mono_count = xen_efi_get_next_high_mono_count;
+	efi.reset_system             = NULL; /* Functionality provided by Xen. */
+}
+EXPORT_SYMBOL_GPL(xen_efi_runtime_setup);
diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig
index 73708ac..27d216a 100644
--- a/drivers/xen/Kconfig
+++ b/drivers/xen/Kconfig
@@ -268,7 +268,7 @@ config XEN_HAVE_PVMMU
 
 config XEN_EFI
 	def_bool y
-	depends on X86_64 && EFI
+	depends on (ARM64 || X86_64) && EFI
 
 config XEN_AUTO_XLATE
 	def_bool y
-- 
2.0.4

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

* [PATCH v3 16/17] FDT: Add a helper to get specified name subnode
  2016-01-23  3:19 ` Shannon Zhao
  (?)
@ 2016-01-23  3:19   ` Shannon Zhao
  -1 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: catalin.marinas, will.deacon, julien.grall, xen-devel,
	devicetree, linux-efi, linux-kernel, ian.campbell, shannon.zhao,
	peter.huangpeng, Rob Herring

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

Sometimes it needs to check if there is a node in FDT by full path.
Introduce this helper to get the specified name subnode if it exists.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
CC: Rob Herring <robh@kernel.org>
---
 drivers/of/fdt.c       | 35 +++++++++++++++++++++++++++++++++++
 include/linux/of_fdt.h |  2 ++
 2 files changed, 37 insertions(+)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 655f79d..112ec16 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -645,6 +645,41 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node,
 }
 
 /**
+ * of_get_flat_dt_subnode_by_name - get subnode of specified node by name
+ *
+ * @node: the parent node
+ * @uname: the name of subnode
+ * @return offset of the subnode, or -FDT_ERR_NOTFOUND if there is none
+ */
+
+int of_get_flat_dt_subnode_by_name(unsigned long node, const char *uname)
+{
+	const void *blob = initial_boot_params;
+	int offset;
+	const char *pathp;
+
+	/* Find first subnode if it exists */
+	offset = fdt_first_subnode(blob, node);
+	if (offset < 0)
+		return -FDT_ERR_NOTFOUND;
+	pathp = fdt_get_name(blob, offset, NULL);
+	if (strncmp(pathp, uname, strlen(uname)) == 0)
+		return offset;
+
+	/* Find other subnodes */
+	do {
+		offset = fdt_next_subnode(blob, offset);
+		if (offset < 0)
+			return -FDT_ERR_NOTFOUND;
+		pathp = fdt_get_name(blob, offset, NULL);
+		if (strncmp(pathp, uname, strlen(uname)) == 0)
+			return offset;
+	} while (offset >= 0);
+
+	return -FDT_ERR_NOTFOUND;
+}
+
+/**
  * of_get_flat_dt_root - find the root node in the flat blob
  */
 unsigned long __init of_get_flat_dt_root(void)
diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
index df9ef38..fc28162 100644
--- a/include/linux/of_fdt.h
+++ b/include/linux/of_fdt.h
@@ -52,6 +52,8 @@ extern char __dtb_end[];
 extern int of_scan_flat_dt(int (*it)(unsigned long node, const char *uname,
 				     int depth, void *data),
 			   void *data);
+extern int of_get_flat_dt_subnode_by_name(unsigned long node,
+					  const char *uname);
 extern const void *of_get_flat_dt_prop(unsigned long node, const char *name,
 				       int *size);
 extern int of_flat_dt_is_compatible(unsigned long node, const char *name);
-- 
2.0.4

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

* [PATCH v3 16/17] FDT: Add a helper to get specified name subnode
@ 2016-01-23  3:19   ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: devicetree, linux-efi, ian.campbell, Rob Herring,
	catalin.marinas, will.deacon, linux-kernel, xen-devel,
	julien.grall, shannon.zhao, peter.huangpeng

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

Sometimes it needs to check if there is a node in FDT by full path.
Introduce this helper to get the specified name subnode if it exists.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
CC: Rob Herring <robh@kernel.org>
---
 drivers/of/fdt.c       | 35 +++++++++++++++++++++++++++++++++++
 include/linux/of_fdt.h |  2 ++
 2 files changed, 37 insertions(+)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 655f79d..112ec16 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -645,6 +645,41 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node,
 }
 
 /**
+ * of_get_flat_dt_subnode_by_name - get subnode of specified node by name
+ *
+ * @node: the parent node
+ * @uname: the name of subnode
+ * @return offset of the subnode, or -FDT_ERR_NOTFOUND if there is none
+ */
+
+int of_get_flat_dt_subnode_by_name(unsigned long node, const char *uname)
+{
+	const void *blob = initial_boot_params;
+	int offset;
+	const char *pathp;
+
+	/* Find first subnode if it exists */
+	offset = fdt_first_subnode(blob, node);
+	if (offset < 0)
+		return -FDT_ERR_NOTFOUND;
+	pathp = fdt_get_name(blob, offset, NULL);
+	if (strncmp(pathp, uname, strlen(uname)) == 0)
+		return offset;
+
+	/* Find other subnodes */
+	do {
+		offset = fdt_next_subnode(blob, offset);
+		if (offset < 0)
+			return -FDT_ERR_NOTFOUND;
+		pathp = fdt_get_name(blob, offset, NULL);
+		if (strncmp(pathp, uname, strlen(uname)) == 0)
+			return offset;
+	} while (offset >= 0);
+
+	return -FDT_ERR_NOTFOUND;
+}
+
+/**
  * of_get_flat_dt_root - find the root node in the flat blob
  */
 unsigned long __init of_get_flat_dt_root(void)
diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
index df9ef38..fc28162 100644
--- a/include/linux/of_fdt.h
+++ b/include/linux/of_fdt.h
@@ -52,6 +52,8 @@ extern char __dtb_end[];
 extern int of_scan_flat_dt(int (*it)(unsigned long node, const char *uname,
 				     int depth, void *data),
 			   void *data);
+extern int of_get_flat_dt_subnode_by_name(unsigned long node,
+					  const char *uname);
 extern const void *of_get_flat_dt_prop(unsigned long node, const char *name,
 				       int *size);
 extern int of_flat_dt_is_compatible(unsigned long node, const char *name);
-- 
2.0.4

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

* [PATCH v3 16/17] FDT: Add a helper to get specified name subnode
@ 2016-01-23  3:19   ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel

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

Sometimes it needs to check if there is a node in FDT by full path.
Introduce this helper to get the specified name subnode if it exists.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
CC: Rob Herring <robh@kernel.org>
---
 drivers/of/fdt.c       | 35 +++++++++++++++++++++++++++++++++++
 include/linux/of_fdt.h |  2 ++
 2 files changed, 37 insertions(+)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 655f79d..112ec16 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -645,6 +645,41 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node,
 }
 
 /**
+ * of_get_flat_dt_subnode_by_name - get subnode of specified node by name
+ *
+ * @node: the parent node
+ * @uname: the name of subnode
+ * @return offset of the subnode, or -FDT_ERR_NOTFOUND if there is none
+ */
+
+int of_get_flat_dt_subnode_by_name(unsigned long node, const char *uname)
+{
+	const void *blob = initial_boot_params;
+	int offset;
+	const char *pathp;
+
+	/* Find first subnode if it exists */
+	offset = fdt_first_subnode(blob, node);
+	if (offset < 0)
+		return -FDT_ERR_NOTFOUND;
+	pathp = fdt_get_name(blob, offset, NULL);
+	if (strncmp(pathp, uname, strlen(uname)) == 0)
+		return offset;
+
+	/* Find other subnodes */
+	do {
+		offset = fdt_next_subnode(blob, offset);
+		if (offset < 0)
+			return -FDT_ERR_NOTFOUND;
+		pathp = fdt_get_name(blob, offset, NULL);
+		if (strncmp(pathp, uname, strlen(uname)) == 0)
+			return offset;
+	} while (offset >= 0);
+
+	return -FDT_ERR_NOTFOUND;
+}
+
+/**
  * of_get_flat_dt_root - find the root node in the flat blob
  */
 unsigned long __init of_get_flat_dt_root(void)
diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
index df9ef38..fc28162 100644
--- a/include/linux/of_fdt.h
+++ b/include/linux/of_fdt.h
@@ -52,6 +52,8 @@ extern char __dtb_end[];
 extern int of_scan_flat_dt(int (*it)(unsigned long node, const char *uname,
 				     int depth, void *data),
 			   void *data);
+extern int of_get_flat_dt_subnode_by_name(unsigned long node,
+					  const char *uname);
 extern const void *of_get_flat_dt_prop(unsigned long node, const char *name,
 				       int *size);
 extern int of_flat_dt_is_compatible(unsigned long node, const char *name);
-- 
2.0.4

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

* [PATCH v3 17/17] Xen: EFI: Parse DT parameters for Xen specific UEFI
  2016-01-23  3:19 ` Shannon Zhao
  (?)
@ 2016-01-23  3:19   ` Shannon Zhao
  -1 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: catalin.marinas, will.deacon, julien.grall, xen-devel,
	devicetree, linux-efi, linux-kernel, ian.campbell, shannon.zhao,
	peter.huangpeng, Matt Fleming

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

Add a new function to parse DT parameters for Xen specific UEFI just
like the way for normal UEFI. Then it could reuse the existing codes.

If Xen supports EFI, initialize runtime services.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
CC: Matt Fleming <matt@codeblueprint.co.uk>
---
 arch/arm/xen/enlighten.c   |  6 ++++++
 arch/arm64/kernel/efi.c    | 17 ++++++++++++-----
 drivers/firmware/efi/efi.c | 45 ++++++++++++++++++++++++++++++++++++++-------
 3 files changed, 56 insertions(+), 12 deletions(-)

diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
index cdc0bd2..608d735 100644
--- a/arch/arm/xen/enlighten.c
+++ b/arch/arm/xen/enlighten.c
@@ -245,6 +245,12 @@ static int __init fdt_find_hyper_node(unsigned long node, const char *uname,
 	    !strncmp(hyper_node.prefix, s, strlen(hyper_node.prefix)))
 		hyper_node.version = s + strlen(hyper_node.prefix);
 
+	if (IS_ENABLED(CONFIG_XEN_EFI)) {
+		/* Check if Xen supports EFI */
+		if (of_get_flat_dt_subnode_by_name(node, "uefi") > 0)
+			set_bit(EFI_PARAVIRT, &efi.flags);
+	}
+
 	return 0;
 }
 
diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c
index 4eeb171..3c46129 100644
--- a/arch/arm64/kernel/efi.c
+++ b/arch/arm64/kernel/efi.c
@@ -33,6 +33,7 @@
 #include <asm/mmu_context.h>
 #include <asm/mmu.h>
 #include <asm/pgtable.h>
+#include <asm/xen/xen-ops.h>
 
 struct efi_memory_map memmap;
 
@@ -308,13 +309,19 @@ static int __init arm64_enable_runtime_services(void)
 	}
 	set_bit(EFI_SYSTEM_TABLES, &efi.flags);
 
-	if (!efi_virtmap_init()) {
-		pr_err("No UEFI virtual mapping was installed -- runtime services will not be available\n");
-		return -ENOMEM;
+	if (IS_ENABLED(CONFIG_XEN_EFI) && efi_enabled(EFI_PARAVIRT)) {
+		/* Set up runtime services function pointers for Xen Dom0 */
+		xen_efi_runtime_setup();
+	} else {
+		if (!efi_virtmap_init()) {
+			pr_err("No UEFI virtual mapping was installed -- runtime services will not be available\n");
+			return -ENOMEM;
+		}
+
+		/* Set up runtime services function pointers */
+		efi_native_runtime_setup();
 	}
 
-	/* Set up runtime services function pointers */
-	efi_native_runtime_setup();
 	set_bit(EFI_RUNTIME_SERVICES, &efi.flags);
 
 	efi.runtime_version = efi.systab->hdr.revision;
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index 027ca21..bdcf6d7 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -498,12 +498,14 @@ device_initcall(efi_load_efivars);
 		FIELD_SIZEOF(struct efi_fdt_params, field) \
 	}
 
-static __initdata struct {
+struct params {
 	const char name[32];
 	const char propname[32];
 	int offset;
 	int size;
-} dt_params[] = {
+};
+
+static struct params fdt_params[] __initdata = {
 	UEFI_PARAM("System Table", "linux,uefi-system-table", system_table),
 	UEFI_PARAM("MemMap Address", "linux,uefi-mmap-start", mmap),
 	UEFI_PARAM("MemMap Size", "linux,uefi-mmap-size", mmap_size),
@@ -511,24 +513,45 @@ static __initdata struct {
 	UEFI_PARAM("MemMap Desc. Version", "linux,uefi-mmap-desc-ver", desc_ver)
 };
 
+static struct params xen_fdt_params[] __initdata = {
+	UEFI_PARAM("System Table", "xen,uefi-system-table", system_table),
+	UEFI_PARAM("MemMap Address", "xen,uefi-mmap-start", mmap),
+	UEFI_PARAM("MemMap Size", "xen,uefi-mmap-size", mmap_size),
+	UEFI_PARAM("MemMap Desc. Size", "xen,uefi-mmap-desc-size", desc_size),
+	UEFI_PARAM("MemMap Desc. Version", "xen,uefi-mmap-desc-ver", desc_ver)
+};
+
 struct param_info {
 	int found;
 	void *params;
+	struct params *dt_params;
+	int size;
 };
 
 static int __init fdt_find_uefi_params(unsigned long node, const char *uname,
 				       int depth, void *data)
 {
 	struct param_info *info = data;
+	struct params *dt_params = info->dt_params;
 	const void *prop;
 	void *dest;
 	u64 val;
-	int i, len;
+	int i, len, offset;
 
-	if (depth != 1 || strcmp(uname, "chosen") != 0)
-		return 0;
+	if (efi_enabled(EFI_PARAVIRT)) {
+		if (depth != 1 || strcmp(uname, "hypervisor") != 0)
+			return 0;
 
-	for (i = 0; i < ARRAY_SIZE(dt_params); i++) {
+		offset = of_get_flat_dt_subnode_by_name(node, "uefi");
+		if (offset < 0)
+			return 0;
+		node = offset;
+	} else {
+		if (depth != 1 || strcmp(uname, "chosen") != 0)
+			return 0;
+	}
+
+	for (i = 0; i < info->size; i++) {
 		prop = of_get_flat_dt_prop(node, dt_params[i].propname, &len);
 		if (!prop)
 			return 0;
@@ -559,12 +582,20 @@ int __init efi_get_fdt_params(struct efi_fdt_params *params)
 	info.found = 0;
 	info.params = params;
 
+	if (efi_enabled(EFI_PARAVIRT)) {
+		info.dt_params = xen_fdt_params;
+		info.size = ARRAY_SIZE(xen_fdt_params);
+	} else {
+		info.dt_params = fdt_params;
+		info.size = ARRAY_SIZE(fdt_params);
+	}
+
 	ret = of_scan_flat_dt(fdt_find_uefi_params, &info);
 	if (!info.found)
 		pr_info("UEFI not found.\n");
 	else if (!ret)
 		pr_err("Can't find '%s' in device tree!\n",
-		       dt_params[info.found].name);
+		       info.dt_params[info.found].name);
 
 	return ret;
 }
-- 
2.0.4

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

* [PATCH v3 17/17] Xen: EFI: Parse DT parameters for Xen specific UEFI
@ 2016-01-23  3:19   ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: catalin.marinas, will.deacon, julien.grall, xen-devel,
	devicetree, linux-efi, linux-kernel, ian.campbell, shannon.zhao,
	peter.huangpeng, Matt Fleming

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

Add a new function to parse DT parameters for Xen specific UEFI just
like the way for normal UEFI. Then it could reuse the existing codes.

If Xen supports EFI, initialize runtime services.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
CC: Matt Fleming <matt@codeblueprint.co.uk>
---
 arch/arm/xen/enlighten.c   |  6 ++++++
 arch/arm64/kernel/efi.c    | 17 ++++++++++++-----
 drivers/firmware/efi/efi.c | 45 ++++++++++++++++++++++++++++++++++++++-------
 3 files changed, 56 insertions(+), 12 deletions(-)

diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
index cdc0bd2..608d735 100644
--- a/arch/arm/xen/enlighten.c
+++ b/arch/arm/xen/enlighten.c
@@ -245,6 +245,12 @@ static int __init fdt_find_hyper_node(unsigned long node, const char *uname,
 	    !strncmp(hyper_node.prefix, s, strlen(hyper_node.prefix)))
 		hyper_node.version = s + strlen(hyper_node.prefix);
 
+	if (IS_ENABLED(CONFIG_XEN_EFI)) {
+		/* Check if Xen supports EFI */
+		if (of_get_flat_dt_subnode_by_name(node, "uefi") > 0)
+			set_bit(EFI_PARAVIRT, &efi.flags);
+	}
+
 	return 0;
 }
 
diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c
index 4eeb171..3c46129 100644
--- a/arch/arm64/kernel/efi.c
+++ b/arch/arm64/kernel/efi.c
@@ -33,6 +33,7 @@
 #include <asm/mmu_context.h>
 #include <asm/mmu.h>
 #include <asm/pgtable.h>
+#include <asm/xen/xen-ops.h>
 
 struct efi_memory_map memmap;
 
@@ -308,13 +309,19 @@ static int __init arm64_enable_runtime_services(void)
 	}
 	set_bit(EFI_SYSTEM_TABLES, &efi.flags);
 
-	if (!efi_virtmap_init()) {
-		pr_err("No UEFI virtual mapping was installed -- runtime services will not be available\n");
-		return -ENOMEM;
+	if (IS_ENABLED(CONFIG_XEN_EFI) && efi_enabled(EFI_PARAVIRT)) {
+		/* Set up runtime services function pointers for Xen Dom0 */
+		xen_efi_runtime_setup();
+	} else {
+		if (!efi_virtmap_init()) {
+			pr_err("No UEFI virtual mapping was installed -- runtime services will not be available\n");
+			return -ENOMEM;
+		}
+
+		/* Set up runtime services function pointers */
+		efi_native_runtime_setup();
 	}
 
-	/* Set up runtime services function pointers */
-	efi_native_runtime_setup();
 	set_bit(EFI_RUNTIME_SERVICES, &efi.flags);
 
 	efi.runtime_version = efi.systab->hdr.revision;
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index 027ca21..bdcf6d7 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -498,12 +498,14 @@ device_initcall(efi_load_efivars);
 		FIELD_SIZEOF(struct efi_fdt_params, field) \
 	}
 
-static __initdata struct {
+struct params {
 	const char name[32];
 	const char propname[32];
 	int offset;
 	int size;
-} dt_params[] = {
+};
+
+static struct params fdt_params[] __initdata = {
 	UEFI_PARAM("System Table", "linux,uefi-system-table", system_table),
 	UEFI_PARAM("MemMap Address", "linux,uefi-mmap-start", mmap),
 	UEFI_PARAM("MemMap Size", "linux,uefi-mmap-size", mmap_size),
@@ -511,24 +513,45 @@ static __initdata struct {
 	UEFI_PARAM("MemMap Desc. Version", "linux,uefi-mmap-desc-ver", desc_ver)
 };
 
+static struct params xen_fdt_params[] __initdata = {
+	UEFI_PARAM("System Table", "xen,uefi-system-table", system_table),
+	UEFI_PARAM("MemMap Address", "xen,uefi-mmap-start", mmap),
+	UEFI_PARAM("MemMap Size", "xen,uefi-mmap-size", mmap_size),
+	UEFI_PARAM("MemMap Desc. Size", "xen,uefi-mmap-desc-size", desc_size),
+	UEFI_PARAM("MemMap Desc. Version", "xen,uefi-mmap-desc-ver", desc_ver)
+};
+
 struct param_info {
 	int found;
 	void *params;
+	struct params *dt_params;
+	int size;
 };
 
 static int __init fdt_find_uefi_params(unsigned long node, const char *uname,
 				       int depth, void *data)
 {
 	struct param_info *info = data;
+	struct params *dt_params = info->dt_params;
 	const void *prop;
 	void *dest;
 	u64 val;
-	int i, len;
+	int i, len, offset;
 
-	if (depth != 1 || strcmp(uname, "chosen") != 0)
-		return 0;
+	if (efi_enabled(EFI_PARAVIRT)) {
+		if (depth != 1 || strcmp(uname, "hypervisor") != 0)
+			return 0;
 
-	for (i = 0; i < ARRAY_SIZE(dt_params); i++) {
+		offset = of_get_flat_dt_subnode_by_name(node, "uefi");
+		if (offset < 0)
+			return 0;
+		node = offset;
+	} else {
+		if (depth != 1 || strcmp(uname, "chosen") != 0)
+			return 0;
+	}
+
+	for (i = 0; i < info->size; i++) {
 		prop = of_get_flat_dt_prop(node, dt_params[i].propname, &len);
 		if (!prop)
 			return 0;
@@ -559,12 +582,20 @@ int __init efi_get_fdt_params(struct efi_fdt_params *params)
 	info.found = 0;
 	info.params = params;
 
+	if (efi_enabled(EFI_PARAVIRT)) {
+		info.dt_params = xen_fdt_params;
+		info.size = ARRAY_SIZE(xen_fdt_params);
+	} else {
+		info.dt_params = fdt_params;
+		info.size = ARRAY_SIZE(fdt_params);
+	}
+
 	ret = of_scan_flat_dt(fdt_find_uefi_params, &info);
 	if (!info.found)
 		pr_info("UEFI not found.\n");
 	else if (!ret)
 		pr_err("Can't find '%s' in device tree!\n",
-		       dt_params[info.found].name);
+		       info.dt_params[info.found].name);
 
 	return ret;
 }
-- 
2.0.4

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

* [PATCH v3 17/17] Xen: EFI: Parse DT parameters for Xen specific UEFI
@ 2016-01-23  3:19   ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel

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

Add a new function to parse DT parameters for Xen specific UEFI just
like the way for normal UEFI. Then it could reuse the existing codes.

If Xen supports EFI, initialize runtime services.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
CC: Matt Fleming <matt@codeblueprint.co.uk>
---
 arch/arm/xen/enlighten.c   |  6 ++++++
 arch/arm64/kernel/efi.c    | 17 ++++++++++++-----
 drivers/firmware/efi/efi.c | 45 ++++++++++++++++++++++++++++++++++++++-------
 3 files changed, 56 insertions(+), 12 deletions(-)

diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
index cdc0bd2..608d735 100644
--- a/arch/arm/xen/enlighten.c
+++ b/arch/arm/xen/enlighten.c
@@ -245,6 +245,12 @@ static int __init fdt_find_hyper_node(unsigned long node, const char *uname,
 	    !strncmp(hyper_node.prefix, s, strlen(hyper_node.prefix)))
 		hyper_node.version = s + strlen(hyper_node.prefix);
 
+	if (IS_ENABLED(CONFIG_XEN_EFI)) {
+		/* Check if Xen supports EFI */
+		if (of_get_flat_dt_subnode_by_name(node, "uefi") > 0)
+			set_bit(EFI_PARAVIRT, &efi.flags);
+	}
+
 	return 0;
 }
 
diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c
index 4eeb171..3c46129 100644
--- a/arch/arm64/kernel/efi.c
+++ b/arch/arm64/kernel/efi.c
@@ -33,6 +33,7 @@
 #include <asm/mmu_context.h>
 #include <asm/mmu.h>
 #include <asm/pgtable.h>
+#include <asm/xen/xen-ops.h>
 
 struct efi_memory_map memmap;
 
@@ -308,13 +309,19 @@ static int __init arm64_enable_runtime_services(void)
 	}
 	set_bit(EFI_SYSTEM_TABLES, &efi.flags);
 
-	if (!efi_virtmap_init()) {
-		pr_err("No UEFI virtual mapping was installed -- runtime services will not be available\n");
-		return -ENOMEM;
+	if (IS_ENABLED(CONFIG_XEN_EFI) && efi_enabled(EFI_PARAVIRT)) {
+		/* Set up runtime services function pointers for Xen Dom0 */
+		xen_efi_runtime_setup();
+	} else {
+		if (!efi_virtmap_init()) {
+			pr_err("No UEFI virtual mapping was installed -- runtime services will not be available\n");
+			return -ENOMEM;
+		}
+
+		/* Set up runtime services function pointers */
+		efi_native_runtime_setup();
 	}
 
-	/* Set up runtime services function pointers */
-	efi_native_runtime_setup();
 	set_bit(EFI_RUNTIME_SERVICES, &efi.flags);
 
 	efi.runtime_version = efi.systab->hdr.revision;
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index 027ca21..bdcf6d7 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -498,12 +498,14 @@ device_initcall(efi_load_efivars);
 		FIELD_SIZEOF(struct efi_fdt_params, field) \
 	}
 
-static __initdata struct {
+struct params {
 	const char name[32];
 	const char propname[32];
 	int offset;
 	int size;
-} dt_params[] = {
+};
+
+static struct params fdt_params[] __initdata = {
 	UEFI_PARAM("System Table", "linux,uefi-system-table", system_table),
 	UEFI_PARAM("MemMap Address", "linux,uefi-mmap-start", mmap),
 	UEFI_PARAM("MemMap Size", "linux,uefi-mmap-size", mmap_size),
@@ -511,24 +513,45 @@ static __initdata struct {
 	UEFI_PARAM("MemMap Desc. Version", "linux,uefi-mmap-desc-ver", desc_ver)
 };
 
+static struct params xen_fdt_params[] __initdata = {
+	UEFI_PARAM("System Table", "xen,uefi-system-table", system_table),
+	UEFI_PARAM("MemMap Address", "xen,uefi-mmap-start", mmap),
+	UEFI_PARAM("MemMap Size", "xen,uefi-mmap-size", mmap_size),
+	UEFI_PARAM("MemMap Desc. Size", "xen,uefi-mmap-desc-size", desc_size),
+	UEFI_PARAM("MemMap Desc. Version", "xen,uefi-mmap-desc-ver", desc_ver)
+};
+
 struct param_info {
 	int found;
 	void *params;
+	struct params *dt_params;
+	int size;
 };
 
 static int __init fdt_find_uefi_params(unsigned long node, const char *uname,
 				       int depth, void *data)
 {
 	struct param_info *info = data;
+	struct params *dt_params = info->dt_params;
 	const void *prop;
 	void *dest;
 	u64 val;
-	int i, len;
+	int i, len, offset;
 
-	if (depth != 1 || strcmp(uname, "chosen") != 0)
-		return 0;
+	if (efi_enabled(EFI_PARAVIRT)) {
+		if (depth != 1 || strcmp(uname, "hypervisor") != 0)
+			return 0;
 
-	for (i = 0; i < ARRAY_SIZE(dt_params); i++) {
+		offset = of_get_flat_dt_subnode_by_name(node, "uefi");
+		if (offset < 0)
+			return 0;
+		node = offset;
+	} else {
+		if (depth != 1 || strcmp(uname, "chosen") != 0)
+			return 0;
+	}
+
+	for (i = 0; i < info->size; i++) {
 		prop = of_get_flat_dt_prop(node, dt_params[i].propname, &len);
 		if (!prop)
 			return 0;
@@ -559,12 +582,20 @@ int __init efi_get_fdt_params(struct efi_fdt_params *params)
 	info.found = 0;
 	info.params = params;
 
+	if (efi_enabled(EFI_PARAVIRT)) {
+		info.dt_params = xen_fdt_params;
+		info.size = ARRAY_SIZE(xen_fdt_params);
+	} else {
+		info.dt_params = fdt_params;
+		info.size = ARRAY_SIZE(fdt_params);
+	}
+
 	ret = of_scan_flat_dt(fdt_find_uefi_params, &info);
 	if (!info.found)
 		pr_info("UEFI not found.\n");
 	else if (!ret)
 		pr_err("Can't find '%s' in device tree!\n",
-		       dt_params[info.found].name);
+		       info.dt_params[info.found].name);
 
 	return ret;
 }
-- 
2.0.4

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

* [PATCH v3 17/17] Xen: EFI: Parse DT parameters for Xen specific UEFI
  2016-01-23  3:19 ` Shannon Zhao
                   ` (25 preceding siblings ...)
  (?)
@ 2016-01-23  3:19 ` Shannon Zhao
  -1 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: devicetree, linux-efi, ian.campbell, Matt Fleming,
	catalin.marinas, will.deacon, linux-kernel, xen-devel,
	julien.grall, shannon.zhao, peter.huangpeng

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

Add a new function to parse DT parameters for Xen specific UEFI just
like the way for normal UEFI. Then it could reuse the existing codes.

If Xen supports EFI, initialize runtime services.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
CC: Matt Fleming <matt@codeblueprint.co.uk>
---
 arch/arm/xen/enlighten.c   |  6 ++++++
 arch/arm64/kernel/efi.c    | 17 ++++++++++++-----
 drivers/firmware/efi/efi.c | 45 ++++++++++++++++++++++++++++++++++++++-------
 3 files changed, 56 insertions(+), 12 deletions(-)

diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
index cdc0bd2..608d735 100644
--- a/arch/arm/xen/enlighten.c
+++ b/arch/arm/xen/enlighten.c
@@ -245,6 +245,12 @@ static int __init fdt_find_hyper_node(unsigned long node, const char *uname,
 	    !strncmp(hyper_node.prefix, s, strlen(hyper_node.prefix)))
 		hyper_node.version = s + strlen(hyper_node.prefix);
 
+	if (IS_ENABLED(CONFIG_XEN_EFI)) {
+		/* Check if Xen supports EFI */
+		if (of_get_flat_dt_subnode_by_name(node, "uefi") > 0)
+			set_bit(EFI_PARAVIRT, &efi.flags);
+	}
+
 	return 0;
 }
 
diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c
index 4eeb171..3c46129 100644
--- a/arch/arm64/kernel/efi.c
+++ b/arch/arm64/kernel/efi.c
@@ -33,6 +33,7 @@
 #include <asm/mmu_context.h>
 #include <asm/mmu.h>
 #include <asm/pgtable.h>
+#include <asm/xen/xen-ops.h>
 
 struct efi_memory_map memmap;
 
@@ -308,13 +309,19 @@ static int __init arm64_enable_runtime_services(void)
 	}
 	set_bit(EFI_SYSTEM_TABLES, &efi.flags);
 
-	if (!efi_virtmap_init()) {
-		pr_err("No UEFI virtual mapping was installed -- runtime services will not be available\n");
-		return -ENOMEM;
+	if (IS_ENABLED(CONFIG_XEN_EFI) && efi_enabled(EFI_PARAVIRT)) {
+		/* Set up runtime services function pointers for Xen Dom0 */
+		xen_efi_runtime_setup();
+	} else {
+		if (!efi_virtmap_init()) {
+			pr_err("No UEFI virtual mapping was installed -- runtime services will not be available\n");
+			return -ENOMEM;
+		}
+
+		/* Set up runtime services function pointers */
+		efi_native_runtime_setup();
 	}
 
-	/* Set up runtime services function pointers */
-	efi_native_runtime_setup();
 	set_bit(EFI_RUNTIME_SERVICES, &efi.flags);
 
 	efi.runtime_version = efi.systab->hdr.revision;
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index 027ca21..bdcf6d7 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -498,12 +498,14 @@ device_initcall(efi_load_efivars);
 		FIELD_SIZEOF(struct efi_fdt_params, field) \
 	}
 
-static __initdata struct {
+struct params {
 	const char name[32];
 	const char propname[32];
 	int offset;
 	int size;
-} dt_params[] = {
+};
+
+static struct params fdt_params[] __initdata = {
 	UEFI_PARAM("System Table", "linux,uefi-system-table", system_table),
 	UEFI_PARAM("MemMap Address", "linux,uefi-mmap-start", mmap),
 	UEFI_PARAM("MemMap Size", "linux,uefi-mmap-size", mmap_size),
@@ -511,24 +513,45 @@ static __initdata struct {
 	UEFI_PARAM("MemMap Desc. Version", "linux,uefi-mmap-desc-ver", desc_ver)
 };
 
+static struct params xen_fdt_params[] __initdata = {
+	UEFI_PARAM("System Table", "xen,uefi-system-table", system_table),
+	UEFI_PARAM("MemMap Address", "xen,uefi-mmap-start", mmap),
+	UEFI_PARAM("MemMap Size", "xen,uefi-mmap-size", mmap_size),
+	UEFI_PARAM("MemMap Desc. Size", "xen,uefi-mmap-desc-size", desc_size),
+	UEFI_PARAM("MemMap Desc. Version", "xen,uefi-mmap-desc-ver", desc_ver)
+};
+
 struct param_info {
 	int found;
 	void *params;
+	struct params *dt_params;
+	int size;
 };
 
 static int __init fdt_find_uefi_params(unsigned long node, const char *uname,
 				       int depth, void *data)
 {
 	struct param_info *info = data;
+	struct params *dt_params = info->dt_params;
 	const void *prop;
 	void *dest;
 	u64 val;
-	int i, len;
+	int i, len, offset;
 
-	if (depth != 1 || strcmp(uname, "chosen") != 0)
-		return 0;
+	if (efi_enabled(EFI_PARAVIRT)) {
+		if (depth != 1 || strcmp(uname, "hypervisor") != 0)
+			return 0;
 
-	for (i = 0; i < ARRAY_SIZE(dt_params); i++) {
+		offset = of_get_flat_dt_subnode_by_name(node, "uefi");
+		if (offset < 0)
+			return 0;
+		node = offset;
+	} else {
+		if (depth != 1 || strcmp(uname, "chosen") != 0)
+			return 0;
+	}
+
+	for (i = 0; i < info->size; i++) {
 		prop = of_get_flat_dt_prop(node, dt_params[i].propname, &len);
 		if (!prop)
 			return 0;
@@ -559,12 +582,20 @@ int __init efi_get_fdt_params(struct efi_fdt_params *params)
 	info.found = 0;
 	info.params = params;
 
+	if (efi_enabled(EFI_PARAVIRT)) {
+		info.dt_params = xen_fdt_params;
+		info.size = ARRAY_SIZE(xen_fdt_params);
+	} else {
+		info.dt_params = fdt_params;
+		info.size = ARRAY_SIZE(fdt_params);
+	}
+
 	ret = of_scan_flat_dt(fdt_find_uefi_params, &info);
 	if (!info.found)
 		pr_info("UEFI not found.\n");
 	else if (!ret)
 		pr_err("Can't find '%s' in device tree!\n",
-		       dt_params[info.found].name);
+		       info.dt_params[info.found].name);
 
 	return ret;
 }
-- 
2.0.4

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

* Re: [PATCH v3 01/17] Xen: ACPI: Hide UART used by Xen
  2016-01-23  3:19   ` Shannon Zhao
  (?)
@ 2016-01-25 12:20     ` Stefano Stabellini
  -1 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 12:20 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel, catalin.marinas, will.deacon,
	julien.grall, xen-devel, devicetree, linux-efi, linux-kernel,
	ian.campbell, shannon.zhao, peter.huangpeng, Rafael J. Wysocki,
	Len Brown, open list:ACPI

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> ACPI 6.0 introduces a new table STAO to list the devices which are used
> by Xen and can't be used by Dom0. On Xen virtual platforms, the physical
> UART is used by Xen. So here it hides UART from Dom0.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
> CC: "Rafael J. Wysocki" <rjw@rjwysocki.net> (supporter:ACPI)
> CC: Len Brown <lenb@kernel.org> (supporter:ACPI)
> CC: linux-acpi@vger.kernel.org (open list:ACPI)
> ---
>  drivers/acpi/bus.c | 36 +++++++++++++++++++++++++++++++++++-
>  1 file changed, 35 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
> index a212cef..7f85b54 100644
> --- a/drivers/acpi/bus.c
> +++ b/drivers/acpi/bus.c
> @@ -46,6 +46,7 @@ ACPI_MODULE_NAME("bus");
>  struct acpi_device *acpi_root;
>  struct proc_dir_entry *acpi_root_dir;
>  EXPORT_SYMBOL(acpi_root_dir);
> +static u64 spcr_uart_addr;
>  
>  #ifdef CONFIG_X86
>  #ifdef CONFIG_ACPI_CUSTOM_DSDT
> @@ -105,6 +106,22 @@ acpi_status acpi_bus_get_status_handle(acpi_handle handle,
>  	return status;
>  }
>  
> +static bool acpi_check_device_is_ignored(acpi_handle handle)
> +{
> +	acpi_status status;
> +	u64 addr;
> +
> +	/* Check if it should ignore the UART device */
> +	if (spcr_uart_addr != 0) {
> +		status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL,
> +					       &addr);
> +		if (ACPI_SUCCESS(status) && addr == spcr_uart_addr)
> +			return true;
> +	}
> +
> +	return false;
> +}
> +
>  int acpi_bus_get_status(struct acpi_device *device)
>  {
>  	acpi_status status;
> @@ -114,7 +131,8 @@ int acpi_bus_get_status(struct acpi_device *device)
>  	if (ACPI_FAILURE(status))
>  		return -ENODEV;
>  
> -	acpi_set_device_status(device, sta);
> +	if (!acpi_check_device_is_ignored(device->handle))
> +		acpi_set_device_status(device, sta);
>  
>  	if (device->status.functional && !device->status.present) {
>  		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]: "
> @@ -1069,6 +1087,8 @@ EXPORT_SYMBOL_GPL(acpi_kobj);
>  static int __init acpi_init(void)
>  {
>  	int result;
> +	acpi_status status;
> +	struct acpi_table_stao *stao_ptr;
>  
>  	if (acpi_disabled) {
>  		printk(KERN_INFO PREFIX "Interpreter disabled.\n");
> @@ -1081,6 +1101,20 @@ static int __init acpi_init(void)
>  		acpi_kobj = NULL;
>  	}
>  
> +	/* If there is STAO table, check whether it needs to ignore the UART
> +	 * device in SPCR table.
> +	 */
> +	status = acpi_get_table(ACPI_SIG_STAO, 0,
> +				(struct acpi_table_header **)&stao_ptr);
> +	if (ACPI_SUCCESS(status) && stao_ptr->ignore_uart) {
> +		struct acpi_table_spcr *spcr_ptr;
> +
> +		status = acpi_get_table(ACPI_SIG_SPCR, 0,
> +					(struct acpi_table_header **)&spcr_ptr);
> +		if (ACPI_SUCCESS(status))
> +			spcr_uart_addr = spcr_ptr->serial_port.address;

else
    printk(KERN_WARNING "STAO table present, but SPCR is missing.\n");

In any case:

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


> +	}
> +
>  	init_acpi_device_notify();
>  	result = acpi_bus_init();
>  	if (result) {

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

* Re: [PATCH v3 01/17] Xen: ACPI: Hide UART used by Xen
@ 2016-01-25 12:20     ` Stefano Stabellini
  0 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 12:20 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel, catalin.marinas, will.deacon,
	julien.grall, xen-devel, devicetree, linux-efi, linux-kernel,
	ian.campbell, shannon.zhao, peter.huangpeng, Rafael J. Wysocki,
	Len Brown, open list:ACPI

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> ACPI 6.0 introduces a new table STAO to list the devices which are used
> by Xen and can't be used by Dom0. On Xen virtual platforms, the physical
> UART is used by Xen. So here it hides UART from Dom0.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
> CC: "Rafael J. Wysocki" <rjw@rjwysocki.net> (supporter:ACPI)
> CC: Len Brown <lenb@kernel.org> (supporter:ACPI)
> CC: linux-acpi@vger.kernel.org (open list:ACPI)
> ---
>  drivers/acpi/bus.c | 36 +++++++++++++++++++++++++++++++++++-
>  1 file changed, 35 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
> index a212cef..7f85b54 100644
> --- a/drivers/acpi/bus.c
> +++ b/drivers/acpi/bus.c
> @@ -46,6 +46,7 @@ ACPI_MODULE_NAME("bus");
>  struct acpi_device *acpi_root;
>  struct proc_dir_entry *acpi_root_dir;
>  EXPORT_SYMBOL(acpi_root_dir);
> +static u64 spcr_uart_addr;
>  
>  #ifdef CONFIG_X86
>  #ifdef CONFIG_ACPI_CUSTOM_DSDT
> @@ -105,6 +106,22 @@ acpi_status acpi_bus_get_status_handle(acpi_handle handle,
>  	return status;
>  }
>  
> +static bool acpi_check_device_is_ignored(acpi_handle handle)
> +{
> +	acpi_status status;
> +	u64 addr;
> +
> +	/* Check if it should ignore the UART device */
> +	if (spcr_uart_addr != 0) {
> +		status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL,
> +					       &addr);
> +		if (ACPI_SUCCESS(status) && addr == spcr_uart_addr)
> +			return true;
> +	}
> +
> +	return false;
> +}
> +
>  int acpi_bus_get_status(struct acpi_device *device)
>  {
>  	acpi_status status;
> @@ -114,7 +131,8 @@ int acpi_bus_get_status(struct acpi_device *device)
>  	if (ACPI_FAILURE(status))
>  		return -ENODEV;
>  
> -	acpi_set_device_status(device, sta);
> +	if (!acpi_check_device_is_ignored(device->handle))
> +		acpi_set_device_status(device, sta);
>  
>  	if (device->status.functional && !device->status.present) {
>  		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]: "
> @@ -1069,6 +1087,8 @@ EXPORT_SYMBOL_GPL(acpi_kobj);
>  static int __init acpi_init(void)
>  {
>  	int result;
> +	acpi_status status;
> +	struct acpi_table_stao *stao_ptr;
>  
>  	if (acpi_disabled) {
>  		printk(KERN_INFO PREFIX "Interpreter disabled.\n");
> @@ -1081,6 +1101,20 @@ static int __init acpi_init(void)
>  		acpi_kobj = NULL;
>  	}
>  
> +	/* If there is STAO table, check whether it needs to ignore the UART
> +	 * device in SPCR table.
> +	 */
> +	status = acpi_get_table(ACPI_SIG_STAO, 0,
> +				(struct acpi_table_header **)&stao_ptr);
> +	if (ACPI_SUCCESS(status) && stao_ptr->ignore_uart) {
> +		struct acpi_table_spcr *spcr_ptr;
> +
> +		status = acpi_get_table(ACPI_SIG_SPCR, 0,
> +					(struct acpi_table_header **)&spcr_ptr);
> +		if (ACPI_SUCCESS(status))
> +			spcr_uart_addr = spcr_ptr->serial_port.address;

else
    printk(KERN_WARNING "STAO table present, but SPCR is missing.\n");

In any case:

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


> +	}
> +
>  	init_acpi_device_notify();
>  	result = acpi_bus_init();
>  	if (result) {

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

* [PATCH v3 01/17] Xen: ACPI: Hide UART used by Xen
@ 2016-01-25 12:20     ` Stefano Stabellini
  0 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 12:20 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> ACPI 6.0 introduces a new table STAO to list the devices which are used
> by Xen and can't be used by Dom0. On Xen virtual platforms, the physical
> UART is used by Xen. So here it hides UART from Dom0.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
> CC: "Rafael J. Wysocki" <rjw@rjwysocki.net> (supporter:ACPI)
> CC: Len Brown <lenb@kernel.org> (supporter:ACPI)
> CC: linux-acpi at vger.kernel.org (open list:ACPI)
> ---
>  drivers/acpi/bus.c | 36 +++++++++++++++++++++++++++++++++++-
>  1 file changed, 35 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
> index a212cef..7f85b54 100644
> --- a/drivers/acpi/bus.c
> +++ b/drivers/acpi/bus.c
> @@ -46,6 +46,7 @@ ACPI_MODULE_NAME("bus");
>  struct acpi_device *acpi_root;
>  struct proc_dir_entry *acpi_root_dir;
>  EXPORT_SYMBOL(acpi_root_dir);
> +static u64 spcr_uart_addr;
>  
>  #ifdef CONFIG_X86
>  #ifdef CONFIG_ACPI_CUSTOM_DSDT
> @@ -105,6 +106,22 @@ acpi_status acpi_bus_get_status_handle(acpi_handle handle,
>  	return status;
>  }
>  
> +static bool acpi_check_device_is_ignored(acpi_handle handle)
> +{
> +	acpi_status status;
> +	u64 addr;
> +
> +	/* Check if it should ignore the UART device */
> +	if (spcr_uart_addr != 0) {
> +		status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL,
> +					       &addr);
> +		if (ACPI_SUCCESS(status) && addr == spcr_uart_addr)
> +			return true;
> +	}
> +
> +	return false;
> +}
> +
>  int acpi_bus_get_status(struct acpi_device *device)
>  {
>  	acpi_status status;
> @@ -114,7 +131,8 @@ int acpi_bus_get_status(struct acpi_device *device)
>  	if (ACPI_FAILURE(status))
>  		return -ENODEV;
>  
> -	acpi_set_device_status(device, sta);
> +	if (!acpi_check_device_is_ignored(device->handle))
> +		acpi_set_device_status(device, sta);
>  
>  	if (device->status.functional && !device->status.present) {
>  		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]: "
> @@ -1069,6 +1087,8 @@ EXPORT_SYMBOL_GPL(acpi_kobj);
>  static int __init acpi_init(void)
>  {
>  	int result;
> +	acpi_status status;
> +	struct acpi_table_stao *stao_ptr;
>  
>  	if (acpi_disabled) {
>  		printk(KERN_INFO PREFIX "Interpreter disabled.\n");
> @@ -1081,6 +1101,20 @@ static int __init acpi_init(void)
>  		acpi_kobj = NULL;
>  	}
>  
> +	/* If there is STAO table, check whether it needs to ignore the UART
> +	 * device in SPCR table.
> +	 */
> +	status = acpi_get_table(ACPI_SIG_STAO, 0,
> +				(struct acpi_table_header **)&stao_ptr);
> +	if (ACPI_SUCCESS(status) && stao_ptr->ignore_uart) {
> +		struct acpi_table_spcr *spcr_ptr;
> +
> +		status = acpi_get_table(ACPI_SIG_SPCR, 0,
> +					(struct acpi_table_header **)&spcr_ptr);
> +		if (ACPI_SUCCESS(status))
> +			spcr_uart_addr = spcr_ptr->serial_port.address;

else
    printk(KERN_WARNING "STAO table present, but SPCR is missing.\n");

In any case:

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


> +	}
> +
>  	init_acpi_device_notify();
>  	result = acpi_bus_init();
>  	if (result) {

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

* Re: [PATCH v3 01/17] Xen: ACPI: Hide UART used by Xen
  2016-01-23  3:19   ` Shannon Zhao
                     ` (2 preceding siblings ...)
  (?)
@ 2016-01-25 12:20   ` Stefano Stabellini
  -1 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 12:20 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: mark.rutland, devicetree, linux-efi, ian.campbell,
	ard.biesheuvel, catalin.marinas, will.deacon, linux-kernel,
	xen-devel, julien.grall, open list:ACPI, stefano.stabellini,
	david.vrabel, peter.huangpeng, Len Brown, Rafael J. Wysocki,
	linux-arm-kernel, shannon.zhao

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> ACPI 6.0 introduces a new table STAO to list the devices which are used
> by Xen and can't be used by Dom0. On Xen virtual platforms, the physical
> UART is used by Xen. So here it hides UART from Dom0.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
> CC: "Rafael J. Wysocki" <rjw@rjwysocki.net> (supporter:ACPI)
> CC: Len Brown <lenb@kernel.org> (supporter:ACPI)
> CC: linux-acpi@vger.kernel.org (open list:ACPI)
> ---
>  drivers/acpi/bus.c | 36 +++++++++++++++++++++++++++++++++++-
>  1 file changed, 35 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
> index a212cef..7f85b54 100644
> --- a/drivers/acpi/bus.c
> +++ b/drivers/acpi/bus.c
> @@ -46,6 +46,7 @@ ACPI_MODULE_NAME("bus");
>  struct acpi_device *acpi_root;
>  struct proc_dir_entry *acpi_root_dir;
>  EXPORT_SYMBOL(acpi_root_dir);
> +static u64 spcr_uart_addr;
>  
>  #ifdef CONFIG_X86
>  #ifdef CONFIG_ACPI_CUSTOM_DSDT
> @@ -105,6 +106,22 @@ acpi_status acpi_bus_get_status_handle(acpi_handle handle,
>  	return status;
>  }
>  
> +static bool acpi_check_device_is_ignored(acpi_handle handle)
> +{
> +	acpi_status status;
> +	u64 addr;
> +
> +	/* Check if it should ignore the UART device */
> +	if (spcr_uart_addr != 0) {
> +		status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL,
> +					       &addr);
> +		if (ACPI_SUCCESS(status) && addr == spcr_uart_addr)
> +			return true;
> +	}
> +
> +	return false;
> +}
> +
>  int acpi_bus_get_status(struct acpi_device *device)
>  {
>  	acpi_status status;
> @@ -114,7 +131,8 @@ int acpi_bus_get_status(struct acpi_device *device)
>  	if (ACPI_FAILURE(status))
>  		return -ENODEV;
>  
> -	acpi_set_device_status(device, sta);
> +	if (!acpi_check_device_is_ignored(device->handle))
> +		acpi_set_device_status(device, sta);
>  
>  	if (device->status.functional && !device->status.present) {
>  		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] status [%08x]: "
> @@ -1069,6 +1087,8 @@ EXPORT_SYMBOL_GPL(acpi_kobj);
>  static int __init acpi_init(void)
>  {
>  	int result;
> +	acpi_status status;
> +	struct acpi_table_stao *stao_ptr;
>  
>  	if (acpi_disabled) {
>  		printk(KERN_INFO PREFIX "Interpreter disabled.\n");
> @@ -1081,6 +1101,20 @@ static int __init acpi_init(void)
>  		acpi_kobj = NULL;
>  	}
>  
> +	/* If there is STAO table, check whether it needs to ignore the UART
> +	 * device in SPCR table.
> +	 */
> +	status = acpi_get_table(ACPI_SIG_STAO, 0,
> +				(struct acpi_table_header **)&stao_ptr);
> +	if (ACPI_SUCCESS(status) && stao_ptr->ignore_uart) {
> +		struct acpi_table_spcr *spcr_ptr;
> +
> +		status = acpi_get_table(ACPI_SIG_SPCR, 0,
> +					(struct acpi_table_header **)&spcr_ptr);
> +		if (ACPI_SUCCESS(status))
> +			spcr_uart_addr = spcr_ptr->serial_port.address;

else
    printk(KERN_WARNING "STAO table present, but SPCR is missing.\n");

In any case:

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


> +	}
> +
>  	init_acpi_device_notify();
>  	result = acpi_bus_init();
>  	if (result) {

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

* Re: [PATCH v3 03/17] Xen: xlate: Use page_to_xen_pfn instead of page_to_pfn
@ 2016-01-25 13:55     ` Stefano Stabellini
  0 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 13:55 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel, catalin.marinas, will.deacon,
	julien.grall, xen-devel, devicetree, linux-efi, linux-kernel,
	ian.campbell, shannon.zhao, peter.huangpeng

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Use page_to_xen_pfn in case of 64KB page.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

Please update the commit message, something like:

"Make xen_xlate_map_ballooned_pages work with 64K pages. In that case
Kernel pages are 64K in size but Xen pages remain 4K in size. Xen pfns
refer to 4K pages."

Provided that you change the commit message:

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


>  drivers/xen/xlate_mmu.c | 26 ++++++++++++++++----------
>  1 file changed, 16 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/xen/xlate_mmu.c b/drivers/xen/xlate_mmu.c
> index 9692656..28f728b 100644
> --- a/drivers/xen/xlate_mmu.c
> +++ b/drivers/xen/xlate_mmu.c
> @@ -207,9 +207,12 @@ int __init xen_xlate_map_ballooned_pages(xen_pfn_t **gfns, void **virt,
>  	void *vaddr;
>  	int rc;
>  	unsigned int i;
> +	unsigned long nr_pages;
> +	xen_pfn_t xen_pfn = 0;
>  
>  	BUG_ON(nr_grant_frames == 0);
> -	pages = kcalloc(nr_grant_frames, sizeof(pages[0]), GFP_KERNEL);
> +	nr_pages = DIV_ROUND_UP(nr_grant_frames, XEN_PFN_PER_PAGE);
> +	pages = kcalloc(nr_pages, sizeof(pages[0]), GFP_KERNEL);
>  	if (!pages)
>  		return -ENOMEM;
>  
> @@ -218,22 +221,25 @@ int __init xen_xlate_map_ballooned_pages(xen_pfn_t **gfns, void **virt,
>  		kfree(pages);
>  		return -ENOMEM;
>  	}
> -	rc = alloc_xenballooned_pages(nr_grant_frames, pages);
> +	rc = alloc_xenballooned_pages(nr_pages, pages);
>  	if (rc) {
> -		pr_warn("%s Couldn't balloon alloc %ld pfns rc:%d\n", __func__,
> -			nr_grant_frames, rc);
> +		pr_warn("%s Couldn't balloon alloc %ld pages rc:%d\n", __func__,
> +			nr_pages, rc);
>  		kfree(pages);
>  		kfree(pfns);
>  		return rc;
>  	}
> -	for (i = 0; i < nr_grant_frames; i++)
> -		pfns[i] = page_to_pfn(pages[i]);
> +	for (i = 0; i < nr_grant_frames; i++) {
> +		if ((i % XEN_PFN_PER_PAGE) == 0)
> +			xen_pfn = page_to_xen_pfn(pages[i / XEN_PFN_PER_PAGE]);
> +		pfns[i] = pfn_to_gfn(xen_pfn++);
> +	}
>  
> -	vaddr = vmap(pages, nr_grant_frames, 0, PAGE_KERNEL);
> +	vaddr = vmap(pages, nr_pages, 0, PAGE_KERNEL);
>  	if (!vaddr) {
> -		pr_warn("%s Couldn't map %ld pfns rc:%d\n", __func__,
> -			nr_grant_frames, rc);
> -		free_xenballooned_pages(nr_grant_frames, pages);
> +		pr_warn("%s Couldn't map %ld pages rc:%d\n", __func__,
> +			nr_pages, rc);
> +		free_xenballooned_pages(nr_pages, pages);
>  		kfree(pages);
>  		kfree(pfns);
>  		return -ENOMEM;
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v3 03/17] Xen: xlate: Use page_to_xen_pfn instead of page_to_pfn
@ 2016-01-25 13:55     ` Stefano Stabellini
  0 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 13:55 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	stefano.stabellini-Sxgqhf6Nn4DQT0dZR+AlfA,
	david.vrabel-Sxgqhf6Nn4DQT0dZR+AlfA, catalin.marinas-5wv7dgnIgG8,
	will.deacon-5wv7dgnIgG8, julien.grall-Sxgqhf6Nn4DQT0dZR+AlfA,
	xen-devel-GuqFBffKawuEi8DpZVb4nw,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-efi-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	ian.campbell-Sxgqhf6Nn4DQT0dZR+AlfA,
	shannon.zhao-QSEj5FYQhm4dnm+yROfE0A,
	peter.huangpeng-hv44wF8Li93QT0dZR+AlfA

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> 
> Use page_to_xen_pfn in case of 64KB page.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>

Please update the commit message, something like:

"Make xen_xlate_map_ballooned_pages work with 64K pages. In that case
Kernel pages are 64K in size but Xen pages remain 4K in size. Xen pfns
refer to 4K pages."

Provided that you change the commit message:

Reviewed-by: Stefano Stabellini <stefano.stabellini-mvvWK6WmYclDPfheJLI6IQ@public.gmane.org>


>  drivers/xen/xlate_mmu.c | 26 ++++++++++++++++----------
>  1 file changed, 16 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/xen/xlate_mmu.c b/drivers/xen/xlate_mmu.c
> index 9692656..28f728b 100644
> --- a/drivers/xen/xlate_mmu.c
> +++ b/drivers/xen/xlate_mmu.c
> @@ -207,9 +207,12 @@ int __init xen_xlate_map_ballooned_pages(xen_pfn_t **gfns, void **virt,
>  	void *vaddr;
>  	int rc;
>  	unsigned int i;
> +	unsigned long nr_pages;
> +	xen_pfn_t xen_pfn = 0;
>  
>  	BUG_ON(nr_grant_frames == 0);
> -	pages = kcalloc(nr_grant_frames, sizeof(pages[0]), GFP_KERNEL);
> +	nr_pages = DIV_ROUND_UP(nr_grant_frames, XEN_PFN_PER_PAGE);
> +	pages = kcalloc(nr_pages, sizeof(pages[0]), GFP_KERNEL);
>  	if (!pages)
>  		return -ENOMEM;
>  
> @@ -218,22 +221,25 @@ int __init xen_xlate_map_ballooned_pages(xen_pfn_t **gfns, void **virt,
>  		kfree(pages);
>  		return -ENOMEM;
>  	}
> -	rc = alloc_xenballooned_pages(nr_grant_frames, pages);
> +	rc = alloc_xenballooned_pages(nr_pages, pages);
>  	if (rc) {
> -		pr_warn("%s Couldn't balloon alloc %ld pfns rc:%d\n", __func__,
> -			nr_grant_frames, rc);
> +		pr_warn("%s Couldn't balloon alloc %ld pages rc:%d\n", __func__,
> +			nr_pages, rc);
>  		kfree(pages);
>  		kfree(pfns);
>  		return rc;
>  	}
> -	for (i = 0; i < nr_grant_frames; i++)
> -		pfns[i] = page_to_pfn(pages[i]);
> +	for (i = 0; i < nr_grant_frames; i++) {
> +		if ((i % XEN_PFN_PER_PAGE) == 0)
> +			xen_pfn = page_to_xen_pfn(pages[i / XEN_PFN_PER_PAGE]);
> +		pfns[i] = pfn_to_gfn(xen_pfn++);
> +	}
>  
> -	vaddr = vmap(pages, nr_grant_frames, 0, PAGE_KERNEL);
> +	vaddr = vmap(pages, nr_pages, 0, PAGE_KERNEL);
>  	if (!vaddr) {
> -		pr_warn("%s Couldn't map %ld pfns rc:%d\n", __func__,
> -			nr_grant_frames, rc);
> -		free_xenballooned_pages(nr_grant_frames, pages);
> +		pr_warn("%s Couldn't map %ld pages rc:%d\n", __func__,
> +			nr_pages, rc);
> +		free_xenballooned_pages(nr_pages, pages);
>  		kfree(pages);
>  		kfree(pfns);
>  		return -ENOMEM;
> -- 
> 2.0.4
> 
> 
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v3 03/17] Xen: xlate: Use page_to_xen_pfn instead of page_to_pfn
@ 2016-01-25 13:55     ` Stefano Stabellini
  0 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 13:55 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Use page_to_xen_pfn in case of 64KB page.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

Please update the commit message, something like:

"Make xen_xlate_map_ballooned_pages work with 64K pages. In that case
Kernel pages are 64K in size but Xen pages remain 4K in size. Xen pfns
refer to 4K pages."

Provided that you change the commit message:

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


>  drivers/xen/xlate_mmu.c | 26 ++++++++++++++++----------
>  1 file changed, 16 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/xen/xlate_mmu.c b/drivers/xen/xlate_mmu.c
> index 9692656..28f728b 100644
> --- a/drivers/xen/xlate_mmu.c
> +++ b/drivers/xen/xlate_mmu.c
> @@ -207,9 +207,12 @@ int __init xen_xlate_map_ballooned_pages(xen_pfn_t **gfns, void **virt,
>  	void *vaddr;
>  	int rc;
>  	unsigned int i;
> +	unsigned long nr_pages;
> +	xen_pfn_t xen_pfn = 0;
>  
>  	BUG_ON(nr_grant_frames == 0);
> -	pages = kcalloc(nr_grant_frames, sizeof(pages[0]), GFP_KERNEL);
> +	nr_pages = DIV_ROUND_UP(nr_grant_frames, XEN_PFN_PER_PAGE);
> +	pages = kcalloc(nr_pages, sizeof(pages[0]), GFP_KERNEL);
>  	if (!pages)
>  		return -ENOMEM;
>  
> @@ -218,22 +221,25 @@ int __init xen_xlate_map_ballooned_pages(xen_pfn_t **gfns, void **virt,
>  		kfree(pages);
>  		return -ENOMEM;
>  	}
> -	rc = alloc_xenballooned_pages(nr_grant_frames, pages);
> +	rc = alloc_xenballooned_pages(nr_pages, pages);
>  	if (rc) {
> -		pr_warn("%s Couldn't balloon alloc %ld pfns rc:%d\n", __func__,
> -			nr_grant_frames, rc);
> +		pr_warn("%s Couldn't balloon alloc %ld pages rc:%d\n", __func__,
> +			nr_pages, rc);
>  		kfree(pages);
>  		kfree(pfns);
>  		return rc;
>  	}
> -	for (i = 0; i < nr_grant_frames; i++)
> -		pfns[i] = page_to_pfn(pages[i]);
> +	for (i = 0; i < nr_grant_frames; i++) {
> +		if ((i % XEN_PFN_PER_PAGE) == 0)
> +			xen_pfn = page_to_xen_pfn(pages[i / XEN_PFN_PER_PAGE]);
> +		pfns[i] = pfn_to_gfn(xen_pfn++);
> +	}
>  
> -	vaddr = vmap(pages, nr_grant_frames, 0, PAGE_KERNEL);
> +	vaddr = vmap(pages, nr_pages, 0, PAGE_KERNEL);
>  	if (!vaddr) {
> -		pr_warn("%s Couldn't map %ld pfns rc:%d\n", __func__,
> -			nr_grant_frames, rc);
> -		free_xenballooned_pages(nr_grant_frames, pages);
> +		pr_warn("%s Couldn't map %ld pages rc:%d\n", __func__,
> +			nr_pages, rc);
> +		free_xenballooned_pages(nr_pages, pages);
>  		kfree(pages);
>  		kfree(pfns);
>  		return -ENOMEM;
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v3 03/17] Xen: xlate: Use page_to_xen_pfn instead of page_to_pfn
  2016-01-23  3:19   ` Shannon Zhao
  (?)
  (?)
@ 2016-01-25 13:55   ` Stefano Stabellini
  -1 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 13:55 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: mark.rutland, devicetree, linux-efi, ian.campbell,
	ard.biesheuvel, catalin.marinas, will.deacon, linux-kernel,
	xen-devel, julien.grall, stefano.stabellini, david.vrabel,
	peter.huangpeng, linux-arm-kernel, shannon.zhao

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Use page_to_xen_pfn in case of 64KB page.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

Please update the commit message, something like:

"Make xen_xlate_map_ballooned_pages work with 64K pages. In that case
Kernel pages are 64K in size but Xen pages remain 4K in size. Xen pfns
refer to 4K pages."

Provided that you change the commit message:

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


>  drivers/xen/xlate_mmu.c | 26 ++++++++++++++++----------
>  1 file changed, 16 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/xen/xlate_mmu.c b/drivers/xen/xlate_mmu.c
> index 9692656..28f728b 100644
> --- a/drivers/xen/xlate_mmu.c
> +++ b/drivers/xen/xlate_mmu.c
> @@ -207,9 +207,12 @@ int __init xen_xlate_map_ballooned_pages(xen_pfn_t **gfns, void **virt,
>  	void *vaddr;
>  	int rc;
>  	unsigned int i;
> +	unsigned long nr_pages;
> +	xen_pfn_t xen_pfn = 0;
>  
>  	BUG_ON(nr_grant_frames == 0);
> -	pages = kcalloc(nr_grant_frames, sizeof(pages[0]), GFP_KERNEL);
> +	nr_pages = DIV_ROUND_UP(nr_grant_frames, XEN_PFN_PER_PAGE);
> +	pages = kcalloc(nr_pages, sizeof(pages[0]), GFP_KERNEL);
>  	if (!pages)
>  		return -ENOMEM;
>  
> @@ -218,22 +221,25 @@ int __init xen_xlate_map_ballooned_pages(xen_pfn_t **gfns, void **virt,
>  		kfree(pages);
>  		return -ENOMEM;
>  	}
> -	rc = alloc_xenballooned_pages(nr_grant_frames, pages);
> +	rc = alloc_xenballooned_pages(nr_pages, pages);
>  	if (rc) {
> -		pr_warn("%s Couldn't balloon alloc %ld pfns rc:%d\n", __func__,
> -			nr_grant_frames, rc);
> +		pr_warn("%s Couldn't balloon alloc %ld pages rc:%d\n", __func__,
> +			nr_pages, rc);
>  		kfree(pages);
>  		kfree(pfns);
>  		return rc;
>  	}
> -	for (i = 0; i < nr_grant_frames; i++)
> -		pfns[i] = page_to_pfn(pages[i]);
> +	for (i = 0; i < nr_grant_frames; i++) {
> +		if ((i % XEN_PFN_PER_PAGE) == 0)
> +			xen_pfn = page_to_xen_pfn(pages[i / XEN_PFN_PER_PAGE]);
> +		pfns[i] = pfn_to_gfn(xen_pfn++);
> +	}
>  
> -	vaddr = vmap(pages, nr_grant_frames, 0, PAGE_KERNEL);
> +	vaddr = vmap(pages, nr_pages, 0, PAGE_KERNEL);
>  	if (!vaddr) {
> -		pr_warn("%s Couldn't map %ld pfns rc:%d\n", __func__,
> -			nr_grant_frames, rc);
> -		free_xenballooned_pages(nr_grant_frames, pages);
> +		pr_warn("%s Couldn't map %ld pages rc:%d\n", __func__,
> +			nr_pages, rc);
> +		free_xenballooned_pages(nr_pages, pages);
>  		kfree(pages);
>  		kfree(pfns);
>  		return -ENOMEM;
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v3 08/17] Xen: public/hvm: sync changes of HVM_PARAM_CALLBACK_VIA ABI from Xen
  2016-01-23  3:19   ` Shannon Zhao
  (?)
@ 2016-01-25 15:06     ` Stefano Stabellini
  -1 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 15:06 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel, catalin.marinas, will.deacon,
	julien.grall, xen-devel, devicetree, linux-efi, linux-kernel,
	ian.campbell, shannon.zhao, peter.huangpeng

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Sync the changes of HVM_PARAM_CALLBACK_VIA ABI introduced by
> Xen commit <ca5c54b6ff05> (public/hvm: export the HVM_PARAM_CALLBACK_VIA
> ABI in the API).
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

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


>  include/xen/interface/hvm/params.h | 27 +++++++++++++++++++++------
>  1 file changed, 21 insertions(+), 6 deletions(-)
> 
> diff --git a/include/xen/interface/hvm/params.h b/include/xen/interface/hvm/params.h
> index a6c7991..70ad208 100644
> --- a/include/xen/interface/hvm/params.h
> +++ b/include/xen/interface/hvm/params.h
> @@ -27,16 +27,31 @@
>   * Parameter space for HVMOP_{set,get}_param.
>   */
>  
> +#define HVM_PARAM_CALLBACK_IRQ 0
>  /*
>   * How should CPU0 event-channel notifications be delivered?
> - * val[63:56] == 0: val[55:0] is a delivery GSI (Global System Interrupt).
> - * val[63:56] == 1: val[55:0] is a delivery PCI INTx line, as follows:
> - *                  Domain = val[47:32], Bus  = val[31:16],
> - *                  DevFn  = val[15: 8], IntX = val[ 1: 0]
> - * val[63:56] == 2: val[7:0] is a vector number.
> + *
>   * If val == 0 then CPU0 event-channel notifications are not delivered.
> + * If val != 0, val[63:56] encodes the type, as follows:
> + */
> +
> +#define HVM_PARAM_CALLBACK_TYPE_GSI      0
> +/*
> + * val[55:0] is a delivery GSI.  GSI 0 cannot be used, as it aliases val == 0,
> + * and disables all notifications.
> + */
> +
> +#define HVM_PARAM_CALLBACK_TYPE_PCI_INTX 1
> +/*
> + * val[55:0] is a delivery PCI INTx line:
> + * Domain = val[47:32], Bus = val[31:16] DevFn = val[15:8], IntX = val[1:0]
> + */
> +
> +#define HVM_PARAM_CALLBACK_TYPE_VECTOR   2
> +/*
> + * val[7:0] is a vector number.  Check for XENFEAT_hvm_callback_vector to know
> + * if this delivery method is available.
>   */
> -#define HVM_PARAM_CALLBACK_IRQ 0
>  
>  #define HVM_PARAM_STORE_PFN    1
>  #define HVM_PARAM_STORE_EVTCHN 2
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v3 08/17] Xen: public/hvm: sync changes of HVM_PARAM_CALLBACK_VIA ABI from Xen
@ 2016-01-25 15:06     ` Stefano Stabellini
  0 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 15:06 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel, catalin.marinas, will.deacon,
	julien.grall, xen-devel, devicetree, linux-efi, linux-kernel,
	ian.campbell, shannon.zhao, peter.huangpeng

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Sync the changes of HVM_PARAM_CALLBACK_VIA ABI introduced by
> Xen commit <ca5c54b6ff05> (public/hvm: export the HVM_PARAM_CALLBACK_VIA
> ABI in the API).
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

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


>  include/xen/interface/hvm/params.h | 27 +++++++++++++++++++++------
>  1 file changed, 21 insertions(+), 6 deletions(-)
> 
> diff --git a/include/xen/interface/hvm/params.h b/include/xen/interface/hvm/params.h
> index a6c7991..70ad208 100644
> --- a/include/xen/interface/hvm/params.h
> +++ b/include/xen/interface/hvm/params.h
> @@ -27,16 +27,31 @@
>   * Parameter space for HVMOP_{set,get}_param.
>   */
>  
> +#define HVM_PARAM_CALLBACK_IRQ 0
>  /*
>   * How should CPU0 event-channel notifications be delivered?
> - * val[63:56] == 0: val[55:0] is a delivery GSI (Global System Interrupt).
> - * val[63:56] == 1: val[55:0] is a delivery PCI INTx line, as follows:
> - *                  Domain = val[47:32], Bus  = val[31:16],
> - *                  DevFn  = val[15: 8], IntX = val[ 1: 0]
> - * val[63:56] == 2: val[7:0] is a vector number.
> + *
>   * If val == 0 then CPU0 event-channel notifications are not delivered.
> + * If val != 0, val[63:56] encodes the type, as follows:
> + */
> +
> +#define HVM_PARAM_CALLBACK_TYPE_GSI      0
> +/*
> + * val[55:0] is a delivery GSI.  GSI 0 cannot be used, as it aliases val == 0,
> + * and disables all notifications.
> + */
> +
> +#define HVM_PARAM_CALLBACK_TYPE_PCI_INTX 1
> +/*
> + * val[55:0] is a delivery PCI INTx line:
> + * Domain = val[47:32], Bus = val[31:16] DevFn = val[15:8], IntX = val[1:0]
> + */
> +
> +#define HVM_PARAM_CALLBACK_TYPE_VECTOR   2
> +/*
> + * val[7:0] is a vector number.  Check for XENFEAT_hvm_callback_vector to know
> + * if this delivery method is available.
>   */
> -#define HVM_PARAM_CALLBACK_IRQ 0
>  
>  #define HVM_PARAM_STORE_PFN    1
>  #define HVM_PARAM_STORE_EVTCHN 2
> -- 
> 2.0.4
> 
> 

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

* [PATCH v3 08/17] Xen: public/hvm: sync changes of HVM_PARAM_CALLBACK_VIA ABI from Xen
@ 2016-01-25 15:06     ` Stefano Stabellini
  0 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 15:06 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Sync the changes of HVM_PARAM_CALLBACK_VIA ABI introduced by
> Xen commit <ca5c54b6ff05> (public/hvm: export the HVM_PARAM_CALLBACK_VIA
> ABI in the API).
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

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


>  include/xen/interface/hvm/params.h | 27 +++++++++++++++++++++------
>  1 file changed, 21 insertions(+), 6 deletions(-)
> 
> diff --git a/include/xen/interface/hvm/params.h b/include/xen/interface/hvm/params.h
> index a6c7991..70ad208 100644
> --- a/include/xen/interface/hvm/params.h
> +++ b/include/xen/interface/hvm/params.h
> @@ -27,16 +27,31 @@
>   * Parameter space for HVMOP_{set,get}_param.
>   */
>  
> +#define HVM_PARAM_CALLBACK_IRQ 0
>  /*
>   * How should CPU0 event-channel notifications be delivered?
> - * val[63:56] == 0: val[55:0] is a delivery GSI (Global System Interrupt).
> - * val[63:56] == 1: val[55:0] is a delivery PCI INTx line, as follows:
> - *                  Domain = val[47:32], Bus  = val[31:16],
> - *                  DevFn  = val[15: 8], IntX = val[ 1: 0]
> - * val[63:56] == 2: val[7:0] is a vector number.
> + *
>   * If val == 0 then CPU0 event-channel notifications are not delivered.
> + * If val != 0, val[63:56] encodes the type, as follows:
> + */
> +
> +#define HVM_PARAM_CALLBACK_TYPE_GSI      0
> +/*
> + * val[55:0] is a delivery GSI.  GSI 0 cannot be used, as it aliases val == 0,
> + * and disables all notifications.
> + */
> +
> +#define HVM_PARAM_CALLBACK_TYPE_PCI_INTX 1
> +/*
> + * val[55:0] is a delivery PCI INTx line:
> + * Domain = val[47:32], Bus = val[31:16] DevFn = val[15:8], IntX = val[1:0]
> + */
> +
> +#define HVM_PARAM_CALLBACK_TYPE_VECTOR   2
> +/*
> + * val[7:0] is a vector number.  Check for XENFEAT_hvm_callback_vector to know
> + * if this delivery method is available.
>   */
> -#define HVM_PARAM_CALLBACK_IRQ 0
>  
>  #define HVM_PARAM_STORE_PFN    1
>  #define HVM_PARAM_STORE_EVTCHN 2
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v3 08/17] Xen: public/hvm: sync changes of HVM_PARAM_CALLBACK_VIA ABI from Xen
  2016-01-23  3:19   ` Shannon Zhao
                     ` (2 preceding siblings ...)
  (?)
@ 2016-01-25 15:06   ` Stefano Stabellini
  -1 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 15:06 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: mark.rutland, devicetree, linux-efi, ian.campbell,
	ard.biesheuvel, catalin.marinas, will.deacon, linux-kernel,
	xen-devel, julien.grall, stefano.stabellini, david.vrabel,
	peter.huangpeng, linux-arm-kernel, shannon.zhao

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Sync the changes of HVM_PARAM_CALLBACK_VIA ABI introduced by
> Xen commit <ca5c54b6ff05> (public/hvm: export the HVM_PARAM_CALLBACK_VIA
> ABI in the API).
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

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


>  include/xen/interface/hvm/params.h | 27 +++++++++++++++++++++------
>  1 file changed, 21 insertions(+), 6 deletions(-)
> 
> diff --git a/include/xen/interface/hvm/params.h b/include/xen/interface/hvm/params.h
> index a6c7991..70ad208 100644
> --- a/include/xen/interface/hvm/params.h
> +++ b/include/xen/interface/hvm/params.h
> @@ -27,16 +27,31 @@
>   * Parameter space for HVMOP_{set,get}_param.
>   */
>  
> +#define HVM_PARAM_CALLBACK_IRQ 0
>  /*
>   * How should CPU0 event-channel notifications be delivered?
> - * val[63:56] == 0: val[55:0] is a delivery GSI (Global System Interrupt).
> - * val[63:56] == 1: val[55:0] is a delivery PCI INTx line, as follows:
> - *                  Domain = val[47:32], Bus  = val[31:16],
> - *                  DevFn  = val[15: 8], IntX = val[ 1: 0]
> - * val[63:56] == 2: val[7:0] is a vector number.
> + *
>   * If val == 0 then CPU0 event-channel notifications are not delivered.
> + * If val != 0, val[63:56] encodes the type, as follows:
> + */
> +
> +#define HVM_PARAM_CALLBACK_TYPE_GSI      0
> +/*
> + * val[55:0] is a delivery GSI.  GSI 0 cannot be used, as it aliases val == 0,
> + * and disables all notifications.
> + */
> +
> +#define HVM_PARAM_CALLBACK_TYPE_PCI_INTX 1
> +/*
> + * val[55:0] is a delivery PCI INTx line:
> + * Domain = val[47:32], Bus = val[31:16] DevFn = val[15:8], IntX = val[1:0]
> + */
> +
> +#define HVM_PARAM_CALLBACK_TYPE_VECTOR   2
> +/*
> + * val[7:0] is a vector number.  Check for XENFEAT_hvm_callback_vector to know
> + * if this delivery method is available.
>   */
> -#define HVM_PARAM_CALLBACK_IRQ 0
>  
>  #define HVM_PARAM_STORE_PFN    1
>  #define HVM_PARAM_STORE_EVTCHN 2
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v3 09/17] xen/hvm/params: Add a new delivery type for event-channel in HVM_PARAM_CALLBACK_IRQ
  2016-01-23  3:19   ` Shannon Zhao
  (?)
@ 2016-01-25 15:08     ` Stefano Stabellini
  -1 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 15:08 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel, catalin.marinas, will.deacon,
	julien.grall, xen-devel, devicetree, linux-efi, linux-kernel,
	ian.campbell, shannon.zhao, peter.huangpeng

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Add a new delivery 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>

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


>  include/xen/interface/hvm/params.h | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/include/xen/interface/hvm/params.h b/include/xen/interface/hvm/params.h
> index 70ad208..5dd629f 100644
> --- a/include/xen/interface/hvm/params.h
> +++ b/include/xen/interface/hvm/params.h
> @@ -53,6 +53,15 @@
>   * if this delivery method is available.
>   */
>  
> +#define HVM_PARAM_CALLBACK_TYPE_EVENT    3
> +/*
> + * val[15:8] is flag of event-channel interrupt:
> + *  bit 0: interrupt is edge(1) or level(0) triggered
> + *  bit 1: interrupt is active low(1) or high(0)
> + * val[7:0] is PPI number used by event-channel.
> + * This is only used by ARM/ARM64.
> + */
> +
>  #define HVM_PARAM_STORE_PFN    1
>  #define HVM_PARAM_STORE_EVTCHN 2
>  
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v3 09/17] xen/hvm/params: Add a new delivery type for event-channel in HVM_PARAM_CALLBACK_IRQ
@ 2016-01-25 15:08     ` Stefano Stabellini
  0 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 15:08 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel, catalin.marinas, will.deacon,
	julien.grall, xen-devel, devicetree, linux-efi, linux-kernel,
	ian.campbell, shannon.zhao, peter.huangpeng

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Add a new delivery 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>

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


>  include/xen/interface/hvm/params.h | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/include/xen/interface/hvm/params.h b/include/xen/interface/hvm/params.h
> index 70ad208..5dd629f 100644
> --- a/include/xen/interface/hvm/params.h
> +++ b/include/xen/interface/hvm/params.h
> @@ -53,6 +53,15 @@
>   * if this delivery method is available.
>   */
>  
> +#define HVM_PARAM_CALLBACK_TYPE_EVENT    3
> +/*
> + * val[15:8] is flag of event-channel interrupt:
> + *  bit 0: interrupt is edge(1) or level(0) triggered
> + *  bit 1: interrupt is active low(1) or high(0)
> + * val[7:0] is PPI number used by event-channel.
> + * This is only used by ARM/ARM64.
> + */
> +
>  #define HVM_PARAM_STORE_PFN    1
>  #define HVM_PARAM_STORE_EVTCHN 2
>  
> -- 
> 2.0.4
> 
> 

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

* [PATCH v3 09/17] xen/hvm/params: Add a new delivery type for event-channel in HVM_PARAM_CALLBACK_IRQ
@ 2016-01-25 15:08     ` Stefano Stabellini
  0 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 15:08 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Add a new delivery 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>

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


>  include/xen/interface/hvm/params.h | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/include/xen/interface/hvm/params.h b/include/xen/interface/hvm/params.h
> index 70ad208..5dd629f 100644
> --- a/include/xen/interface/hvm/params.h
> +++ b/include/xen/interface/hvm/params.h
> @@ -53,6 +53,15 @@
>   * if this delivery method is available.
>   */
>  
> +#define HVM_PARAM_CALLBACK_TYPE_EVENT    3
> +/*
> + * val[15:8] is flag of event-channel interrupt:
> + *  bit 0: interrupt is edge(1) or level(0) triggered
> + *  bit 1: interrupt is active low(1) or high(0)
> + * val[7:0] is PPI number used by event-channel.
> + * This is only used by ARM/ARM64.
> + */
> +
>  #define HVM_PARAM_STORE_PFN    1
>  #define HVM_PARAM_STORE_EVTCHN 2
>  
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v3 09/17] xen/hvm/params: Add a new delivery type for event-channel in HVM_PARAM_CALLBACK_IRQ
  2016-01-23  3:19   ` Shannon Zhao
  (?)
  (?)
@ 2016-01-25 15:08   ` Stefano Stabellini
  -1 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 15:08 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: mark.rutland, devicetree, linux-efi, ian.campbell,
	ard.biesheuvel, catalin.marinas, will.deacon, linux-kernel,
	xen-devel, julien.grall, stefano.stabellini, david.vrabel,
	peter.huangpeng, linux-arm-kernel, shannon.zhao

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Add a new delivery 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>

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


>  include/xen/interface/hvm/params.h | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/include/xen/interface/hvm/params.h b/include/xen/interface/hvm/params.h
> index 70ad208..5dd629f 100644
> --- a/include/xen/interface/hvm/params.h
> +++ b/include/xen/interface/hvm/params.h
> @@ -53,6 +53,15 @@
>   * if this delivery method is available.
>   */
>  
> +#define HVM_PARAM_CALLBACK_TYPE_EVENT    3
> +/*
> + * val[15:8] is flag of event-channel interrupt:
> + *  bit 0: interrupt is edge(1) or level(0) triggered
> + *  bit 1: interrupt is active low(1) or high(0)
> + * val[7:0] is PPI number used by event-channel.
> + * This is only used by ARM/ARM64.
> + */
> +
>  #define HVM_PARAM_STORE_PFN    1
>  #define HVM_PARAM_STORE_EVTCHN 2
>  
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v3 10/17] arm/xen: Get event-channel irq through HVM_PARAM when booting with ACPI
@ 2016-01-25 15:19     ` Stefano Stabellini
  0 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 15:19 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel, catalin.marinas, will.deacon,
	julien.grall, xen-devel, devicetree, linux-efi, linux-kernel,
	ian.campbell, shannon.zhao, peter.huangpeng

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> When booting with ACPI, it could get the event-channel irq through
> HVM_PARAM_CALLBACK_IRQ.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  arch/arm/xen/enlighten.c | 36 +++++++++++++++++++++++++++++++++++-
>  1 file changed, 35 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
> index 6d90a62..0e010bb 100644
> --- a/arch/arm/xen/enlighten.c
> +++ b/arch/arm/xen/enlighten.c
> @@ -29,6 +29,7 @@
>  #include <linux/time64.h>
>  #include <linux/timekeeping.h>
>  #include <linux/timekeeper_internal.h>
> +#include <linux/acpi.h>
>  
>  #include <linux/mm.h>
>  
> @@ -262,6 +263,35 @@ void __init xen_early_init(void)
>  		add_preferred_console("hvc", 0, NULL);
>  }
>  
> +static void __init xen_acpi_guest_init_events_irq(void)

please rename it to "xen_acpi_guest_init"


> +{
> +#ifdef CONFIG_ACPI
> +	struct xen_hvm_param a;
> +	int interrupt, trigger, polarity;
> +
> +	a.domid = DOMID_SELF;
> +	a.index = HVM_PARAM_CALLBACK_IRQ;
> +	xen_events_irq = 0;
> +
> +	if (!HYPERVISOR_hvm_op(HVMOP_get_param, &a)) {
> +		if ((a.value >> 56) == HVM_PARAM_CALLBACK_TYPE_EVENT) {
> +			interrupt = a.value & 0xff;
> +			trigger = ((a.value >> 8) & 0x1) ? ACPI_EDGE_SENSITIVE
> +							 : ACPI_LEVEL_SENSITIVE;
> +			polarity = ((a.value >> 8) & 0x2) ? ACPI_ACTIVE_LOW
> +							  : ACPI_ACTIVE_HIGH;
> +			xen_events_irq = acpi_register_gsi(NULL, interrupt,
> +							   trigger, polarity);
> +		}
> +	}
> +#endif
> +}
> +
> +static void __init xen_dt_guest_init_events_irq(void)

"xen_dt_guest_init"

Provided that you make these two changes:

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



> +{
> +	xen_events_irq = irq_of_parse_and_map(xen_node, 0);
> +}
> +
>  static int __init xen_guest_init(void)
>  {
>  	struct xen_add_to_physmap xatp;
> @@ -270,7 +300,11 @@ static int __init xen_guest_init(void)
>  	if (!xen_domain())
>  		return 0;
>  
> -	xen_events_irq = irq_of_parse_and_map(xen_node, 0);
> +	if (!acpi_disabled)
> +		xen_acpi_guest_init_events_irq();
> +	else
> +		xen_dt_guest_init_events_irq();
> +
>  	if (!xen_events_irq) {
>  		pr_err("Xen event channel interrupt not found\n");
>  		return -ENODEV;
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v3 10/17] arm/xen: Get event-channel irq through HVM_PARAM when booting with ACPI
@ 2016-01-25 15:19     ` Stefano Stabellini
  0 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 15:19 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	stefano.stabellini-Sxgqhf6Nn4DQT0dZR+AlfA,
	david.vrabel-Sxgqhf6Nn4DQT0dZR+AlfA, catalin.marinas-5wv7dgnIgG8,
	will.deacon-5wv7dgnIgG8, julien.grall-Sxgqhf6Nn4DQT0dZR+AlfA,
	xen-devel-GuqFBffKawuEi8DpZVb4nw,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-efi-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	ian.campbell-Sxgqhf6Nn4DQT0dZR+AlfA,
	shannon.zhao-QSEj5FYQhm4dnm+yROfE0A,
	peter.huangpeng-hv44wF8Li93QT0dZR+AlfA

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> 
> When booting with ACPI, it could get the event-channel irq through
> HVM_PARAM_CALLBACK_IRQ.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> ---
>  arch/arm/xen/enlighten.c | 36 +++++++++++++++++++++++++++++++++++-
>  1 file changed, 35 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
> index 6d90a62..0e010bb 100644
> --- a/arch/arm/xen/enlighten.c
> +++ b/arch/arm/xen/enlighten.c
> @@ -29,6 +29,7 @@
>  #include <linux/time64.h>
>  #include <linux/timekeeping.h>
>  #include <linux/timekeeper_internal.h>
> +#include <linux/acpi.h>
>  
>  #include <linux/mm.h>
>  
> @@ -262,6 +263,35 @@ void __init xen_early_init(void)
>  		add_preferred_console("hvc", 0, NULL);
>  }
>  
> +static void __init xen_acpi_guest_init_events_irq(void)

please rename it to "xen_acpi_guest_init"


> +{
> +#ifdef CONFIG_ACPI
> +	struct xen_hvm_param a;
> +	int interrupt, trigger, polarity;
> +
> +	a.domid = DOMID_SELF;
> +	a.index = HVM_PARAM_CALLBACK_IRQ;
> +	xen_events_irq = 0;
> +
> +	if (!HYPERVISOR_hvm_op(HVMOP_get_param, &a)) {
> +		if ((a.value >> 56) == HVM_PARAM_CALLBACK_TYPE_EVENT) {
> +			interrupt = a.value & 0xff;
> +			trigger = ((a.value >> 8) & 0x1) ? ACPI_EDGE_SENSITIVE
> +							 : ACPI_LEVEL_SENSITIVE;
> +			polarity = ((a.value >> 8) & 0x2) ? ACPI_ACTIVE_LOW
> +							  : ACPI_ACTIVE_HIGH;
> +			xen_events_irq = acpi_register_gsi(NULL, interrupt,
> +							   trigger, polarity);
> +		}
> +	}
> +#endif
> +}
> +
> +static void __init xen_dt_guest_init_events_irq(void)

"xen_dt_guest_init"

Provided that you make these two changes:

Reviewed-by: Stefano Stabellini <stefano.stabellini-mvvWK6WmYclDPfheJLI6IQ@public.gmane.org>



> +{
> +	xen_events_irq = irq_of_parse_and_map(xen_node, 0);
> +}
> +
>  static int __init xen_guest_init(void)
>  {
>  	struct xen_add_to_physmap xatp;
> @@ -270,7 +300,11 @@ static int __init xen_guest_init(void)
>  	if (!xen_domain())
>  		return 0;
>  
> -	xen_events_irq = irq_of_parse_and_map(xen_node, 0);
> +	if (!acpi_disabled)
> +		xen_acpi_guest_init_events_irq();
> +	else
> +		xen_dt_guest_init_events_irq();
> +
>  	if (!xen_events_irq) {
>  		pr_err("Xen event channel interrupt not found\n");
>  		return -ENODEV;
> -- 
> 2.0.4
> 
> 
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v3 10/17] arm/xen: Get event-channel irq through HVM_PARAM when booting with ACPI
@ 2016-01-25 15:19     ` Stefano Stabellini
  0 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 15:19 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> When booting with ACPI, it could get the event-channel irq through
> HVM_PARAM_CALLBACK_IRQ.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  arch/arm/xen/enlighten.c | 36 +++++++++++++++++++++++++++++++++++-
>  1 file changed, 35 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
> index 6d90a62..0e010bb 100644
> --- a/arch/arm/xen/enlighten.c
> +++ b/arch/arm/xen/enlighten.c
> @@ -29,6 +29,7 @@
>  #include <linux/time64.h>
>  #include <linux/timekeeping.h>
>  #include <linux/timekeeper_internal.h>
> +#include <linux/acpi.h>
>  
>  #include <linux/mm.h>
>  
> @@ -262,6 +263,35 @@ void __init xen_early_init(void)
>  		add_preferred_console("hvc", 0, NULL);
>  }
>  
> +static void __init xen_acpi_guest_init_events_irq(void)

please rename it to "xen_acpi_guest_init"


> +{
> +#ifdef CONFIG_ACPI
> +	struct xen_hvm_param a;
> +	int interrupt, trigger, polarity;
> +
> +	a.domid = DOMID_SELF;
> +	a.index = HVM_PARAM_CALLBACK_IRQ;
> +	xen_events_irq = 0;
> +
> +	if (!HYPERVISOR_hvm_op(HVMOP_get_param, &a)) {
> +		if ((a.value >> 56) == HVM_PARAM_CALLBACK_TYPE_EVENT) {
> +			interrupt = a.value & 0xff;
> +			trigger = ((a.value >> 8) & 0x1) ? ACPI_EDGE_SENSITIVE
> +							 : ACPI_LEVEL_SENSITIVE;
> +			polarity = ((a.value >> 8) & 0x2) ? ACPI_ACTIVE_LOW
> +							  : ACPI_ACTIVE_HIGH;
> +			xen_events_irq = acpi_register_gsi(NULL, interrupt,
> +							   trigger, polarity);
> +		}
> +	}
> +#endif
> +}
> +
> +static void __init xen_dt_guest_init_events_irq(void)

"xen_dt_guest_init"

Provided that you make these two changes:

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



> +{
> +	xen_events_irq = irq_of_parse_and_map(xen_node, 0);
> +}
> +
>  static int __init xen_guest_init(void)
>  {
>  	struct xen_add_to_physmap xatp;
> @@ -270,7 +300,11 @@ static int __init xen_guest_init(void)
>  	if (!xen_domain())
>  		return 0;
>  
> -	xen_events_irq = irq_of_parse_and_map(xen_node, 0);
> +	if (!acpi_disabled)
> +		xen_acpi_guest_init_events_irq();
> +	else
> +		xen_dt_guest_init_events_irq();
> +
>  	if (!xen_events_irq) {
>  		pr_err("Xen event channel interrupt not found\n");
>  		return -ENODEV;
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v3 10/17] arm/xen: Get event-channel irq through HVM_PARAM when booting with ACPI
  2016-01-23  3:19   ` Shannon Zhao
  (?)
  (?)
@ 2016-01-25 15:19   ` Stefano Stabellini
  -1 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 15:19 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: mark.rutland, devicetree, linux-efi, ian.campbell,
	ard.biesheuvel, catalin.marinas, will.deacon, linux-kernel,
	xen-devel, julien.grall, stefano.stabellini, david.vrabel,
	peter.huangpeng, linux-arm-kernel, shannon.zhao

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> When booting with ACPI, it could get the event-channel irq through
> HVM_PARAM_CALLBACK_IRQ.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  arch/arm/xen/enlighten.c | 36 +++++++++++++++++++++++++++++++++++-
>  1 file changed, 35 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
> index 6d90a62..0e010bb 100644
> --- a/arch/arm/xen/enlighten.c
> +++ b/arch/arm/xen/enlighten.c
> @@ -29,6 +29,7 @@
>  #include <linux/time64.h>
>  #include <linux/timekeeping.h>
>  #include <linux/timekeeper_internal.h>
> +#include <linux/acpi.h>
>  
>  #include <linux/mm.h>
>  
> @@ -262,6 +263,35 @@ void __init xen_early_init(void)
>  		add_preferred_console("hvc", 0, NULL);
>  }
>  
> +static void __init xen_acpi_guest_init_events_irq(void)

please rename it to "xen_acpi_guest_init"


> +{
> +#ifdef CONFIG_ACPI
> +	struct xen_hvm_param a;
> +	int interrupt, trigger, polarity;
> +
> +	a.domid = DOMID_SELF;
> +	a.index = HVM_PARAM_CALLBACK_IRQ;
> +	xen_events_irq = 0;
> +
> +	if (!HYPERVISOR_hvm_op(HVMOP_get_param, &a)) {
> +		if ((a.value >> 56) == HVM_PARAM_CALLBACK_TYPE_EVENT) {
> +			interrupt = a.value & 0xff;
> +			trigger = ((a.value >> 8) & 0x1) ? ACPI_EDGE_SENSITIVE
> +							 : ACPI_LEVEL_SENSITIVE;
> +			polarity = ((a.value >> 8) & 0x2) ? ACPI_ACTIVE_LOW
> +							  : ACPI_ACTIVE_HIGH;
> +			xen_events_irq = acpi_register_gsi(NULL, interrupt,
> +							   trigger, polarity);
> +		}
> +	}
> +#endif
> +}
> +
> +static void __init xen_dt_guest_init_events_irq(void)

"xen_dt_guest_init"

Provided that you make these two changes:

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



> +{
> +	xen_events_irq = irq_of_parse_and_map(xen_node, 0);
> +}
> +
>  static int __init xen_guest_init(void)
>  {
>  	struct xen_add_to_physmap xatp;
> @@ -270,7 +300,11 @@ static int __init xen_guest_init(void)
>  	if (!xen_domain())
>  		return 0;
>  
> -	xen_events_irq = irq_of_parse_and_map(xen_node, 0);
> +	if (!acpi_disabled)
> +		xen_acpi_guest_init_events_irq();
> +	else
> +		xen_dt_guest_init_events_irq();
> +
>  	if (!xen_events_irq) {
>  		pr_err("Xen event channel interrupt not found\n");
>  		return -ENODEV;
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v3 11/17] ARM: XEN: Move xen_early_init() before efi_init()
@ 2016-01-25 15:25     ` Stefano Stabellini
  0 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 15:25 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel, catalin.marinas, will.deacon,
	julien.grall, xen-devel, devicetree, linux-efi, linux-kernel,
	ian.campbell, shannon.zhao, peter.huangpeng

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Move xen_early_init() before efi_init(), then when calling efi_init()
> could initialize Xen specific UEFI.
> 
> Check if it runs on Xen hypervisor through the flat dts.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

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


>  arch/arm/xen/enlighten.c  | 56 ++++++++++++++++++++++++++++++++++-------------
>  arch/arm64/kernel/setup.c |  2 +-
>  2 files changed, 42 insertions(+), 16 deletions(-)
> 
> diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
> index 0e010bb..cdc0bd2 100644
> --- a/arch/arm/xen/enlighten.c
> +++ b/arch/arm/xen/enlighten.c
> @@ -19,6 +19,7 @@
>  #include <linux/irqreturn.h>
>  #include <linux/module.h>
>  #include <linux/of.h>
> +#include <linux/of_fdt.h>
>  #include <linux/of_irq.h>
>  #include <linux/of_address.h>
>  #include <linux/cpuidle.h>
> @@ -52,8 +53,6 @@ struct xen_memory_region xen_extra_mem[XEN_EXTRA_MEM_MAX_REGIONS] __initdata;
>  
>  static __read_mostly unsigned int xen_events_irq;
>  
> -static __initdata struct device_node *xen_node;
> -
>  int xen_remap_domain_gfn_array(struct vm_area_struct *vma,
>  			       unsigned long addr,
>  			       xen_pfn_t *gfn, int nr,
> @@ -222,6 +221,33 @@ static irqreturn_t xen_arm_callback(int irq, void *arg)
>  	return IRQ_HANDLED;
>  }
>  
> +static __initdata struct {
> +	const char *compat;
> +	const char *prefix;
> +	const char *version;
> +	bool found;
> +} hyper_node = {"xen,xen", "xen,xen-", NULL, false};
> +
> +static int __init fdt_find_hyper_node(unsigned long node, const char *uname,
> +				      int depth, void *data)
> +{
> +	const void *s = NULL;
> +	int len;
> +
> +	if (depth != 1 || strcmp(uname, "hypervisor") != 0)
> +		return 0;
> +
> +	if (of_flat_dt_is_compatible(node, hyper_node.compat))
> +		hyper_node.found = true;
> +
> +	s = of_get_flat_dt_prop(node, "compatible", &len);
> +	if (strlen(hyper_node.prefix) + 3  < len &&
> +	    !strncmp(hyper_node.prefix, s, strlen(hyper_node.prefix)))
> +		hyper_node.version = s + strlen(hyper_node.prefix);
> +
> +	return 0;
> +}
> +
>  /*
>   * see Documentation/devicetree/bindings/arm/xen.txt for the
>   * documentation of the Xen Device Tree format.
> @@ -229,26 +255,18 @@ static irqreturn_t xen_arm_callback(int irq, void *arg)
>  #define GRANT_TABLE_PHYSADDR 0
>  void __init xen_early_init(void)
>  {
> -	int len;
> -	const char *s = NULL;
> -	const char *version = NULL;
> -	const char *xen_prefix = "xen,xen-";
> -
> -	xen_node = of_find_compatible_node(NULL, NULL, "xen,xen");
> -	if (!xen_node) {
> +	of_scan_flat_dt(fdt_find_hyper_node, NULL);
> +	if (!hyper_node.found) {
>  		pr_debug("No Xen support\n");
>  		return;
>  	}
> -	s = of_get_property(xen_node, "compatible", &len);
> -	if (strlen(xen_prefix) + 3  < len &&
> -			!strncmp(xen_prefix, s, strlen(xen_prefix)))
> -		version = s + strlen(xen_prefix);
> -	if (version == NULL) {
> +
> +	if (hyper_node.version == NULL) {
>  		pr_debug("Xen version not found\n");
>  		return;
>  	}
>  
> -	pr_info("Xen %s support found\n", version);
> +	pr_info("Xen %s support found\n", hyper_node.version);
>  
>  	xen_domain_type = XEN_HVM_DOMAIN;
>  
> @@ -289,6 +307,14 @@ static void __init xen_acpi_guest_init_events_irq(void)
>  
>  static void __init xen_dt_guest_init_events_irq(void)
>  {
> +	struct device_node *xen_node;
> +
> +	xen_node = of_find_compatible_node(NULL, NULL, "xen,xen");
> +	if (!xen_node) {
> +		pr_err("Xen support was detected before, but it has disappeared\n");
> +		return;
> +	}
> +
>  	xen_events_irq = irq_of_parse_and_map(xen_node, 0);
>  }
>  
> diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
> index 8119479..a4a2878 100644
> --- a/arch/arm64/kernel/setup.c
> +++ b/arch/arm64/kernel/setup.c
> @@ -313,6 +313,7 @@ void __init setup_arch(char **cmdline_p)
>  	 */
>  	local_async_enable();
>  
> +	xen_early_init();
>  	efi_init();
>  	arm64_memblock_init();
>  
> @@ -334,7 +335,6 @@ void __init setup_arch(char **cmdline_p)
>  	} else {
>  		psci_acpi_init();
>  	}
> -	xen_early_init();
>  
>  	cpu_read_bootcpu_ops();
>  	smp_init_cpus();
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v3 11/17] ARM: XEN: Move xen_early_init() before efi_init()
@ 2016-01-25 15:25     ` Stefano Stabellini
  0 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 15:25 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	stefano.stabellini-Sxgqhf6Nn4DQT0dZR+AlfA,
	david.vrabel-Sxgqhf6Nn4DQT0dZR+AlfA, catalin.marinas-5wv7dgnIgG8,
	will.deacon-5wv7dgnIgG8, julien.grall-Sxgqhf6Nn4DQT0dZR+AlfA,
	xen-devel-GuqFBffKawuEi8DpZVb4nw,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-efi-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	ian.campbell-Sxgqhf6Nn4DQT0dZR+AlfA,
	shannon.zhao-QSEj5FYQhm4dnm+yROfE0A,
	peter.huangpeng-hv44wF8Li93QT0dZR+AlfA

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> 
> Move xen_early_init() before efi_init(), then when calling efi_init()
> could initialize Xen specific UEFI.
> 
> Check if it runs on Xen hypervisor through the flat dts.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>

Reviewed-by: Stefano Stabellini <stefano.stabellini-mvvWK6WmYclDPfheJLI6IQ@public.gmane.org>


>  arch/arm/xen/enlighten.c  | 56 ++++++++++++++++++++++++++++++++++-------------
>  arch/arm64/kernel/setup.c |  2 +-
>  2 files changed, 42 insertions(+), 16 deletions(-)
> 
> diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
> index 0e010bb..cdc0bd2 100644
> --- a/arch/arm/xen/enlighten.c
> +++ b/arch/arm/xen/enlighten.c
> @@ -19,6 +19,7 @@
>  #include <linux/irqreturn.h>
>  #include <linux/module.h>
>  #include <linux/of.h>
> +#include <linux/of_fdt.h>
>  #include <linux/of_irq.h>
>  #include <linux/of_address.h>
>  #include <linux/cpuidle.h>
> @@ -52,8 +53,6 @@ struct xen_memory_region xen_extra_mem[XEN_EXTRA_MEM_MAX_REGIONS] __initdata;
>  
>  static __read_mostly unsigned int xen_events_irq;
>  
> -static __initdata struct device_node *xen_node;
> -
>  int xen_remap_domain_gfn_array(struct vm_area_struct *vma,
>  			       unsigned long addr,
>  			       xen_pfn_t *gfn, int nr,
> @@ -222,6 +221,33 @@ static irqreturn_t xen_arm_callback(int irq, void *arg)
>  	return IRQ_HANDLED;
>  }
>  
> +static __initdata struct {
> +	const char *compat;
> +	const char *prefix;
> +	const char *version;
> +	bool found;
> +} hyper_node = {"xen,xen", "xen,xen-", NULL, false};
> +
> +static int __init fdt_find_hyper_node(unsigned long node, const char *uname,
> +				      int depth, void *data)
> +{
> +	const void *s = NULL;
> +	int len;
> +
> +	if (depth != 1 || strcmp(uname, "hypervisor") != 0)
> +		return 0;
> +
> +	if (of_flat_dt_is_compatible(node, hyper_node.compat))
> +		hyper_node.found = true;
> +
> +	s = of_get_flat_dt_prop(node, "compatible", &len);
> +	if (strlen(hyper_node.prefix) + 3  < len &&
> +	    !strncmp(hyper_node.prefix, s, strlen(hyper_node.prefix)))
> +		hyper_node.version = s + strlen(hyper_node.prefix);
> +
> +	return 0;
> +}
> +
>  /*
>   * see Documentation/devicetree/bindings/arm/xen.txt for the
>   * documentation of the Xen Device Tree format.
> @@ -229,26 +255,18 @@ static irqreturn_t xen_arm_callback(int irq, void *arg)
>  #define GRANT_TABLE_PHYSADDR 0
>  void __init xen_early_init(void)
>  {
> -	int len;
> -	const char *s = NULL;
> -	const char *version = NULL;
> -	const char *xen_prefix = "xen,xen-";
> -
> -	xen_node = of_find_compatible_node(NULL, NULL, "xen,xen");
> -	if (!xen_node) {
> +	of_scan_flat_dt(fdt_find_hyper_node, NULL);
> +	if (!hyper_node.found) {
>  		pr_debug("No Xen support\n");
>  		return;
>  	}
> -	s = of_get_property(xen_node, "compatible", &len);
> -	if (strlen(xen_prefix) + 3  < len &&
> -			!strncmp(xen_prefix, s, strlen(xen_prefix)))
> -		version = s + strlen(xen_prefix);
> -	if (version == NULL) {
> +
> +	if (hyper_node.version == NULL) {
>  		pr_debug("Xen version not found\n");
>  		return;
>  	}
>  
> -	pr_info("Xen %s support found\n", version);
> +	pr_info("Xen %s support found\n", hyper_node.version);
>  
>  	xen_domain_type = XEN_HVM_DOMAIN;
>  
> @@ -289,6 +307,14 @@ static void __init xen_acpi_guest_init_events_irq(void)
>  
>  static void __init xen_dt_guest_init_events_irq(void)
>  {
> +	struct device_node *xen_node;
> +
> +	xen_node = of_find_compatible_node(NULL, NULL, "xen,xen");
> +	if (!xen_node) {
> +		pr_err("Xen support was detected before, but it has disappeared\n");
> +		return;
> +	}
> +
>  	xen_events_irq = irq_of_parse_and_map(xen_node, 0);
>  }
>  
> diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
> index 8119479..a4a2878 100644
> --- a/arch/arm64/kernel/setup.c
> +++ b/arch/arm64/kernel/setup.c
> @@ -313,6 +313,7 @@ void __init setup_arch(char **cmdline_p)
>  	 */
>  	local_async_enable();
>  
> +	xen_early_init();
>  	efi_init();
>  	arm64_memblock_init();
>  
> @@ -334,7 +335,6 @@ void __init setup_arch(char **cmdline_p)
>  	} else {
>  		psci_acpi_init();
>  	}
> -	xen_early_init();
>  
>  	cpu_read_bootcpu_ops();
>  	smp_init_cpus();
> -- 
> 2.0.4
> 
> 
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v3 11/17] ARM: XEN: Move xen_early_init() before efi_init()
@ 2016-01-25 15:25     ` Stefano Stabellini
  0 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 15:25 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Move xen_early_init() before efi_init(), then when calling efi_init()
> could initialize Xen specific UEFI.
> 
> Check if it runs on Xen hypervisor through the flat dts.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

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


>  arch/arm/xen/enlighten.c  | 56 ++++++++++++++++++++++++++++++++++-------------
>  arch/arm64/kernel/setup.c |  2 +-
>  2 files changed, 42 insertions(+), 16 deletions(-)
> 
> diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
> index 0e010bb..cdc0bd2 100644
> --- a/arch/arm/xen/enlighten.c
> +++ b/arch/arm/xen/enlighten.c
> @@ -19,6 +19,7 @@
>  #include <linux/irqreturn.h>
>  #include <linux/module.h>
>  #include <linux/of.h>
> +#include <linux/of_fdt.h>
>  #include <linux/of_irq.h>
>  #include <linux/of_address.h>
>  #include <linux/cpuidle.h>
> @@ -52,8 +53,6 @@ struct xen_memory_region xen_extra_mem[XEN_EXTRA_MEM_MAX_REGIONS] __initdata;
>  
>  static __read_mostly unsigned int xen_events_irq;
>  
> -static __initdata struct device_node *xen_node;
> -
>  int xen_remap_domain_gfn_array(struct vm_area_struct *vma,
>  			       unsigned long addr,
>  			       xen_pfn_t *gfn, int nr,
> @@ -222,6 +221,33 @@ static irqreturn_t xen_arm_callback(int irq, void *arg)
>  	return IRQ_HANDLED;
>  }
>  
> +static __initdata struct {
> +	const char *compat;
> +	const char *prefix;
> +	const char *version;
> +	bool found;
> +} hyper_node = {"xen,xen", "xen,xen-", NULL, false};
> +
> +static int __init fdt_find_hyper_node(unsigned long node, const char *uname,
> +				      int depth, void *data)
> +{
> +	const void *s = NULL;
> +	int len;
> +
> +	if (depth != 1 || strcmp(uname, "hypervisor") != 0)
> +		return 0;
> +
> +	if (of_flat_dt_is_compatible(node, hyper_node.compat))
> +		hyper_node.found = true;
> +
> +	s = of_get_flat_dt_prop(node, "compatible", &len);
> +	if (strlen(hyper_node.prefix) + 3  < len &&
> +	    !strncmp(hyper_node.prefix, s, strlen(hyper_node.prefix)))
> +		hyper_node.version = s + strlen(hyper_node.prefix);
> +
> +	return 0;
> +}
> +
>  /*
>   * see Documentation/devicetree/bindings/arm/xen.txt for the
>   * documentation of the Xen Device Tree format.
> @@ -229,26 +255,18 @@ static irqreturn_t xen_arm_callback(int irq, void *arg)
>  #define GRANT_TABLE_PHYSADDR 0
>  void __init xen_early_init(void)
>  {
> -	int len;
> -	const char *s = NULL;
> -	const char *version = NULL;
> -	const char *xen_prefix = "xen,xen-";
> -
> -	xen_node = of_find_compatible_node(NULL, NULL, "xen,xen");
> -	if (!xen_node) {
> +	of_scan_flat_dt(fdt_find_hyper_node, NULL);
> +	if (!hyper_node.found) {
>  		pr_debug("No Xen support\n");
>  		return;
>  	}
> -	s = of_get_property(xen_node, "compatible", &len);
> -	if (strlen(xen_prefix) + 3  < len &&
> -			!strncmp(xen_prefix, s, strlen(xen_prefix)))
> -		version = s + strlen(xen_prefix);
> -	if (version == NULL) {
> +
> +	if (hyper_node.version == NULL) {
>  		pr_debug("Xen version not found\n");
>  		return;
>  	}
>  
> -	pr_info("Xen %s support found\n", version);
> +	pr_info("Xen %s support found\n", hyper_node.version);
>  
>  	xen_domain_type = XEN_HVM_DOMAIN;
>  
> @@ -289,6 +307,14 @@ static void __init xen_acpi_guest_init_events_irq(void)
>  
>  static void __init xen_dt_guest_init_events_irq(void)
>  {
> +	struct device_node *xen_node;
> +
> +	xen_node = of_find_compatible_node(NULL, NULL, "xen,xen");
> +	if (!xen_node) {
> +		pr_err("Xen support was detected before, but it has disappeared\n");
> +		return;
> +	}
> +
>  	xen_events_irq = irq_of_parse_and_map(xen_node, 0);
>  }
>  
> diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
> index 8119479..a4a2878 100644
> --- a/arch/arm64/kernel/setup.c
> +++ b/arch/arm64/kernel/setup.c
> @@ -313,6 +313,7 @@ void __init setup_arch(char **cmdline_p)
>  	 */
>  	local_async_enable();
>  
> +	xen_early_init();
>  	efi_init();
>  	arm64_memblock_init();
>  
> @@ -334,7 +335,6 @@ void __init setup_arch(char **cmdline_p)
>  	} else {
>  		psci_acpi_init();
>  	}
> -	xen_early_init();
>  
>  	cpu_read_bootcpu_ops();
>  	smp_init_cpus();
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v3 11/17] ARM: XEN: Move xen_early_init() before efi_init()
  2016-01-23  3:19   ` Shannon Zhao
                     ` (2 preceding siblings ...)
  (?)
@ 2016-01-25 15:25   ` Stefano Stabellini
  -1 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 15:25 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: mark.rutland, devicetree, linux-efi, ian.campbell,
	ard.biesheuvel, catalin.marinas, will.deacon, linux-kernel,
	xen-devel, julien.grall, stefano.stabellini, david.vrabel,
	peter.huangpeng, linux-arm-kernel, shannon.zhao

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Move xen_early_init() before efi_init(), then when calling efi_init()
> could initialize Xen specific UEFI.
> 
> Check if it runs on Xen hypervisor through the flat dts.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

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


>  arch/arm/xen/enlighten.c  | 56 ++++++++++++++++++++++++++++++++++-------------
>  arch/arm64/kernel/setup.c |  2 +-
>  2 files changed, 42 insertions(+), 16 deletions(-)
> 
> diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
> index 0e010bb..cdc0bd2 100644
> --- a/arch/arm/xen/enlighten.c
> +++ b/arch/arm/xen/enlighten.c
> @@ -19,6 +19,7 @@
>  #include <linux/irqreturn.h>
>  #include <linux/module.h>
>  #include <linux/of.h>
> +#include <linux/of_fdt.h>
>  #include <linux/of_irq.h>
>  #include <linux/of_address.h>
>  #include <linux/cpuidle.h>
> @@ -52,8 +53,6 @@ struct xen_memory_region xen_extra_mem[XEN_EXTRA_MEM_MAX_REGIONS] __initdata;
>  
>  static __read_mostly unsigned int xen_events_irq;
>  
> -static __initdata struct device_node *xen_node;
> -
>  int xen_remap_domain_gfn_array(struct vm_area_struct *vma,
>  			       unsigned long addr,
>  			       xen_pfn_t *gfn, int nr,
> @@ -222,6 +221,33 @@ static irqreturn_t xen_arm_callback(int irq, void *arg)
>  	return IRQ_HANDLED;
>  }
>  
> +static __initdata struct {
> +	const char *compat;
> +	const char *prefix;
> +	const char *version;
> +	bool found;
> +} hyper_node = {"xen,xen", "xen,xen-", NULL, false};
> +
> +static int __init fdt_find_hyper_node(unsigned long node, const char *uname,
> +				      int depth, void *data)
> +{
> +	const void *s = NULL;
> +	int len;
> +
> +	if (depth != 1 || strcmp(uname, "hypervisor") != 0)
> +		return 0;
> +
> +	if (of_flat_dt_is_compatible(node, hyper_node.compat))
> +		hyper_node.found = true;
> +
> +	s = of_get_flat_dt_prop(node, "compatible", &len);
> +	if (strlen(hyper_node.prefix) + 3  < len &&
> +	    !strncmp(hyper_node.prefix, s, strlen(hyper_node.prefix)))
> +		hyper_node.version = s + strlen(hyper_node.prefix);
> +
> +	return 0;
> +}
> +
>  /*
>   * see Documentation/devicetree/bindings/arm/xen.txt for the
>   * documentation of the Xen Device Tree format.
> @@ -229,26 +255,18 @@ static irqreturn_t xen_arm_callback(int irq, void *arg)
>  #define GRANT_TABLE_PHYSADDR 0
>  void __init xen_early_init(void)
>  {
> -	int len;
> -	const char *s = NULL;
> -	const char *version = NULL;
> -	const char *xen_prefix = "xen,xen-";
> -
> -	xen_node = of_find_compatible_node(NULL, NULL, "xen,xen");
> -	if (!xen_node) {
> +	of_scan_flat_dt(fdt_find_hyper_node, NULL);
> +	if (!hyper_node.found) {
>  		pr_debug("No Xen support\n");
>  		return;
>  	}
> -	s = of_get_property(xen_node, "compatible", &len);
> -	if (strlen(xen_prefix) + 3  < len &&
> -			!strncmp(xen_prefix, s, strlen(xen_prefix)))
> -		version = s + strlen(xen_prefix);
> -	if (version == NULL) {
> +
> +	if (hyper_node.version == NULL) {
>  		pr_debug("Xen version not found\n");
>  		return;
>  	}
>  
> -	pr_info("Xen %s support found\n", version);
> +	pr_info("Xen %s support found\n", hyper_node.version);
>  
>  	xen_domain_type = XEN_HVM_DOMAIN;
>  
> @@ -289,6 +307,14 @@ static void __init xen_acpi_guest_init_events_irq(void)
>  
>  static void __init xen_dt_guest_init_events_irq(void)
>  {
> +	struct device_node *xen_node;
> +
> +	xen_node = of_find_compatible_node(NULL, NULL, "xen,xen");
> +	if (!xen_node) {
> +		pr_err("Xen support was detected before, but it has disappeared\n");
> +		return;
> +	}
> +
>  	xen_events_irq = irq_of_parse_and_map(xen_node, 0);
>  }
>  
> diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
> index 8119479..a4a2878 100644
> --- a/arch/arm64/kernel/setup.c
> +++ b/arch/arm64/kernel/setup.c
> @@ -313,6 +313,7 @@ void __init setup_arch(char **cmdline_p)
>  	 */
>  	local_async_enable();
>  
> +	xen_early_init();
>  	efi_init();
>  	arm64_memblock_init();
>  
> @@ -334,7 +335,6 @@ void __init setup_arch(char **cmdline_p)
>  	} else {
>  		psci_acpi_init();
>  	}
> -	xen_early_init();
>  
>  	cpu_read_bootcpu_ops();
>  	smp_init_cpus();
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v3 12/17] ARM64: ACPI: Check if it runs on Xen to enable or disable ACPI
@ 2016-01-25 15:32     ` Stefano Stabellini
  0 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 15:32 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel, catalin.marinas, will.deacon,
	julien.grall, xen-devel, devicetree, linux-efi, linux-kernel,
	ian.campbell, shannon.zhao, peter.huangpeng, Hanjun Guo

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> When it's a Xen domain0 booting with ACPI, it will supply a /chosen and
> a /hypervisor node in DT. So check if it needs to enable ACPI.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

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


> CC: Hanjun Guo <hanjun.guo@linaro.org>
> ---
>  arch/arm64/kernel/acpi.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
> index d1ce8e2..4e92be0 100644
> --- a/arch/arm64/kernel/acpi.c
> +++ b/arch/arm64/kernel/acpi.c
> @@ -67,10 +67,13 @@ static int __init dt_scan_depth1_nodes(unsigned long node,
>  {
>  	/*
>  	 * Return 1 as soon as we encounter a node at depth 1 that is
> -	 * not the /chosen node.
> +	 * not the /chosen node, or /hypervisor node when running on Xen.
>  	 */
> -	if (depth == 1 && (strcmp(uname, "chosen") != 0))
> -		return 1;
> +	if (depth == 1 && (strcmp(uname, "chosen") != 0)) {
> +		if (!xen_initial_domain() || (strcmp(uname, "hypervisor") != 0))
> +			return 1;
> +	}
> +
>  	return 0;
>  }
>  
> @@ -184,7 +187,8 @@ void __init acpi_boot_table_init(void)
>  	/*
>  	 * Enable ACPI instead of device tree unless
>  	 * - ACPI has been disabled explicitly (acpi=off), or
> -	 * - the device tree is not empty (it has more than just a /chosen node)
> +	 * - the device tree is not empty (it has more than just a /chosen node,
> +	 *   and a /hypervisor node when running on Xen)
>  	 *   and ACPI has not been force enabled (acpi=force)
>  	 */
>  	if (param_acpi_off ||
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v3 12/17] ARM64: ACPI: Check if it runs on Xen to enable or disable ACPI
@ 2016-01-25 15:32     ` Stefano Stabellini
  0 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 15:32 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	stefano.stabellini-Sxgqhf6Nn4DQT0dZR+AlfA,
	david.vrabel-Sxgqhf6Nn4DQT0dZR+AlfA, catalin.marinas-5wv7dgnIgG8,
	will.deacon-5wv7dgnIgG8, julien.grall-Sxgqhf6Nn4DQT0dZR+AlfA,
	xen-devel-GuqFBffKawuEi8DpZVb4nw,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-efi-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	ian.campbell-Sxgqhf6Nn4DQT0dZR+AlfA,
	shannon.zhao-QSEj5FYQhm4dnm+yROfE0A,
	peter.huangpeng-hv44wF8Li93QT0dZR+AlfA, Hanjun Guo

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> 
> When it's a Xen domain0 booting with ACPI, it will supply a /chosen and
> a /hypervisor node in DT. So check if it needs to enable ACPI.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>

Reviewed-by: Stefano Stabellini <stefano.stabellini-mvvWK6WmYclDPfheJLI6IQ@public.gmane.org>


> CC: Hanjun Guo <hanjun.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> ---
>  arch/arm64/kernel/acpi.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
> index d1ce8e2..4e92be0 100644
> --- a/arch/arm64/kernel/acpi.c
> +++ b/arch/arm64/kernel/acpi.c
> @@ -67,10 +67,13 @@ static int __init dt_scan_depth1_nodes(unsigned long node,
>  {
>  	/*
>  	 * Return 1 as soon as we encounter a node at depth 1 that is
> -	 * not the /chosen node.
> +	 * not the /chosen node, or /hypervisor node when running on Xen.
>  	 */
> -	if (depth == 1 && (strcmp(uname, "chosen") != 0))
> -		return 1;
> +	if (depth == 1 && (strcmp(uname, "chosen") != 0)) {
> +		if (!xen_initial_domain() || (strcmp(uname, "hypervisor") != 0))
> +			return 1;
> +	}
> +
>  	return 0;
>  }
>  
> @@ -184,7 +187,8 @@ void __init acpi_boot_table_init(void)
>  	/*
>  	 * Enable ACPI instead of device tree unless
>  	 * - ACPI has been disabled explicitly (acpi=off), or
> -	 * - the device tree is not empty (it has more than just a /chosen node)
> +	 * - the device tree is not empty (it has more than just a /chosen node,
> +	 *   and a /hypervisor node when running on Xen)
>  	 *   and ACPI has not been force enabled (acpi=force)
>  	 */
>  	if (param_acpi_off ||
> -- 
> 2.0.4
> 
> 
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v3 12/17] ARM64: ACPI: Check if it runs on Xen to enable or disable ACPI
@ 2016-01-25 15:32     ` Stefano Stabellini
  0 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 15:32 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> When it's a Xen domain0 booting with ACPI, it will supply a /chosen and
> a /hypervisor node in DT. So check if it needs to enable ACPI.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

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


> CC: Hanjun Guo <hanjun.guo@linaro.org>
> ---
>  arch/arm64/kernel/acpi.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
> index d1ce8e2..4e92be0 100644
> --- a/arch/arm64/kernel/acpi.c
> +++ b/arch/arm64/kernel/acpi.c
> @@ -67,10 +67,13 @@ static int __init dt_scan_depth1_nodes(unsigned long node,
>  {
>  	/*
>  	 * Return 1 as soon as we encounter a node at depth 1 that is
> -	 * not the /chosen node.
> +	 * not the /chosen node, or /hypervisor node when running on Xen.
>  	 */
> -	if (depth == 1 && (strcmp(uname, "chosen") != 0))
> -		return 1;
> +	if (depth == 1 && (strcmp(uname, "chosen") != 0)) {
> +		if (!xen_initial_domain() || (strcmp(uname, "hypervisor") != 0))
> +			return 1;
> +	}
> +
>  	return 0;
>  }
>  
> @@ -184,7 +187,8 @@ void __init acpi_boot_table_init(void)
>  	/*
>  	 * Enable ACPI instead of device tree unless
>  	 * - ACPI has been disabled explicitly (acpi=off), or
> -	 * - the device tree is not empty (it has more than just a /chosen node)
> +	 * - the device tree is not empty (it has more than just a /chosen node,
> +	 *   and a /hypervisor node when running on Xen)
>  	 *   and ACPI has not been force enabled (acpi=force)
>  	 */
>  	if (param_acpi_off ||
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v3 12/17] ARM64: ACPI: Check if it runs on Xen to enable or disable ACPI
  2016-01-23  3:19   ` Shannon Zhao
                     ` (2 preceding siblings ...)
  (?)
@ 2016-01-25 15:32   ` Stefano Stabellini
  -1 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 15:32 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: mark.rutland, devicetree, linux-efi, ian.campbell,
	ard.biesheuvel, catalin.marinas, will.deacon, linux-kernel,
	xen-devel, julien.grall, stefano.stabellini, david.vrabel,
	peter.huangpeng, Hanjun Guo, linux-arm-kernel, shannon.zhao

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> When it's a Xen domain0 booting with ACPI, it will supply a /chosen and
> a /hypervisor node in DT. So check if it needs to enable ACPI.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

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


> CC: Hanjun Guo <hanjun.guo@linaro.org>
> ---
>  arch/arm64/kernel/acpi.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
> index d1ce8e2..4e92be0 100644
> --- a/arch/arm64/kernel/acpi.c
> +++ b/arch/arm64/kernel/acpi.c
> @@ -67,10 +67,13 @@ static int __init dt_scan_depth1_nodes(unsigned long node,
>  {
>  	/*
>  	 * Return 1 as soon as we encounter a node at depth 1 that is
> -	 * not the /chosen node.
> +	 * not the /chosen node, or /hypervisor node when running on Xen.
>  	 */
> -	if (depth == 1 && (strcmp(uname, "chosen") != 0))
> -		return 1;
> +	if (depth == 1 && (strcmp(uname, "chosen") != 0)) {
> +		if (!xen_initial_domain() || (strcmp(uname, "hypervisor") != 0))
> +			return 1;
> +	}
> +
>  	return 0;
>  }
>  
> @@ -184,7 +187,8 @@ void __init acpi_boot_table_init(void)
>  	/*
>  	 * Enable ACPI instead of device tree unless
>  	 * - ACPI has been disabled explicitly (acpi=off), or
> -	 * - the device tree is not empty (it has more than just a /chosen node)
> +	 * - the device tree is not empty (it has more than just a /chosen node,
> +	 *   and a /hypervisor node when running on Xen)
>  	 *   and ACPI has not been force enabled (acpi=force)
>  	 */
>  	if (param_acpi_off ||
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v3 13/17] ARM: Xen: Document UEFI support on Xen ARM virtual platforms
  2016-01-23  3:19   ` Shannon Zhao
  (?)
@ 2016-01-25 15:50     ` Stefano Stabellini
  -1 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 15:50 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel, catalin.marinas, will.deacon,
	julien.grall, xen-devel, devicetree, linux-efi, linux-kernel,
	ian.campbell, shannon.zhao, peter.huangpeng, Rob Herring

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Add a "uefi" node under /hypervisor node in FDT, then Linux kernel could
> scan this to get the UEFI information.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> Acked-by: Rob Herring <robh@kernel.org>
> ---
> CC: Rob Herring <robh@kernel.org>
> ---
>  Documentation/devicetree/bindings/arm/xen.txt | 34 +++++++++++++++++++++++++++
>  1 file changed, 34 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/arm/xen.txt b/Documentation/devicetree/bindings/arm/xen.txt
> index 0f7b9c2..aa69405 100644
> --- a/Documentation/devicetree/bindings/arm/xen.txt
> +++ b/Documentation/devicetree/bindings/arm/xen.txt
> @@ -15,6 +15,26 @@ the following properties:
>  - interrupts: the interrupt used by Xen to inject event notifications.
>    A GIC node is also required.
>  
> +To support UEFI on Xen ARM virtual platforms, Xen populates the FDT "uefi" node
> +under /hypervisor with following parameters:
> +
> +________________________________________________________________________________
> +Name                      | Size   | Description
> +================================================================================
> +xen,uefi-system-table     | 64-bit | Guest physical address of the UEFI System
> +			  |	   | Table.
> +--------------------------------------------------------------------------------
> +xen,uefi-mmap-start       | 64-bit | Guest physical address of the UEFI memory
> +			  |	   | map.
> +--------------------------------------------------------------------------------
> +xen,uefi-mmap-size        | 32-bit | Size in bytes of the UEFI memory map
> +                          |        | pointed to in previous entry.
> +--------------------------------------------------------------------------------
> +xen,uefi-mmap-desc-size   | 32-bit | Size in bytes of each entry in the UEFI
> +                          |        | memory map.
> +--------------------------------------------------------------------------------
> +xen,uefi-mmap-desc-ver    | 32-bit | Version of the mmap descriptor format.
> +--------------------------------------------------------------------------------
>  
>  Example (assuming #address-cells = <2> and #size-cells = <2>):
>  
> @@ -22,4 +42,18 @@ hypervisor {
>  	compatible = "xen,xen-4.3", "xen,xen";
>  	reg = <0 0xb0000000 0 0x20000>;
>  	interrupts = <1 15 0xf08>;
> +	uefi {
> +		xen,uefi-system-table = <0xXXXXXXXX>;
> +		xen,uefi-mmap-start = <0xXXXXXXXX>;
> +		xen,uefi-mmap-size = <0xXXXXXXXX>;
> +		xen,uefi-mmap-desc-size = <0xXXXXXXXX>;
> +		xen,uefi-mmap-desc-ver = <0xXXXXXXXX>;
> +        };
>  };
> +
> +The format and meaning of these "xen,uefi-*" parameters are similar to those in
> +Documentation/arm/uefi.txt which are used by normal UEFI. But to distinguish
> +from normal UEFI, for Xen ARM virtual platforms it needs to introduce a Xen
> +specific UEFI which requires Xen hypervisor to provide hypercalls for Dom0 to
> +make use of the runtime services. Therefore, it defines these parameters under
> +/hypervisor node.

Please replace the paragraph with the following which mentions
include/xen/interface/platform.h and improves the wording:

"The format and meaning of the "xen,uefi-*" parameters are similar to
those in Documentation/arm/uefi.txt, which are provided by the regular
UEFI stub. However they differ because they are provided by the Xen
hypervisor, together with a set of UEFI runtime services implemented via
hypercalls, see include/xen/interface/platform.h."

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

* Re: [PATCH v3 13/17] ARM: Xen: Document UEFI support on Xen ARM virtual platforms
@ 2016-01-25 15:50     ` Stefano Stabellini
  0 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 15:50 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel, catalin.marinas, will.deacon,
	julien.grall, xen-devel, devicetree, linux-efi, linux-kernel,
	ian.campbell, shannon.zhao, peter.huangpeng, Rob Herring

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Add a "uefi" node under /hypervisor node in FDT, then Linux kernel could
> scan this to get the UEFI information.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> Acked-by: Rob Herring <robh@kernel.org>
> ---
> CC: Rob Herring <robh@kernel.org>
> ---
>  Documentation/devicetree/bindings/arm/xen.txt | 34 +++++++++++++++++++++++++++
>  1 file changed, 34 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/arm/xen.txt b/Documentation/devicetree/bindings/arm/xen.txt
> index 0f7b9c2..aa69405 100644
> --- a/Documentation/devicetree/bindings/arm/xen.txt
> +++ b/Documentation/devicetree/bindings/arm/xen.txt
> @@ -15,6 +15,26 @@ the following properties:
>  - interrupts: the interrupt used by Xen to inject event notifications.
>    A GIC node is also required.
>  
> +To support UEFI on Xen ARM virtual platforms, Xen populates the FDT "uefi" node
> +under /hypervisor with following parameters:
> +
> +________________________________________________________________________________
> +Name                      | Size   | Description
> +================================================================================
> +xen,uefi-system-table     | 64-bit | Guest physical address of the UEFI System
> +			  |	   | Table.
> +--------------------------------------------------------------------------------
> +xen,uefi-mmap-start       | 64-bit | Guest physical address of the UEFI memory
> +			  |	   | map.
> +--------------------------------------------------------------------------------
> +xen,uefi-mmap-size        | 32-bit | Size in bytes of the UEFI memory map
> +                          |        | pointed to in previous entry.
> +--------------------------------------------------------------------------------
> +xen,uefi-mmap-desc-size   | 32-bit | Size in bytes of each entry in the UEFI
> +                          |        | memory map.
> +--------------------------------------------------------------------------------
> +xen,uefi-mmap-desc-ver    | 32-bit | Version of the mmap descriptor format.
> +--------------------------------------------------------------------------------
>  
>  Example (assuming #address-cells = <2> and #size-cells = <2>):
>  
> @@ -22,4 +42,18 @@ hypervisor {
>  	compatible = "xen,xen-4.3", "xen,xen";
>  	reg = <0 0xb0000000 0 0x20000>;
>  	interrupts = <1 15 0xf08>;
> +	uefi {
> +		xen,uefi-system-table = <0xXXXXXXXX>;
> +		xen,uefi-mmap-start = <0xXXXXXXXX>;
> +		xen,uefi-mmap-size = <0xXXXXXXXX>;
> +		xen,uefi-mmap-desc-size = <0xXXXXXXXX>;
> +		xen,uefi-mmap-desc-ver = <0xXXXXXXXX>;
> +        };
>  };
> +
> +The format and meaning of these "xen,uefi-*" parameters are similar to those in
> +Documentation/arm/uefi.txt which are used by normal UEFI. But to distinguish
> +from normal UEFI, for Xen ARM virtual platforms it needs to introduce a Xen
> +specific UEFI which requires Xen hypervisor to provide hypercalls for Dom0 to
> +make use of the runtime services. Therefore, it defines these parameters under
> +/hypervisor node.

Please replace the paragraph with the following which mentions
include/xen/interface/platform.h and improves the wording:

"The format and meaning of the "xen,uefi-*" parameters are similar to
those in Documentation/arm/uefi.txt, which are provided by the regular
UEFI stub. However they differ because they are provided by the Xen
hypervisor, together with a set of UEFI runtime services implemented via
hypercalls, see include/xen/interface/platform.h."

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

* [PATCH v3 13/17] ARM: Xen: Document UEFI support on Xen ARM virtual platforms
@ 2016-01-25 15:50     ` Stefano Stabellini
  0 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 15:50 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Add a "uefi" node under /hypervisor node in FDT, then Linux kernel could
> scan this to get the UEFI information.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> Acked-by: Rob Herring <robh@kernel.org>
> ---
> CC: Rob Herring <robh@kernel.org>
> ---
>  Documentation/devicetree/bindings/arm/xen.txt | 34 +++++++++++++++++++++++++++
>  1 file changed, 34 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/arm/xen.txt b/Documentation/devicetree/bindings/arm/xen.txt
> index 0f7b9c2..aa69405 100644
> --- a/Documentation/devicetree/bindings/arm/xen.txt
> +++ b/Documentation/devicetree/bindings/arm/xen.txt
> @@ -15,6 +15,26 @@ the following properties:
>  - interrupts: the interrupt used by Xen to inject event notifications.
>    A GIC node is also required.
>  
> +To support UEFI on Xen ARM virtual platforms, Xen populates the FDT "uefi" node
> +under /hypervisor with following parameters:
> +
> +________________________________________________________________________________
> +Name                      | Size   | Description
> +================================================================================
> +xen,uefi-system-table     | 64-bit | Guest physical address of the UEFI System
> +			  |	   | Table.
> +--------------------------------------------------------------------------------
> +xen,uefi-mmap-start       | 64-bit | Guest physical address of the UEFI memory
> +			  |	   | map.
> +--------------------------------------------------------------------------------
> +xen,uefi-mmap-size        | 32-bit | Size in bytes of the UEFI memory map
> +                          |        | pointed to in previous entry.
> +--------------------------------------------------------------------------------
> +xen,uefi-mmap-desc-size   | 32-bit | Size in bytes of each entry in the UEFI
> +                          |        | memory map.
> +--------------------------------------------------------------------------------
> +xen,uefi-mmap-desc-ver    | 32-bit | Version of the mmap descriptor format.
> +--------------------------------------------------------------------------------
>  
>  Example (assuming #address-cells = <2> and #size-cells = <2>):
>  
> @@ -22,4 +42,18 @@ hypervisor {
>  	compatible = "xen,xen-4.3", "xen,xen";
>  	reg = <0 0xb0000000 0 0x20000>;
>  	interrupts = <1 15 0xf08>;
> +	uefi {
> +		xen,uefi-system-table = <0xXXXXXXXX>;
> +		xen,uefi-mmap-start = <0xXXXXXXXX>;
> +		xen,uefi-mmap-size = <0xXXXXXXXX>;
> +		xen,uefi-mmap-desc-size = <0xXXXXXXXX>;
> +		xen,uefi-mmap-desc-ver = <0xXXXXXXXX>;
> +        };
>  };
> +
> +The format and meaning of these "xen,uefi-*" parameters are similar to those in
> +Documentation/arm/uefi.txt which are used by normal UEFI. But to distinguish
> +from normal UEFI, for Xen ARM virtual platforms it needs to introduce a Xen
> +specific UEFI which requires Xen hypervisor to provide hypercalls for Dom0 to
> +make use of the runtime services. Therefore, it defines these parameters under
> +/hypervisor node.

Please replace the paragraph with the following which mentions
include/xen/interface/platform.h and improves the wording:

"The format and meaning of the "xen,uefi-*" parameters are similar to
those in Documentation/arm/uefi.txt, which are provided by the regular
UEFI stub. However they differ because they are provided by the Xen
hypervisor, together with a set of UEFI runtime services implemented via
hypercalls, see include/xen/interface/platform.h."

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

* Re: [PATCH v3 13/17] ARM: Xen: Document UEFI support on Xen ARM virtual platforms
  2016-01-23  3:19   ` Shannon Zhao
                     ` (2 preceding siblings ...)
  (?)
@ 2016-01-25 15:50   ` Stefano Stabellini
  -1 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 15:50 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: mark.rutland, devicetree, linux-efi, ian.campbell,
	ard.biesheuvel, catalin.marinas, will.deacon, linux-kernel,
	xen-devel, julien.grall, stefano.stabellini, david.vrabel,
	peter.huangpeng, Rob Herring, linux-arm-kernel, shannon.zhao

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Add a "uefi" node under /hypervisor node in FDT, then Linux kernel could
> scan this to get the UEFI information.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> Acked-by: Rob Herring <robh@kernel.org>
> ---
> CC: Rob Herring <robh@kernel.org>
> ---
>  Documentation/devicetree/bindings/arm/xen.txt | 34 +++++++++++++++++++++++++++
>  1 file changed, 34 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/arm/xen.txt b/Documentation/devicetree/bindings/arm/xen.txt
> index 0f7b9c2..aa69405 100644
> --- a/Documentation/devicetree/bindings/arm/xen.txt
> +++ b/Documentation/devicetree/bindings/arm/xen.txt
> @@ -15,6 +15,26 @@ the following properties:
>  - interrupts: the interrupt used by Xen to inject event notifications.
>    A GIC node is also required.
>  
> +To support UEFI on Xen ARM virtual platforms, Xen populates the FDT "uefi" node
> +under /hypervisor with following parameters:
> +
> +________________________________________________________________________________
> +Name                      | Size   | Description
> +================================================================================
> +xen,uefi-system-table     | 64-bit | Guest physical address of the UEFI System
> +			  |	   | Table.
> +--------------------------------------------------------------------------------
> +xen,uefi-mmap-start       | 64-bit | Guest physical address of the UEFI memory
> +			  |	   | map.
> +--------------------------------------------------------------------------------
> +xen,uefi-mmap-size        | 32-bit | Size in bytes of the UEFI memory map
> +                          |        | pointed to in previous entry.
> +--------------------------------------------------------------------------------
> +xen,uefi-mmap-desc-size   | 32-bit | Size in bytes of each entry in the UEFI
> +                          |        | memory map.
> +--------------------------------------------------------------------------------
> +xen,uefi-mmap-desc-ver    | 32-bit | Version of the mmap descriptor format.
> +--------------------------------------------------------------------------------
>  
>  Example (assuming #address-cells = <2> and #size-cells = <2>):
>  
> @@ -22,4 +42,18 @@ hypervisor {
>  	compatible = "xen,xen-4.3", "xen,xen";
>  	reg = <0 0xb0000000 0 0x20000>;
>  	interrupts = <1 15 0xf08>;
> +	uefi {
> +		xen,uefi-system-table = <0xXXXXXXXX>;
> +		xen,uefi-mmap-start = <0xXXXXXXXX>;
> +		xen,uefi-mmap-size = <0xXXXXXXXX>;
> +		xen,uefi-mmap-desc-size = <0xXXXXXXXX>;
> +		xen,uefi-mmap-desc-ver = <0xXXXXXXXX>;
> +        };
>  };
> +
> +The format and meaning of these "xen,uefi-*" parameters are similar to those in
> +Documentation/arm/uefi.txt which are used by normal UEFI. But to distinguish
> +from normal UEFI, for Xen ARM virtual platforms it needs to introduce a Xen
> +specific UEFI which requires Xen hypervisor to provide hypercalls for Dom0 to
> +make use of the runtime services. Therefore, it defines these parameters under
> +/hypervisor node.

Please replace the paragraph with the following which mentions
include/xen/interface/platform.h and improves the wording:

"The format and meaning of the "xen,uefi-*" parameters are similar to
those in Documentation/arm/uefi.txt, which are provided by the regular
UEFI stub. However they differ because they are provided by the Xen
hypervisor, together with a set of UEFI runtime services implemented via
hypercalls, see include/xen/interface/platform.h."

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

* Re: [PATCH v3 13/17] ARM: Xen: Document UEFI support on Xen ARM virtual platforms
  2016-01-25 15:50     ` Stefano Stabellini
  (?)
@ 2016-01-25 15:59       ` Mark Rutland
  -1 siblings, 0 replies; 145+ messages in thread
From: Mark Rutland @ 2016-01-25 15:59 UTC (permalink / raw)
  To: Stefano Stabellini
  Cc: Shannon Zhao, linux-arm-kernel, ard.biesheuvel,
	stefano.stabellini, david.vrabel, catalin.marinas, will.deacon,
	julien.grall, xen-devel, devicetree, linux-efi, linux-kernel,
	ian.campbell, shannon.zhao, peter.huangpeng, Rob Herring

On Mon, Jan 25, 2016 at 03:50:52PM +0000, Stefano Stabellini wrote:
> On Sat, 23 Jan 2016, Shannon Zhao wrote:
> > From: Shannon Zhao <shannon.zhao@linaro.org>
> > 
> > Add a "uefi" node under /hypervisor node in FDT, then Linux kernel could
> > scan this to get the UEFI information.
> > 
> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> > Acked-by: Rob Herring <robh@kernel.org>
> > ---
> > CC: Rob Herring <robh@kernel.org>
> > ---
> >  Documentation/devicetree/bindings/arm/xen.txt | 34 +++++++++++++++++++++++++++
> >  1 file changed, 34 insertions(+)
> > 
> > diff --git a/Documentation/devicetree/bindings/arm/xen.txt b/Documentation/devicetree/bindings/arm/xen.txt
> > index 0f7b9c2..aa69405 100644
> > --- a/Documentation/devicetree/bindings/arm/xen.txt
> > +++ b/Documentation/devicetree/bindings/arm/xen.txt
> > @@ -15,6 +15,26 @@ the following properties:
> >  - interrupts: the interrupt used by Xen to inject event notifications.
> >    A GIC node is also required.
> >  
> > +To support UEFI on Xen ARM virtual platforms, Xen populates the FDT "uefi" node
> > +under /hypervisor with following parameters:
> > +
> > +________________________________________________________________________________
> > +Name                      | Size   | Description
> > +================================================================================
> > +xen,uefi-system-table     | 64-bit | Guest physical address of the UEFI System
> > +			  |	   | Table.
> > +--------------------------------------------------------------------------------
> > +xen,uefi-mmap-start       | 64-bit | Guest physical address of the UEFI memory
> > +			  |	   | map.
> > +--------------------------------------------------------------------------------
> > +xen,uefi-mmap-size        | 32-bit | Size in bytes of the UEFI memory map
> > +                          |        | pointed to in previous entry.
> > +--------------------------------------------------------------------------------
> > +xen,uefi-mmap-desc-size   | 32-bit | Size in bytes of each entry in the UEFI
> > +                          |        | memory map.
> > +--------------------------------------------------------------------------------
> > +xen,uefi-mmap-desc-ver    | 32-bit | Version of the mmap descriptor format.
> > +--------------------------------------------------------------------------------
> >  
> >  Example (assuming #address-cells = <2> and #size-cells = <2>):
> >  
> > @@ -22,4 +42,18 @@ hypervisor {
> >  	compatible = "xen,xen-4.3", "xen,xen";
> >  	reg = <0 0xb0000000 0 0x20000>;
> >  	interrupts = <1 15 0xf08>;
> > +	uefi {
> > +		xen,uefi-system-table = <0xXXXXXXXX>;
> > +		xen,uefi-mmap-start = <0xXXXXXXXX>;
> > +		xen,uefi-mmap-size = <0xXXXXXXXX>;
> > +		xen,uefi-mmap-desc-size = <0xXXXXXXXX>;
> > +		xen,uefi-mmap-desc-ver = <0xXXXXXXXX>;
> > +        };
> >  };
> > +
> > +The format and meaning of these "xen,uefi-*" parameters are similar to those in
> > +Documentation/arm/uefi.txt which are used by normal UEFI. But to distinguish
> > +from normal UEFI, for Xen ARM virtual platforms it needs to introduce a Xen
> > +specific UEFI which requires Xen hypervisor to provide hypercalls for Dom0 to
> > +make use of the runtime services. Therefore, it defines these parameters under
> > +/hypervisor node.
> 
> Please replace the paragraph with the following which mentions
> include/xen/interface/platform.h and improves the wording:
> 
> "The format and meaning of the "xen,uefi-*" parameters are similar to
> those in Documentation/arm/uefi.txt, which are provided by the regular
> UEFI stub. However they differ because they are provided by the Xen
> hypervisor, together with a set of UEFI runtime services implemented via
> hypercalls, see include/xen/interface/platform.h."

I would prefer if we didn't refer to Linux paths here, for the usual
rationale of keeping bindings distinct from Linux implementation
details.

Could we either drop the "see include/xen/interface/platform.h" part, or
refer to some Xen documentation?

Thanks,
Mark.

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

* Re: [PATCH v3 13/17] ARM: Xen: Document UEFI support on Xen ARM virtual platforms
@ 2016-01-25 15:59       ` Mark Rutland
  0 siblings, 0 replies; 145+ messages in thread
From: Mark Rutland @ 2016-01-25 15:59 UTC (permalink / raw)
  To: Stefano Stabellini
  Cc: devicetree, linux-efi, ian.campbell, ard.biesheuvel,
	catalin.marinas, will.deacon, linux-kernel, xen-devel,
	julien.grall, stefano.stabellini, david.vrabel, Shannon Zhao,
	peter.huangpeng, Rob Herring, linux-arm-kernel, shannon.zhao

On Mon, Jan 25, 2016 at 03:50:52PM +0000, Stefano Stabellini wrote:
> On Sat, 23 Jan 2016, Shannon Zhao wrote:
> > From: Shannon Zhao <shannon.zhao@linaro.org>
> > 
> > Add a "uefi" node under /hypervisor node in FDT, then Linux kernel could
> > scan this to get the UEFI information.
> > 
> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> > Acked-by: Rob Herring <robh@kernel.org>
> > ---
> > CC: Rob Herring <robh@kernel.org>
> > ---
> >  Documentation/devicetree/bindings/arm/xen.txt | 34 +++++++++++++++++++++++++++
> >  1 file changed, 34 insertions(+)
> > 
> > diff --git a/Documentation/devicetree/bindings/arm/xen.txt b/Documentation/devicetree/bindings/arm/xen.txt
> > index 0f7b9c2..aa69405 100644
> > --- a/Documentation/devicetree/bindings/arm/xen.txt
> > +++ b/Documentation/devicetree/bindings/arm/xen.txt
> > @@ -15,6 +15,26 @@ the following properties:
> >  - interrupts: the interrupt used by Xen to inject event notifications.
> >    A GIC node is also required.
> >  
> > +To support UEFI on Xen ARM virtual platforms, Xen populates the FDT "uefi" node
> > +under /hypervisor with following parameters:
> > +
> > +________________________________________________________________________________
> > +Name                      | Size   | Description
> > +================================================================================
> > +xen,uefi-system-table     | 64-bit | Guest physical address of the UEFI System
> > +			  |	   | Table.
> > +--------------------------------------------------------------------------------
> > +xen,uefi-mmap-start       | 64-bit | Guest physical address of the UEFI memory
> > +			  |	   | map.
> > +--------------------------------------------------------------------------------
> > +xen,uefi-mmap-size        | 32-bit | Size in bytes of the UEFI memory map
> > +                          |        | pointed to in previous entry.
> > +--------------------------------------------------------------------------------
> > +xen,uefi-mmap-desc-size   | 32-bit | Size in bytes of each entry in the UEFI
> > +                          |        | memory map.
> > +--------------------------------------------------------------------------------
> > +xen,uefi-mmap-desc-ver    | 32-bit | Version of the mmap descriptor format.
> > +--------------------------------------------------------------------------------
> >  
> >  Example (assuming #address-cells = <2> and #size-cells = <2>):
> >  
> > @@ -22,4 +42,18 @@ hypervisor {
> >  	compatible = "xen,xen-4.3", "xen,xen";
> >  	reg = <0 0xb0000000 0 0x20000>;
> >  	interrupts = <1 15 0xf08>;
> > +	uefi {
> > +		xen,uefi-system-table = <0xXXXXXXXX>;
> > +		xen,uefi-mmap-start = <0xXXXXXXXX>;
> > +		xen,uefi-mmap-size = <0xXXXXXXXX>;
> > +		xen,uefi-mmap-desc-size = <0xXXXXXXXX>;
> > +		xen,uefi-mmap-desc-ver = <0xXXXXXXXX>;
> > +        };
> >  };
> > +
> > +The format and meaning of these "xen,uefi-*" parameters are similar to those in
> > +Documentation/arm/uefi.txt which are used by normal UEFI. But to distinguish
> > +from normal UEFI, for Xen ARM virtual platforms it needs to introduce a Xen
> > +specific UEFI which requires Xen hypervisor to provide hypercalls for Dom0 to
> > +make use of the runtime services. Therefore, it defines these parameters under
> > +/hypervisor node.
> 
> Please replace the paragraph with the following which mentions
> include/xen/interface/platform.h and improves the wording:
> 
> "The format and meaning of the "xen,uefi-*" parameters are similar to
> those in Documentation/arm/uefi.txt, which are provided by the regular
> UEFI stub. However they differ because they are provided by the Xen
> hypervisor, together with a set of UEFI runtime services implemented via
> hypercalls, see include/xen/interface/platform.h."

I would prefer if we didn't refer to Linux paths here, for the usual
rationale of keeping bindings distinct from Linux implementation
details.

Could we either drop the "see include/xen/interface/platform.h" part, or
refer to some Xen documentation?

Thanks,
Mark.

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

* [PATCH v3 13/17] ARM: Xen: Document UEFI support on Xen ARM virtual platforms
@ 2016-01-25 15:59       ` Mark Rutland
  0 siblings, 0 replies; 145+ messages in thread
From: Mark Rutland @ 2016-01-25 15:59 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Jan 25, 2016 at 03:50:52PM +0000, Stefano Stabellini wrote:
> On Sat, 23 Jan 2016, Shannon Zhao wrote:
> > From: Shannon Zhao <shannon.zhao@linaro.org>
> > 
> > Add a "uefi" node under /hypervisor node in FDT, then Linux kernel could
> > scan this to get the UEFI information.
> > 
> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> > Acked-by: Rob Herring <robh@kernel.org>
> > ---
> > CC: Rob Herring <robh@kernel.org>
> > ---
> >  Documentation/devicetree/bindings/arm/xen.txt | 34 +++++++++++++++++++++++++++
> >  1 file changed, 34 insertions(+)
> > 
> > diff --git a/Documentation/devicetree/bindings/arm/xen.txt b/Documentation/devicetree/bindings/arm/xen.txt
> > index 0f7b9c2..aa69405 100644
> > --- a/Documentation/devicetree/bindings/arm/xen.txt
> > +++ b/Documentation/devicetree/bindings/arm/xen.txt
> > @@ -15,6 +15,26 @@ the following properties:
> >  - interrupts: the interrupt used by Xen to inject event notifications.
> >    A GIC node is also required.
> >  
> > +To support UEFI on Xen ARM virtual platforms, Xen populates the FDT "uefi" node
> > +under /hypervisor with following parameters:
> > +
> > +________________________________________________________________________________
> > +Name                      | Size   | Description
> > +================================================================================
> > +xen,uefi-system-table     | 64-bit | Guest physical address of the UEFI System
> > +			  |	   | Table.
> > +--------------------------------------------------------------------------------
> > +xen,uefi-mmap-start       | 64-bit | Guest physical address of the UEFI memory
> > +			  |	   | map.
> > +--------------------------------------------------------------------------------
> > +xen,uefi-mmap-size        | 32-bit | Size in bytes of the UEFI memory map
> > +                          |        | pointed to in previous entry.
> > +--------------------------------------------------------------------------------
> > +xen,uefi-mmap-desc-size   | 32-bit | Size in bytes of each entry in the UEFI
> > +                          |        | memory map.
> > +--------------------------------------------------------------------------------
> > +xen,uefi-mmap-desc-ver    | 32-bit | Version of the mmap descriptor format.
> > +--------------------------------------------------------------------------------
> >  
> >  Example (assuming #address-cells = <2> and #size-cells = <2>):
> >  
> > @@ -22,4 +42,18 @@ hypervisor {
> >  	compatible = "xen,xen-4.3", "xen,xen";
> >  	reg = <0 0xb0000000 0 0x20000>;
> >  	interrupts = <1 15 0xf08>;
> > +	uefi {
> > +		xen,uefi-system-table = <0xXXXXXXXX>;
> > +		xen,uefi-mmap-start = <0xXXXXXXXX>;
> > +		xen,uefi-mmap-size = <0xXXXXXXXX>;
> > +		xen,uefi-mmap-desc-size = <0xXXXXXXXX>;
> > +		xen,uefi-mmap-desc-ver = <0xXXXXXXXX>;
> > +        };
> >  };
> > +
> > +The format and meaning of these "xen,uefi-*" parameters are similar to those in
> > +Documentation/arm/uefi.txt which are used by normal UEFI. But to distinguish
> > +from normal UEFI, for Xen ARM virtual platforms it needs to introduce a Xen
> > +specific UEFI which requires Xen hypervisor to provide hypercalls for Dom0 to
> > +make use of the runtime services. Therefore, it defines these parameters under
> > +/hypervisor node.
> 
> Please replace the paragraph with the following which mentions
> include/xen/interface/platform.h and improves the wording:
> 
> "The format and meaning of the "xen,uefi-*" parameters are similar to
> those in Documentation/arm/uefi.txt, which are provided by the regular
> UEFI stub. However they differ because they are provided by the Xen
> hypervisor, together with a set of UEFI runtime services implemented via
> hypercalls, see include/xen/interface/platform.h."

I would prefer if we didn't refer to Linux paths here, for the usual
rationale of keeping bindings distinct from Linux implementation
details.

Could we either drop the "see include/xen/interface/platform.h" part, or
refer to some Xen documentation?

Thanks,
Mark.

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

* Re: [PATCH v3 13/17] ARM: Xen: Document UEFI support on Xen ARM virtual platforms
  2016-01-25 15:59       ` Mark Rutland
  (?)
@ 2016-01-25 16:06         ` Stefano Stabellini
  -1 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 16:06 UTC (permalink / raw)
  To: Mark Rutland
  Cc: Stefano Stabellini, Shannon Zhao, linux-arm-kernel,
	ard.biesheuvel, stefano.stabellini, david.vrabel,
	catalin.marinas, will.deacon, julien.grall, xen-devel,
	devicetree, linux-efi, linux-kernel, ian.campbell, shannon.zhao,
	peter.huangpeng, Rob Herring

On Mon, 25 Jan 2016, Mark Rutland wrote:
> On Mon, Jan 25, 2016 at 03:50:52PM +0000, Stefano Stabellini wrote:
> > On Sat, 23 Jan 2016, Shannon Zhao wrote:
> > > From: Shannon Zhao <shannon.zhao@linaro.org>
> > > 
> > > Add a "uefi" node under /hypervisor node in FDT, then Linux kernel could
> > > scan this to get the UEFI information.
> > > 
> > > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> > > Acked-by: Rob Herring <robh@kernel.org>
> > > ---
> > > CC: Rob Herring <robh@kernel.org>
> > > ---
> > >  Documentation/devicetree/bindings/arm/xen.txt | 34 +++++++++++++++++++++++++++
> > >  1 file changed, 34 insertions(+)
> > > 
> > > diff --git a/Documentation/devicetree/bindings/arm/xen.txt b/Documentation/devicetree/bindings/arm/xen.txt
> > > index 0f7b9c2..aa69405 100644
> > > --- a/Documentation/devicetree/bindings/arm/xen.txt
> > > +++ b/Documentation/devicetree/bindings/arm/xen.txt
> > > @@ -15,6 +15,26 @@ the following properties:
> > >  - interrupts: the interrupt used by Xen to inject event notifications.
> > >    A GIC node is also required.
> > >  
> > > +To support UEFI on Xen ARM virtual platforms, Xen populates the FDT "uefi" node
> > > +under /hypervisor with following parameters:
> > > +
> > > +________________________________________________________________________________
> > > +Name                      | Size   | Description
> > > +================================================================================
> > > +xen,uefi-system-table     | 64-bit | Guest physical address of the UEFI System
> > > +			  |	   | Table.
> > > +--------------------------------------------------------------------------------
> > > +xen,uefi-mmap-start       | 64-bit | Guest physical address of the UEFI memory
> > > +			  |	   | map.
> > > +--------------------------------------------------------------------------------
> > > +xen,uefi-mmap-size        | 32-bit | Size in bytes of the UEFI memory map
> > > +                          |        | pointed to in previous entry.
> > > +--------------------------------------------------------------------------------
> > > +xen,uefi-mmap-desc-size   | 32-bit | Size in bytes of each entry in the UEFI
> > > +                          |        | memory map.
> > > +--------------------------------------------------------------------------------
> > > +xen,uefi-mmap-desc-ver    | 32-bit | Version of the mmap descriptor format.
> > > +--------------------------------------------------------------------------------
> > >  
> > >  Example (assuming #address-cells = <2> and #size-cells = <2>):
> > >  
> > > @@ -22,4 +42,18 @@ hypervisor {
> > >  	compatible = "xen,xen-4.3", "xen,xen";
> > >  	reg = <0 0xb0000000 0 0x20000>;
> > >  	interrupts = <1 15 0xf08>;
> > > +	uefi {
> > > +		xen,uefi-system-table = <0xXXXXXXXX>;
> > > +		xen,uefi-mmap-start = <0xXXXXXXXX>;
> > > +		xen,uefi-mmap-size = <0xXXXXXXXX>;
> > > +		xen,uefi-mmap-desc-size = <0xXXXXXXXX>;
> > > +		xen,uefi-mmap-desc-ver = <0xXXXXXXXX>;
> > > +        };
> > >  };
> > > +
> > > +The format and meaning of these "xen,uefi-*" parameters are similar to those in
> > > +Documentation/arm/uefi.txt which are used by normal UEFI. But to distinguish
> > > +from normal UEFI, for Xen ARM virtual platforms it needs to introduce a Xen
> > > +specific UEFI which requires Xen hypervisor to provide hypercalls for Dom0 to
> > > +make use of the runtime services. Therefore, it defines these parameters under
> > > +/hypervisor node.
> > 
> > Please replace the paragraph with the following which mentions
> > include/xen/interface/platform.h and improves the wording:
> > 
> > "The format and meaning of the "xen,uefi-*" parameters are similar to
> > those in Documentation/arm/uefi.txt, which are provided by the regular
> > UEFI stub. However they differ because they are provided by the Xen
> > hypervisor, together with a set of UEFI runtime services implemented via
> > hypercalls, see include/xen/interface/platform.h."
> 
> I would prefer if we didn't refer to Linux paths here, for the usual
> rationale of keeping bindings distinct from Linux implementation
> details.
> 
> Could we either drop the "see include/xen/interface/platform.h" part, or
> refer to some Xen documentation?

Sure, in fact the canonical headers are the ones in the Xen tree anyway.
We could use the following instead:

http://xenbits.xen.org/docs/unstable/hypercall/x86_64/include,public,platform.h.html 

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

* Re: [PATCH v3 13/17] ARM: Xen: Document UEFI support on Xen ARM virtual platforms
@ 2016-01-25 16:06         ` Stefano Stabellini
  0 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 16:06 UTC (permalink / raw)
  To: Mark Rutland
  Cc: Stefano Stabellini, Shannon Zhao, linux-arm-kernel,
	ard.biesheuvel, stefano.stabellini, david.vrabel,
	catalin.marinas, will.deacon, julien.grall, xen-devel,
	devicetree, linux-efi, linux-kernel, ian.campbell, shannon.zhao,
	peter.huangpeng, Rob Herring

On Mon, 25 Jan 2016, Mark Rutland wrote:
> On Mon, Jan 25, 2016 at 03:50:52PM +0000, Stefano Stabellini wrote:
> > On Sat, 23 Jan 2016, Shannon Zhao wrote:
> > > From: Shannon Zhao <shannon.zhao@linaro.org>
> > > 
> > > Add a "uefi" node under /hypervisor node in FDT, then Linux kernel could
> > > scan this to get the UEFI information.
> > > 
> > > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> > > Acked-by: Rob Herring <robh@kernel.org>
> > > ---
> > > CC: Rob Herring <robh@kernel.org>
> > > ---
> > >  Documentation/devicetree/bindings/arm/xen.txt | 34 +++++++++++++++++++++++++++
> > >  1 file changed, 34 insertions(+)
> > > 
> > > diff --git a/Documentation/devicetree/bindings/arm/xen.txt b/Documentation/devicetree/bindings/arm/xen.txt
> > > index 0f7b9c2..aa69405 100644
> > > --- a/Documentation/devicetree/bindings/arm/xen.txt
> > > +++ b/Documentation/devicetree/bindings/arm/xen.txt
> > > @@ -15,6 +15,26 @@ the following properties:
> > >  - interrupts: the interrupt used by Xen to inject event notifications.
> > >    A GIC node is also required.
> > >  
> > > +To support UEFI on Xen ARM virtual platforms, Xen populates the FDT "uefi" node
> > > +under /hypervisor with following parameters:
> > > +
> > > +________________________________________________________________________________
> > > +Name                      | Size   | Description
> > > +================================================================================
> > > +xen,uefi-system-table     | 64-bit | Guest physical address of the UEFI System
> > > +			  |	   | Table.
> > > +--------------------------------------------------------------------------------
> > > +xen,uefi-mmap-start       | 64-bit | Guest physical address of the UEFI memory
> > > +			  |	   | map.
> > > +--------------------------------------------------------------------------------
> > > +xen,uefi-mmap-size        | 32-bit | Size in bytes of the UEFI memory map
> > > +                          |        | pointed to in previous entry.
> > > +--------------------------------------------------------------------------------
> > > +xen,uefi-mmap-desc-size   | 32-bit | Size in bytes of each entry in the UEFI
> > > +                          |        | memory map.
> > > +--------------------------------------------------------------------------------
> > > +xen,uefi-mmap-desc-ver    | 32-bit | Version of the mmap descriptor format.
> > > +--------------------------------------------------------------------------------
> > >  
> > >  Example (assuming #address-cells = <2> and #size-cells = <2>):
> > >  
> > > @@ -22,4 +42,18 @@ hypervisor {
> > >  	compatible = "xen,xen-4.3", "xen,xen";
> > >  	reg = <0 0xb0000000 0 0x20000>;
> > >  	interrupts = <1 15 0xf08>;
> > > +	uefi {
> > > +		xen,uefi-system-table = <0xXXXXXXXX>;
> > > +		xen,uefi-mmap-start = <0xXXXXXXXX>;
> > > +		xen,uefi-mmap-size = <0xXXXXXXXX>;
> > > +		xen,uefi-mmap-desc-size = <0xXXXXXXXX>;
> > > +		xen,uefi-mmap-desc-ver = <0xXXXXXXXX>;
> > > +        };
> > >  };
> > > +
> > > +The format and meaning of these "xen,uefi-*" parameters are similar to those in
> > > +Documentation/arm/uefi.txt which are used by normal UEFI. But to distinguish
> > > +from normal UEFI, for Xen ARM virtual platforms it needs to introduce a Xen
> > > +specific UEFI which requires Xen hypervisor to provide hypercalls for Dom0 to
> > > +make use of the runtime services. Therefore, it defines these parameters under
> > > +/hypervisor node.
> > 
> > Please replace the paragraph with the following which mentions
> > include/xen/interface/platform.h and improves the wording:
> > 
> > "The format and meaning of the "xen,uefi-*" parameters are similar to
> > those in Documentation/arm/uefi.txt, which are provided by the regular
> > UEFI stub. However they differ because they are provided by the Xen
> > hypervisor, together with a set of UEFI runtime services implemented via
> > hypercalls, see include/xen/interface/platform.h."
> 
> I would prefer if we didn't refer to Linux paths here, for the usual
> rationale of keeping bindings distinct from Linux implementation
> details.
> 
> Could we either drop the "see include/xen/interface/platform.h" part, or
> refer to some Xen documentation?

Sure, in fact the canonical headers are the ones in the Xen tree anyway.
We could use the following instead:

http://xenbits.xen.org/docs/unstable/hypercall/x86_64/include,public,platform.h.html 

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

* [PATCH v3 13/17] ARM: Xen: Document UEFI support on Xen ARM virtual platforms
@ 2016-01-25 16:06         ` Stefano Stabellini
  0 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 16:06 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, 25 Jan 2016, Mark Rutland wrote:
> On Mon, Jan 25, 2016 at 03:50:52PM +0000, Stefano Stabellini wrote:
> > On Sat, 23 Jan 2016, Shannon Zhao wrote:
> > > From: Shannon Zhao <shannon.zhao@linaro.org>
> > > 
> > > Add a "uefi" node under /hypervisor node in FDT, then Linux kernel could
> > > scan this to get the UEFI information.
> > > 
> > > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> > > Acked-by: Rob Herring <robh@kernel.org>
> > > ---
> > > CC: Rob Herring <robh@kernel.org>
> > > ---
> > >  Documentation/devicetree/bindings/arm/xen.txt | 34 +++++++++++++++++++++++++++
> > >  1 file changed, 34 insertions(+)
> > > 
> > > diff --git a/Documentation/devicetree/bindings/arm/xen.txt b/Documentation/devicetree/bindings/arm/xen.txt
> > > index 0f7b9c2..aa69405 100644
> > > --- a/Documentation/devicetree/bindings/arm/xen.txt
> > > +++ b/Documentation/devicetree/bindings/arm/xen.txt
> > > @@ -15,6 +15,26 @@ the following properties:
> > >  - interrupts: the interrupt used by Xen to inject event notifications.
> > >    A GIC node is also required.
> > >  
> > > +To support UEFI on Xen ARM virtual platforms, Xen populates the FDT "uefi" node
> > > +under /hypervisor with following parameters:
> > > +
> > > +________________________________________________________________________________
> > > +Name                      | Size   | Description
> > > +================================================================================
> > > +xen,uefi-system-table     | 64-bit | Guest physical address of the UEFI System
> > > +			  |	   | Table.
> > > +--------------------------------------------------------------------------------
> > > +xen,uefi-mmap-start       | 64-bit | Guest physical address of the UEFI memory
> > > +			  |	   | map.
> > > +--------------------------------------------------------------------------------
> > > +xen,uefi-mmap-size        | 32-bit | Size in bytes of the UEFI memory map
> > > +                          |        | pointed to in previous entry.
> > > +--------------------------------------------------------------------------------
> > > +xen,uefi-mmap-desc-size   | 32-bit | Size in bytes of each entry in the UEFI
> > > +                          |        | memory map.
> > > +--------------------------------------------------------------------------------
> > > +xen,uefi-mmap-desc-ver    | 32-bit | Version of the mmap descriptor format.
> > > +--------------------------------------------------------------------------------
> > >  
> > >  Example (assuming #address-cells = <2> and #size-cells = <2>):
> > >  
> > > @@ -22,4 +42,18 @@ hypervisor {
> > >  	compatible = "xen,xen-4.3", "xen,xen";
> > >  	reg = <0 0xb0000000 0 0x20000>;
> > >  	interrupts = <1 15 0xf08>;
> > > +	uefi {
> > > +		xen,uefi-system-table = <0xXXXXXXXX>;
> > > +		xen,uefi-mmap-start = <0xXXXXXXXX>;
> > > +		xen,uefi-mmap-size = <0xXXXXXXXX>;
> > > +		xen,uefi-mmap-desc-size = <0xXXXXXXXX>;
> > > +		xen,uefi-mmap-desc-ver = <0xXXXXXXXX>;
> > > +        };
> > >  };
> > > +
> > > +The format and meaning of these "xen,uefi-*" parameters are similar to those in
> > > +Documentation/arm/uefi.txt which are used by normal UEFI. But to distinguish
> > > +from normal UEFI, for Xen ARM virtual platforms it needs to introduce a Xen
> > > +specific UEFI which requires Xen hypervisor to provide hypercalls for Dom0 to
> > > +make use of the runtime services. Therefore, it defines these parameters under
> > > +/hypervisor node.
> > 
> > Please replace the paragraph with the following which mentions
> > include/xen/interface/platform.h and improves the wording:
> > 
> > "The format and meaning of the "xen,uefi-*" parameters are similar to
> > those in Documentation/arm/uefi.txt, which are provided by the regular
> > UEFI stub. However they differ because they are provided by the Xen
> > hypervisor, together with a set of UEFI runtime services implemented via
> > hypercalls, see include/xen/interface/platform.h."
> 
> I would prefer if we didn't refer to Linux paths here, for the usual
> rationale of keeping bindings distinct from Linux implementation
> details.
> 
> Could we either drop the "see include/xen/interface/platform.h" part, or
> refer to some Xen documentation?

Sure, in fact the canonical headers are the ones in the Xen tree anyway.
We could use the following instead:

http://xenbits.xen.org/docs/unstable/hypercall/x86_64/include,public,platform.h.html 

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

* Re: [PATCH v3 13/17] ARM: Xen: Document UEFI support on Xen ARM virtual platforms
  2016-01-25 15:59       ` Mark Rutland
  (?)
  (?)
@ 2016-01-25 16:06       ` Stefano Stabellini
  -1 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 16:06 UTC (permalink / raw)
  To: Mark Rutland
  Cc: devicetree, linux-efi, ian.campbell, ard.biesheuvel,
	catalin.marinas, Stefano Stabellini, will.deacon, linux-kernel,
	xen-devel, julien.grall, stefano.stabellini, david.vrabel,
	Shannon Zhao, peter.huangpeng, Rob Herring, linux-arm-kernel,
	shannon.zhao

On Mon, 25 Jan 2016, Mark Rutland wrote:
> On Mon, Jan 25, 2016 at 03:50:52PM +0000, Stefano Stabellini wrote:
> > On Sat, 23 Jan 2016, Shannon Zhao wrote:
> > > From: Shannon Zhao <shannon.zhao@linaro.org>
> > > 
> > > Add a "uefi" node under /hypervisor node in FDT, then Linux kernel could
> > > scan this to get the UEFI information.
> > > 
> > > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> > > Acked-by: Rob Herring <robh@kernel.org>
> > > ---
> > > CC: Rob Herring <robh@kernel.org>
> > > ---
> > >  Documentation/devicetree/bindings/arm/xen.txt | 34 +++++++++++++++++++++++++++
> > >  1 file changed, 34 insertions(+)
> > > 
> > > diff --git a/Documentation/devicetree/bindings/arm/xen.txt b/Documentation/devicetree/bindings/arm/xen.txt
> > > index 0f7b9c2..aa69405 100644
> > > --- a/Documentation/devicetree/bindings/arm/xen.txt
> > > +++ b/Documentation/devicetree/bindings/arm/xen.txt
> > > @@ -15,6 +15,26 @@ the following properties:
> > >  - interrupts: the interrupt used by Xen to inject event notifications.
> > >    A GIC node is also required.
> > >  
> > > +To support UEFI on Xen ARM virtual platforms, Xen populates the FDT "uefi" node
> > > +under /hypervisor with following parameters:
> > > +
> > > +________________________________________________________________________________
> > > +Name                      | Size   | Description
> > > +================================================================================
> > > +xen,uefi-system-table     | 64-bit | Guest physical address of the UEFI System
> > > +			  |	   | Table.
> > > +--------------------------------------------------------------------------------
> > > +xen,uefi-mmap-start       | 64-bit | Guest physical address of the UEFI memory
> > > +			  |	   | map.
> > > +--------------------------------------------------------------------------------
> > > +xen,uefi-mmap-size        | 32-bit | Size in bytes of the UEFI memory map
> > > +                          |        | pointed to in previous entry.
> > > +--------------------------------------------------------------------------------
> > > +xen,uefi-mmap-desc-size   | 32-bit | Size in bytes of each entry in the UEFI
> > > +                          |        | memory map.
> > > +--------------------------------------------------------------------------------
> > > +xen,uefi-mmap-desc-ver    | 32-bit | Version of the mmap descriptor format.
> > > +--------------------------------------------------------------------------------
> > >  
> > >  Example (assuming #address-cells = <2> and #size-cells = <2>):
> > >  
> > > @@ -22,4 +42,18 @@ hypervisor {
> > >  	compatible = "xen,xen-4.3", "xen,xen";
> > >  	reg = <0 0xb0000000 0 0x20000>;
> > >  	interrupts = <1 15 0xf08>;
> > > +	uefi {
> > > +		xen,uefi-system-table = <0xXXXXXXXX>;
> > > +		xen,uefi-mmap-start = <0xXXXXXXXX>;
> > > +		xen,uefi-mmap-size = <0xXXXXXXXX>;
> > > +		xen,uefi-mmap-desc-size = <0xXXXXXXXX>;
> > > +		xen,uefi-mmap-desc-ver = <0xXXXXXXXX>;
> > > +        };
> > >  };
> > > +
> > > +The format and meaning of these "xen,uefi-*" parameters are similar to those in
> > > +Documentation/arm/uefi.txt which are used by normal UEFI. But to distinguish
> > > +from normal UEFI, for Xen ARM virtual platforms it needs to introduce a Xen
> > > +specific UEFI which requires Xen hypervisor to provide hypercalls for Dom0 to
> > > +make use of the runtime services. Therefore, it defines these parameters under
> > > +/hypervisor node.
> > 
> > Please replace the paragraph with the following which mentions
> > include/xen/interface/platform.h and improves the wording:
> > 
> > "The format and meaning of the "xen,uefi-*" parameters are similar to
> > those in Documentation/arm/uefi.txt, which are provided by the regular
> > UEFI stub. However they differ because they are provided by the Xen
> > hypervisor, together with a set of UEFI runtime services implemented via
> > hypercalls, see include/xen/interface/platform.h."
> 
> I would prefer if we didn't refer to Linux paths here, for the usual
> rationale of keeping bindings distinct from Linux implementation
> details.
> 
> Could we either drop the "see include/xen/interface/platform.h" part, or
> refer to some Xen documentation?

Sure, in fact the canonical headers are the ones in the Xen tree anyway.
We could use the following instead:

http://xenbits.xen.org/docs/unstable/hypercall/x86_64/include,public,platform.h.html 

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

* Re: [PATCH v3 14/17] XEN: EFI: Move x86 specific codes to architecture directory
  2016-01-23  3:19   ` Shannon Zhao
  (?)
@ 2016-01-25 16:44     ` Stefano Stabellini
  -1 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 16:44 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel, catalin.marinas, will.deacon,
	julien.grall, xen-devel, devicetree, linux-efi, linux-kernel,
	ian.campbell, shannon.zhao, peter.huangpeng

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

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Move x86 specific codes to architecture directory and export those EFI
> runtime service functions. This will be useful for initializing runtime
> service on ARM later.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

This patch causes a build breakage on x86:

arch/x86/xen/efi.c: In function ‘xen_efi_probe’:
arch/x86/xen/efi.c:101:2: error: implicit declaration of function ‘HYPERVISOR_platform_op’ [-Werror=implicit-function-declaration]



>  arch/x86/xen/efi.c    | 112 ++++++++++++++++++++++++++++++++
>  drivers/xen/efi.c     | 174 ++++++++++----------------------------------------
>  include/xen/xen-ops.h |  30 ++++++---
>  3 files changed, 168 insertions(+), 148 deletions(-)
> 
> diff --git a/arch/x86/xen/efi.c b/arch/x86/xen/efi.c
> index be14cc3..86527f1 100644
> --- a/arch/x86/xen/efi.c
> +++ b/arch/x86/xen/efi.c
> @@ -20,10 +20,122 @@
>  #include <linux/init.h>
>  #include <linux/string.h>
>  
> +#include <xen/xen.h>
>  #include <xen/xen-ops.h>
> +#include <xen/interface/platform.h>
>  
>  #include <asm/page.h>
>  #include <asm/setup.h>
> +#include <asm/xen/hypercall.h>
> +
> +static efi_char16_t vendor[100] __initdata;
> +
> +static efi_system_table_t efi_systab_xen __initdata = {
> +	.hdr = {
> +		.signature	= EFI_SYSTEM_TABLE_SIGNATURE,
> +		.revision	= 0, /* Initialized later. */
> +		.headersize	= 0, /* Ignored by Linux Kernel. */
> +		.crc32		= 0, /* Ignored by Linux Kernel. */
> +		.reserved	= 0
> +	},
> +	.fw_vendor	= EFI_INVALID_TABLE_ADDR, /* Initialized later. */
> +	.fw_revision	= 0,			  /* Initialized later. */
> +	.con_in_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> +	.con_in		= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> +	.con_out_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> +	.con_out	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> +	.stderr_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> +	.stderr		= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> +	.runtime	= (efi_runtime_services_t *)EFI_INVALID_TABLE_ADDR,
> +						  /* Not used under Xen. */
> +	.boottime	= (efi_boot_services_t *)EFI_INVALID_TABLE_ADDR,
> +						  /* Not used under Xen. */
> +	.nr_tables	= 0,			  /* Initialized later. */
> +	.tables		= EFI_INVALID_TABLE_ADDR  /* Initialized later. */
> +};
> +
> +static const struct efi efi_xen __initconst = {
> +	.systab                   = NULL, /* Initialized later. */
> +	.runtime_version	  = 0,    /* Initialized later. */
> +	.mps                      = EFI_INVALID_TABLE_ADDR,
> +	.acpi                     = EFI_INVALID_TABLE_ADDR,
> +	.acpi20                   = EFI_INVALID_TABLE_ADDR,
> +	.smbios                   = EFI_INVALID_TABLE_ADDR,
> +	.smbios3                  = EFI_INVALID_TABLE_ADDR,
> +	.sal_systab               = EFI_INVALID_TABLE_ADDR,
> +	.boot_info                = EFI_INVALID_TABLE_ADDR,
> +	.hcdp                     = EFI_INVALID_TABLE_ADDR,
> +	.uga                      = EFI_INVALID_TABLE_ADDR,
> +	.uv_systab                = EFI_INVALID_TABLE_ADDR,
> +	.fw_vendor                = EFI_INVALID_TABLE_ADDR,
> +	.runtime                  = EFI_INVALID_TABLE_ADDR,
> +	.config_table             = EFI_INVALID_TABLE_ADDR,
> +	.get_time                 = xen_efi_get_time,
> +	.set_time                 = xen_efi_set_time,
> +	.get_wakeup_time          = xen_efi_get_wakeup_time,
> +	.set_wakeup_time          = xen_efi_set_wakeup_time,
> +	.get_variable             = xen_efi_get_variable,
> +	.get_next_variable        = xen_efi_get_next_variable,
> +	.set_variable             = xen_efi_set_variable,
> +	.query_variable_info      = xen_efi_query_variable_info,
> +	.update_capsule           = xen_efi_update_capsule,
> +	.query_capsule_caps       = xen_efi_query_capsule_caps,
> +	.get_next_high_mono_count = xen_efi_get_next_high_mono_count,
> +	.reset_system             = NULL, /* Functionality provided by Xen. */
> +	.set_virtual_address_map  = NULL, /* Not used under Xen. */
> +	.memmap                   = NULL, /* Not used under Xen. */
> +	.flags			  = 0     /* Initialized later. */
> +};
> +
> +static efi_system_table_t __init *xen_efi_probe(void)
> +{
> +	struct xen_platform_op op = {
> +		.cmd = XENPF_firmware_info,
> +		.u.firmware_info = {
> +			.type = XEN_FW_EFI_INFO,
> +			.index = XEN_FW_EFI_CONFIG_TABLE
> +		}
> +	};
> +	union xenpf_efi_info *info = &op.u.firmware_info.u.efi_info;
> +
> +	if (!xen_initial_domain() || HYPERVISOR_platform_op(&op) < 0)
> +		return NULL;
> +
> +	/* Here we know that Xen runs on EFI platform. */
> +
> +	efi = efi_xen;
> +
> +	efi_systab_xen.tables = info->cfg.addr;
> +	efi_systab_xen.nr_tables = info->cfg.nent;
> +
> +	op.cmd = XENPF_firmware_info;
> +	op.u.firmware_info.type = XEN_FW_EFI_INFO;
> +	op.u.firmware_info.index = XEN_FW_EFI_VENDOR;
> +	info->vendor.bufsz = sizeof(vendor);
> +	set_xen_guest_handle(info->vendor.name, vendor);
> +
> +	if (HYPERVISOR_platform_op(&op) == 0) {
> +		efi_systab_xen.fw_vendor = __pa_symbol(vendor);
> +		efi_systab_xen.fw_revision = info->vendor.revision;
> +	} else
> +		efi_systab_xen.fw_vendor = __pa_symbol(L"UNKNOWN");
> +
> +	op.cmd = XENPF_firmware_info;
> +	op.u.firmware_info.type = XEN_FW_EFI_INFO;
> +	op.u.firmware_info.index = XEN_FW_EFI_VERSION;
> +
> +	if (HYPERVISOR_platform_op(&op) == 0)
> +		efi_systab_xen.hdr.revision = info->version;
> +
> +	op.cmd = XENPF_firmware_info;
> +	op.u.firmware_info.type = XEN_FW_EFI_INFO;
> +	op.u.firmware_info.index = XEN_FW_EFI_RT_VERSION;
> +
> +	if (HYPERVISOR_platform_op(&op) == 0)
> +		efi.runtime_version = info->version;
> +
> +	return &efi_systab_xen;
> +}
>  
>  void __init xen_efi_init(void)
>  {
> diff --git a/drivers/xen/efi.c b/drivers/xen/efi.c
> index be7e56a..22f71ff 100644
> --- a/drivers/xen/efi.c
> +++ b/drivers/xen/efi.c
> @@ -38,7 +38,7 @@
>  
>  #define efi_data(op)	(op.u.efi_runtime_call)
>  
> -static efi_status_t xen_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc)
> +efi_status_t xen_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(get_time);
>  
> @@ -59,8 +59,9 @@ static efi_status_t xen_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc)
>  
>  	return efi_data(op).status;
>  }
> +EXPORT_SYMBOL_GPL(xen_efi_get_time);
>  
> -static efi_status_t xen_efi_set_time(efi_time_t *tm)
> +efi_status_t xen_efi_set_time(efi_time_t *tm)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(set_time);
>  
> @@ -72,10 +73,10 @@ static efi_status_t xen_efi_set_time(efi_time_t *tm)
>  
>  	return efi_data(op).status;
>  }
> +EXPORT_SYMBOL_GPL(xen_efi_set_time);
>  
> -static efi_status_t xen_efi_get_wakeup_time(efi_bool_t *enabled,
> -					    efi_bool_t *pending,
> -					    efi_time_t *tm)
> +efi_status_t xen_efi_get_wakeup_time(efi_bool_t *enabled, efi_bool_t *pending,
> +				     efi_time_t *tm)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(get_wakeup_time);
>  
> @@ -95,8 +96,9 @@ static efi_status_t xen_efi_get_wakeup_time(efi_bool_t *enabled,
>  
>  	return efi_data(op).status;
>  }
> +EXPORT_SYMBOL_GPL(xen_efi_get_wakeup_time);
>  
> -static efi_status_t xen_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm)
> +efi_status_t xen_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(set_wakeup_time);
>  
> @@ -113,12 +115,11 @@ static efi_status_t xen_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm)
>  
>  	return efi_data(op).status;
>  }
> +EXPORT_SYMBOL_GPL(xen_efi_set_wakeup_time);
>  
> -static efi_status_t xen_efi_get_variable(efi_char16_t *name,
> -					 efi_guid_t *vendor,
> -					 u32 *attr,
> -					 unsigned long *data_size,
> -					 void *data)
> +efi_status_t xen_efi_get_variable(efi_char16_t *name, efi_guid_t *vendor,
> +				  u32 *attr, unsigned long *data_size,
> +				  void *data)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(get_variable);
>  
> @@ -138,10 +139,11 @@ static efi_status_t xen_efi_get_variable(efi_char16_t *name,
>  
>  	return efi_data(op).status;
>  }
> +EXPORT_SYMBOL_GPL(xen_efi_get_variable);
>  
> -static efi_status_t xen_efi_get_next_variable(unsigned long *name_size,
> -					      efi_char16_t *name,
> -					      efi_guid_t *vendor)
> +efi_status_t xen_efi_get_next_variable(unsigned long *name_size,
> +				       efi_char16_t *name,
> +				       efi_guid_t *vendor)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(get_next_variable_name);
>  
> @@ -161,12 +163,11 @@ static efi_status_t xen_efi_get_next_variable(unsigned long *name_size,
>  
>  	return efi_data(op).status;
>  }
> +EXPORT_SYMBOL_GPL(xen_efi_get_next_variable);
>  
> -static efi_status_t xen_efi_set_variable(efi_char16_t *name,
> -					 efi_guid_t *vendor,
> -					 u32 attr,
> -					 unsigned long data_size,
> -					 void *data)
> +efi_status_t xen_efi_set_variable(efi_char16_t *name, efi_guid_t *vendor,
> +				 u32 attr, unsigned long data_size,
> +				 void *data)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(set_variable);
>  
> @@ -183,11 +184,11 @@ static efi_status_t xen_efi_set_variable(efi_char16_t *name,
>  
>  	return efi_data(op).status;
>  }
> +EXPORT_SYMBOL_GPL(xen_efi_set_variable);
>  
> -static efi_status_t xen_efi_query_variable_info(u32 attr,
> -						u64 *storage_space,
> -						u64 *remaining_space,
> -						u64 *max_variable_size)
> +efi_status_t xen_efi_query_variable_info(u32 attr, u64 *storage_space,
> +					 u64 *remaining_space,
> +					 u64 *max_variable_size)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(query_variable_info);
>  
> @@ -205,8 +206,9 @@ static efi_status_t xen_efi_query_variable_info(u32 attr,
>  
>  	return efi_data(op).status;
>  }
> +EXPORT_SYMBOL_GPL(xen_efi_query_variable_info);
>  
> -static efi_status_t xen_efi_get_next_high_mono_count(u32 *count)
> +efi_status_t xen_efi_get_next_high_mono_count(u32 *count)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(get_next_high_monotonic_count);
>  
> @@ -217,10 +219,10 @@ static efi_status_t xen_efi_get_next_high_mono_count(u32 *count)
>  
>  	return efi_data(op).status;
>  }
> +EXPORT_SYMBOL_GPL(xen_efi_get_next_high_mono_count);
>  
> -static efi_status_t xen_efi_update_capsule(efi_capsule_header_t **capsules,
> -					   unsigned long count,
> -					   unsigned long sg_list)
> +efi_status_t xen_efi_update_capsule(efi_capsule_header_t **capsules,
> +				    unsigned long count, unsigned long sg_list)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(update_capsule);
>  
> @@ -237,11 +239,11 @@ static efi_status_t xen_efi_update_capsule(efi_capsule_header_t **capsules,
>  
>  	return efi_data(op).status;
>  }
> +EXPORT_SYMBOL_GPL(xen_efi_update_capsule);
>  
> -static efi_status_t xen_efi_query_capsule_caps(efi_capsule_header_t **capsules,
> -					       unsigned long count,
> -					       u64 *max_size,
> -					       int *reset_type)
> +efi_status_t xen_efi_query_capsule_caps(efi_capsule_header_t **capsules,
> +					unsigned long count, u64 *max_size,
> +					int *reset_type)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(query_capsule_capabilities);
>  
> @@ -260,112 +262,4 @@ static efi_status_t xen_efi_query_capsule_caps(efi_capsule_header_t **capsules,
>  
>  	return efi_data(op).status;
>  }
> -
> -static efi_char16_t vendor[100] __initdata;
> -
> -static efi_system_table_t efi_systab_xen __initdata = {
> -	.hdr = {
> -		.signature	= EFI_SYSTEM_TABLE_SIGNATURE,
> -		.revision	= 0, /* Initialized later. */
> -		.headersize	= 0, /* Ignored by Linux Kernel. */
> -		.crc32		= 0, /* Ignored by Linux Kernel. */
> -		.reserved	= 0
> -	},
> -	.fw_vendor	= EFI_INVALID_TABLE_ADDR, /* Initialized later. */
> -	.fw_revision	= 0,			  /* Initialized later. */
> -	.con_in_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> -	.con_in		= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> -	.con_out_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> -	.con_out	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> -	.stderr_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> -	.stderr		= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> -	.runtime	= (efi_runtime_services_t *)EFI_INVALID_TABLE_ADDR,
> -						  /* Not used under Xen. */
> -	.boottime	= (efi_boot_services_t *)EFI_INVALID_TABLE_ADDR,
> -						  /* Not used under Xen. */
> -	.nr_tables	= 0,			  /* Initialized later. */
> -	.tables		= EFI_INVALID_TABLE_ADDR  /* Initialized later. */
> -};
> -
> -static const struct efi efi_xen __initconst = {
> -	.systab                   = NULL, /* Initialized later. */
> -	.runtime_version	  = 0,    /* Initialized later. */
> -	.mps                      = EFI_INVALID_TABLE_ADDR,
> -	.acpi                     = EFI_INVALID_TABLE_ADDR,
> -	.acpi20                   = EFI_INVALID_TABLE_ADDR,
> -	.smbios                   = EFI_INVALID_TABLE_ADDR,
> -	.smbios3                  = EFI_INVALID_TABLE_ADDR,
> -	.sal_systab               = EFI_INVALID_TABLE_ADDR,
> -	.boot_info                = EFI_INVALID_TABLE_ADDR,
> -	.hcdp                     = EFI_INVALID_TABLE_ADDR,
> -	.uga                      = EFI_INVALID_TABLE_ADDR,
> -	.uv_systab                = EFI_INVALID_TABLE_ADDR,
> -	.fw_vendor                = EFI_INVALID_TABLE_ADDR,
> -	.runtime                  = EFI_INVALID_TABLE_ADDR,
> -	.config_table             = EFI_INVALID_TABLE_ADDR,
> -	.get_time                 = xen_efi_get_time,
> -	.set_time                 = xen_efi_set_time,
> -	.get_wakeup_time          = xen_efi_get_wakeup_time,
> -	.set_wakeup_time          = xen_efi_set_wakeup_time,
> -	.get_variable             = xen_efi_get_variable,
> -	.get_next_variable        = xen_efi_get_next_variable,
> -	.set_variable             = xen_efi_set_variable,
> -	.query_variable_info      = xen_efi_query_variable_info,
> -	.update_capsule           = xen_efi_update_capsule,
> -	.query_capsule_caps       = xen_efi_query_capsule_caps,
> -	.get_next_high_mono_count = xen_efi_get_next_high_mono_count,
> -	.reset_system             = NULL, /* Functionality provided by Xen. */
> -	.set_virtual_address_map  = NULL, /* Not used under Xen. */
> -	.memmap                   = NULL, /* Not used under Xen. */
> -	.flags			  = 0     /* Initialized later. */
> -};
> -
> -efi_system_table_t __init *xen_efi_probe(void)
> -{
> -	struct xen_platform_op op = {
> -		.cmd = XENPF_firmware_info,
> -		.u.firmware_info = {
> -			.type = XEN_FW_EFI_INFO,
> -			.index = XEN_FW_EFI_CONFIG_TABLE
> -		}
> -	};
> -	union xenpf_efi_info *info = &op.u.firmware_info.u.efi_info;
> -
> -	if (!xen_initial_domain() || HYPERVISOR_platform_op(&op) < 0)
> -		return NULL;
> -
> -	/* Here we know that Xen runs on EFI platform. */
> -
> -	efi = efi_xen;
> -
> -	efi_systab_xen.tables = info->cfg.addr;
> -	efi_systab_xen.nr_tables = info->cfg.nent;
> -
> -	op.cmd = XENPF_firmware_info;
> -	op.u.firmware_info.type = XEN_FW_EFI_INFO;
> -	op.u.firmware_info.index = XEN_FW_EFI_VENDOR;
> -	info->vendor.bufsz = sizeof(vendor);
> -	set_xen_guest_handle(info->vendor.name, vendor);
> -
> -	if (HYPERVISOR_platform_op(&op) == 0) {
> -		efi_systab_xen.fw_vendor = __pa_symbol(vendor);
> -		efi_systab_xen.fw_revision = info->vendor.revision;
> -	} else
> -		efi_systab_xen.fw_vendor = __pa_symbol(L"UNKNOWN");
> -
> -	op.cmd = XENPF_firmware_info;
> -	op.u.firmware_info.type = XEN_FW_EFI_INFO;
> -	op.u.firmware_info.index = XEN_FW_EFI_VERSION;
> -
> -	if (HYPERVISOR_platform_op(&op) == 0)
> -		efi_systab_xen.hdr.revision = info->version;
> -
> -	op.cmd = XENPF_firmware_info;
> -	op.u.firmware_info.type = XEN_FW_EFI_INFO;
> -	op.u.firmware_info.index = XEN_FW_EFI_RT_VERSION;
> -
> -	if (HYPERVISOR_platform_op(&op) == 0)
> -		efi.runtime_version = info->version;
> -
> -	return &efi_systab_xen;
> -}
> +EXPORT_SYMBOL_GPL(xen_efi_query_capsule_caps);
> diff --git a/include/xen/xen-ops.h b/include/xen/xen-ops.h
> index 42be31a..c83a338 100644
> --- a/include/xen/xen-ops.h
> +++ b/include/xen/xen-ops.h
> @@ -85,14 +85,28 @@ int xen_xlate_map_ballooned_pages(xen_pfn_t **pfns, void **vaddr,
>  
>  bool xen_running_on_version_or_later(unsigned int major, unsigned int minor);
>  
> -#ifdef CONFIG_XEN_EFI
> -extern efi_system_table_t *xen_efi_probe(void);
> -#else
> -static inline efi_system_table_t __init *xen_efi_probe(void)
> -{
> -	return NULL;
> -}
> -#endif
> +efi_status_t xen_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc);
> +efi_status_t xen_efi_set_time(efi_time_t *tm);
> +efi_status_t xen_efi_get_wakeup_time(efi_bool_t *enabled, efi_bool_t *pending,
> +				     efi_time_t *tm);
> +efi_status_t xen_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm);
> +efi_status_t xen_efi_get_variable(efi_char16_t *name, efi_guid_t *vendor,
> +				  u32 *attr, unsigned long *data_size,
> +				  void *data);
> +efi_status_t xen_efi_get_next_variable(unsigned long *name_size,
> +				       efi_char16_t *name, efi_guid_t *vendor);
> +efi_status_t xen_efi_set_variable(efi_char16_t *name, efi_guid_t *vendor,
> +				  u32 attr, unsigned long data_size,
> +				  void *data);
> +efi_status_t xen_efi_query_variable_info(u32 attr, u64 *storage_space,
> +					 u64 *remaining_space,
> +					 u64 *max_variable_size);
> +efi_status_t xen_efi_get_next_high_mono_count(u32 *count);
> +efi_status_t xen_efi_update_capsule(efi_capsule_header_t **capsules,
> +				    unsigned long count, unsigned long sg_list);
> +efi_status_t xen_efi_query_capsule_caps(efi_capsule_header_t **capsules,
> +					unsigned long count, u64 *max_size,
> +					int *reset_type);
>  
>  #ifdef CONFIG_PREEMPT
>  
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v3 14/17] XEN: EFI: Move x86 specific codes to architecture directory
@ 2016-01-25 16:44     ` Stefano Stabellini
  0 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 16:44 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel, catalin.marinas, will.deacon,
	julien.grall, xen-devel, devicetree, linux-efi, linux-kernel,
	ian.campbell, shannon.zhao, peter.huangpeng

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

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Move x86 specific codes to architecture directory and export those EFI
> runtime service functions. This will be useful for initializing runtime
> service on ARM later.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

This patch causes a build breakage on x86:

arch/x86/xen/efi.c: In function ‘xen_efi_probe’:
arch/x86/xen/efi.c:101:2: error: implicit declaration of function ‘HYPERVISOR_platform_op’ [-Werror=implicit-function-declaration]



>  arch/x86/xen/efi.c    | 112 ++++++++++++++++++++++++++++++++
>  drivers/xen/efi.c     | 174 ++++++++++----------------------------------------
>  include/xen/xen-ops.h |  30 ++++++---
>  3 files changed, 168 insertions(+), 148 deletions(-)
> 
> diff --git a/arch/x86/xen/efi.c b/arch/x86/xen/efi.c
> index be14cc3..86527f1 100644
> --- a/arch/x86/xen/efi.c
> +++ b/arch/x86/xen/efi.c
> @@ -20,10 +20,122 @@
>  #include <linux/init.h>
>  #include <linux/string.h>
>  
> +#include <xen/xen.h>
>  #include <xen/xen-ops.h>
> +#include <xen/interface/platform.h>
>  
>  #include <asm/page.h>
>  #include <asm/setup.h>
> +#include <asm/xen/hypercall.h>
> +
> +static efi_char16_t vendor[100] __initdata;
> +
> +static efi_system_table_t efi_systab_xen __initdata = {
> +	.hdr = {
> +		.signature	= EFI_SYSTEM_TABLE_SIGNATURE,
> +		.revision	= 0, /* Initialized later. */
> +		.headersize	= 0, /* Ignored by Linux Kernel. */
> +		.crc32		= 0, /* Ignored by Linux Kernel. */
> +		.reserved	= 0
> +	},
> +	.fw_vendor	= EFI_INVALID_TABLE_ADDR, /* Initialized later. */
> +	.fw_revision	= 0,			  /* Initialized later. */
> +	.con_in_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> +	.con_in		= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> +	.con_out_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> +	.con_out	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> +	.stderr_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> +	.stderr		= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> +	.runtime	= (efi_runtime_services_t *)EFI_INVALID_TABLE_ADDR,
> +						  /* Not used under Xen. */
> +	.boottime	= (efi_boot_services_t *)EFI_INVALID_TABLE_ADDR,
> +						  /* Not used under Xen. */
> +	.nr_tables	= 0,			  /* Initialized later. */
> +	.tables		= EFI_INVALID_TABLE_ADDR  /* Initialized later. */
> +};
> +
> +static const struct efi efi_xen __initconst = {
> +	.systab                   = NULL, /* Initialized later. */
> +	.runtime_version	  = 0,    /* Initialized later. */
> +	.mps                      = EFI_INVALID_TABLE_ADDR,
> +	.acpi                     = EFI_INVALID_TABLE_ADDR,
> +	.acpi20                   = EFI_INVALID_TABLE_ADDR,
> +	.smbios                   = EFI_INVALID_TABLE_ADDR,
> +	.smbios3                  = EFI_INVALID_TABLE_ADDR,
> +	.sal_systab               = EFI_INVALID_TABLE_ADDR,
> +	.boot_info                = EFI_INVALID_TABLE_ADDR,
> +	.hcdp                     = EFI_INVALID_TABLE_ADDR,
> +	.uga                      = EFI_INVALID_TABLE_ADDR,
> +	.uv_systab                = EFI_INVALID_TABLE_ADDR,
> +	.fw_vendor                = EFI_INVALID_TABLE_ADDR,
> +	.runtime                  = EFI_INVALID_TABLE_ADDR,
> +	.config_table             = EFI_INVALID_TABLE_ADDR,
> +	.get_time                 = xen_efi_get_time,
> +	.set_time                 = xen_efi_set_time,
> +	.get_wakeup_time          = xen_efi_get_wakeup_time,
> +	.set_wakeup_time          = xen_efi_set_wakeup_time,
> +	.get_variable             = xen_efi_get_variable,
> +	.get_next_variable        = xen_efi_get_next_variable,
> +	.set_variable             = xen_efi_set_variable,
> +	.query_variable_info      = xen_efi_query_variable_info,
> +	.update_capsule           = xen_efi_update_capsule,
> +	.query_capsule_caps       = xen_efi_query_capsule_caps,
> +	.get_next_high_mono_count = xen_efi_get_next_high_mono_count,
> +	.reset_system             = NULL, /* Functionality provided by Xen. */
> +	.set_virtual_address_map  = NULL, /* Not used under Xen. */
> +	.memmap                   = NULL, /* Not used under Xen. */
> +	.flags			  = 0     /* Initialized later. */
> +};
> +
> +static efi_system_table_t __init *xen_efi_probe(void)
> +{
> +	struct xen_platform_op op = {
> +		.cmd = XENPF_firmware_info,
> +		.u.firmware_info = {
> +			.type = XEN_FW_EFI_INFO,
> +			.index = XEN_FW_EFI_CONFIG_TABLE
> +		}
> +	};
> +	union xenpf_efi_info *info = &op.u.firmware_info.u.efi_info;
> +
> +	if (!xen_initial_domain() || HYPERVISOR_platform_op(&op) < 0)
> +		return NULL;
> +
> +	/* Here we know that Xen runs on EFI platform. */
> +
> +	efi = efi_xen;
> +
> +	efi_systab_xen.tables = info->cfg.addr;
> +	efi_systab_xen.nr_tables = info->cfg.nent;
> +
> +	op.cmd = XENPF_firmware_info;
> +	op.u.firmware_info.type = XEN_FW_EFI_INFO;
> +	op.u.firmware_info.index = XEN_FW_EFI_VENDOR;
> +	info->vendor.bufsz = sizeof(vendor);
> +	set_xen_guest_handle(info->vendor.name, vendor);
> +
> +	if (HYPERVISOR_platform_op(&op) == 0) {
> +		efi_systab_xen.fw_vendor = __pa_symbol(vendor);
> +		efi_systab_xen.fw_revision = info->vendor.revision;
> +	} else
> +		efi_systab_xen.fw_vendor = __pa_symbol(L"UNKNOWN");
> +
> +	op.cmd = XENPF_firmware_info;
> +	op.u.firmware_info.type = XEN_FW_EFI_INFO;
> +	op.u.firmware_info.index = XEN_FW_EFI_VERSION;
> +
> +	if (HYPERVISOR_platform_op(&op) == 0)
> +		efi_systab_xen.hdr.revision = info->version;
> +
> +	op.cmd = XENPF_firmware_info;
> +	op.u.firmware_info.type = XEN_FW_EFI_INFO;
> +	op.u.firmware_info.index = XEN_FW_EFI_RT_VERSION;
> +
> +	if (HYPERVISOR_platform_op(&op) == 0)
> +		efi.runtime_version = info->version;
> +
> +	return &efi_systab_xen;
> +}
>  
>  void __init xen_efi_init(void)
>  {
> diff --git a/drivers/xen/efi.c b/drivers/xen/efi.c
> index be7e56a..22f71ff 100644
> --- a/drivers/xen/efi.c
> +++ b/drivers/xen/efi.c
> @@ -38,7 +38,7 @@
>  
>  #define efi_data(op)	(op.u.efi_runtime_call)
>  
> -static efi_status_t xen_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc)
> +efi_status_t xen_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(get_time);
>  
> @@ -59,8 +59,9 @@ static efi_status_t xen_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc)
>  
>  	return efi_data(op).status;
>  }
> +EXPORT_SYMBOL_GPL(xen_efi_get_time);
>  
> -static efi_status_t xen_efi_set_time(efi_time_t *tm)
> +efi_status_t xen_efi_set_time(efi_time_t *tm)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(set_time);
>  
> @@ -72,10 +73,10 @@ static efi_status_t xen_efi_set_time(efi_time_t *tm)
>  
>  	return efi_data(op).status;
>  }
> +EXPORT_SYMBOL_GPL(xen_efi_set_time);
>  
> -static efi_status_t xen_efi_get_wakeup_time(efi_bool_t *enabled,
> -					    efi_bool_t *pending,
> -					    efi_time_t *tm)
> +efi_status_t xen_efi_get_wakeup_time(efi_bool_t *enabled, efi_bool_t *pending,
> +				     efi_time_t *tm)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(get_wakeup_time);
>  
> @@ -95,8 +96,9 @@ static efi_status_t xen_efi_get_wakeup_time(efi_bool_t *enabled,
>  
>  	return efi_data(op).status;
>  }
> +EXPORT_SYMBOL_GPL(xen_efi_get_wakeup_time);
>  
> -static efi_status_t xen_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm)
> +efi_status_t xen_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(set_wakeup_time);
>  
> @@ -113,12 +115,11 @@ static efi_status_t xen_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm)
>  
>  	return efi_data(op).status;
>  }
> +EXPORT_SYMBOL_GPL(xen_efi_set_wakeup_time);
>  
> -static efi_status_t xen_efi_get_variable(efi_char16_t *name,
> -					 efi_guid_t *vendor,
> -					 u32 *attr,
> -					 unsigned long *data_size,
> -					 void *data)
> +efi_status_t xen_efi_get_variable(efi_char16_t *name, efi_guid_t *vendor,
> +				  u32 *attr, unsigned long *data_size,
> +				  void *data)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(get_variable);
>  
> @@ -138,10 +139,11 @@ static efi_status_t xen_efi_get_variable(efi_char16_t *name,
>  
>  	return efi_data(op).status;
>  }
> +EXPORT_SYMBOL_GPL(xen_efi_get_variable);
>  
> -static efi_status_t xen_efi_get_next_variable(unsigned long *name_size,
> -					      efi_char16_t *name,
> -					      efi_guid_t *vendor)
> +efi_status_t xen_efi_get_next_variable(unsigned long *name_size,
> +				       efi_char16_t *name,
> +				       efi_guid_t *vendor)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(get_next_variable_name);
>  
> @@ -161,12 +163,11 @@ static efi_status_t xen_efi_get_next_variable(unsigned long *name_size,
>  
>  	return efi_data(op).status;
>  }
> +EXPORT_SYMBOL_GPL(xen_efi_get_next_variable);
>  
> -static efi_status_t xen_efi_set_variable(efi_char16_t *name,
> -					 efi_guid_t *vendor,
> -					 u32 attr,
> -					 unsigned long data_size,
> -					 void *data)
> +efi_status_t xen_efi_set_variable(efi_char16_t *name, efi_guid_t *vendor,
> +				 u32 attr, unsigned long data_size,
> +				 void *data)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(set_variable);
>  
> @@ -183,11 +184,11 @@ static efi_status_t xen_efi_set_variable(efi_char16_t *name,
>  
>  	return efi_data(op).status;
>  }
> +EXPORT_SYMBOL_GPL(xen_efi_set_variable);
>  
> -static efi_status_t xen_efi_query_variable_info(u32 attr,
> -						u64 *storage_space,
> -						u64 *remaining_space,
> -						u64 *max_variable_size)
> +efi_status_t xen_efi_query_variable_info(u32 attr, u64 *storage_space,
> +					 u64 *remaining_space,
> +					 u64 *max_variable_size)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(query_variable_info);
>  
> @@ -205,8 +206,9 @@ static efi_status_t xen_efi_query_variable_info(u32 attr,
>  
>  	return efi_data(op).status;
>  }
> +EXPORT_SYMBOL_GPL(xen_efi_query_variable_info);
>  
> -static efi_status_t xen_efi_get_next_high_mono_count(u32 *count)
> +efi_status_t xen_efi_get_next_high_mono_count(u32 *count)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(get_next_high_monotonic_count);
>  
> @@ -217,10 +219,10 @@ static efi_status_t xen_efi_get_next_high_mono_count(u32 *count)
>  
>  	return efi_data(op).status;
>  }
> +EXPORT_SYMBOL_GPL(xen_efi_get_next_high_mono_count);
>  
> -static efi_status_t xen_efi_update_capsule(efi_capsule_header_t **capsules,
> -					   unsigned long count,
> -					   unsigned long sg_list)
> +efi_status_t xen_efi_update_capsule(efi_capsule_header_t **capsules,
> +				    unsigned long count, unsigned long sg_list)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(update_capsule);
>  
> @@ -237,11 +239,11 @@ static efi_status_t xen_efi_update_capsule(efi_capsule_header_t **capsules,
>  
>  	return efi_data(op).status;
>  }
> +EXPORT_SYMBOL_GPL(xen_efi_update_capsule);
>  
> -static efi_status_t xen_efi_query_capsule_caps(efi_capsule_header_t **capsules,
> -					       unsigned long count,
> -					       u64 *max_size,
> -					       int *reset_type)
> +efi_status_t xen_efi_query_capsule_caps(efi_capsule_header_t **capsules,
> +					unsigned long count, u64 *max_size,
> +					int *reset_type)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(query_capsule_capabilities);
>  
> @@ -260,112 +262,4 @@ static efi_status_t xen_efi_query_capsule_caps(efi_capsule_header_t **capsules,
>  
>  	return efi_data(op).status;
>  }
> -
> -static efi_char16_t vendor[100] __initdata;
> -
> -static efi_system_table_t efi_systab_xen __initdata = {
> -	.hdr = {
> -		.signature	= EFI_SYSTEM_TABLE_SIGNATURE,
> -		.revision	= 0, /* Initialized later. */
> -		.headersize	= 0, /* Ignored by Linux Kernel. */
> -		.crc32		= 0, /* Ignored by Linux Kernel. */
> -		.reserved	= 0
> -	},
> -	.fw_vendor	= EFI_INVALID_TABLE_ADDR, /* Initialized later. */
> -	.fw_revision	= 0,			  /* Initialized later. */
> -	.con_in_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> -	.con_in		= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> -	.con_out_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> -	.con_out	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> -	.stderr_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> -	.stderr		= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> -	.runtime	= (efi_runtime_services_t *)EFI_INVALID_TABLE_ADDR,
> -						  /* Not used under Xen. */
> -	.boottime	= (efi_boot_services_t *)EFI_INVALID_TABLE_ADDR,
> -						  /* Not used under Xen. */
> -	.nr_tables	= 0,			  /* Initialized later. */
> -	.tables		= EFI_INVALID_TABLE_ADDR  /* Initialized later. */
> -};
> -
> -static const struct efi efi_xen __initconst = {
> -	.systab                   = NULL, /* Initialized later. */
> -	.runtime_version	  = 0,    /* Initialized later. */
> -	.mps                      = EFI_INVALID_TABLE_ADDR,
> -	.acpi                     = EFI_INVALID_TABLE_ADDR,
> -	.acpi20                   = EFI_INVALID_TABLE_ADDR,
> -	.smbios                   = EFI_INVALID_TABLE_ADDR,
> -	.smbios3                  = EFI_INVALID_TABLE_ADDR,
> -	.sal_systab               = EFI_INVALID_TABLE_ADDR,
> -	.boot_info                = EFI_INVALID_TABLE_ADDR,
> -	.hcdp                     = EFI_INVALID_TABLE_ADDR,
> -	.uga                      = EFI_INVALID_TABLE_ADDR,
> -	.uv_systab                = EFI_INVALID_TABLE_ADDR,
> -	.fw_vendor                = EFI_INVALID_TABLE_ADDR,
> -	.runtime                  = EFI_INVALID_TABLE_ADDR,
> -	.config_table             = EFI_INVALID_TABLE_ADDR,
> -	.get_time                 = xen_efi_get_time,
> -	.set_time                 = xen_efi_set_time,
> -	.get_wakeup_time          = xen_efi_get_wakeup_time,
> -	.set_wakeup_time          = xen_efi_set_wakeup_time,
> -	.get_variable             = xen_efi_get_variable,
> -	.get_next_variable        = xen_efi_get_next_variable,
> -	.set_variable             = xen_efi_set_variable,
> -	.query_variable_info      = xen_efi_query_variable_info,
> -	.update_capsule           = xen_efi_update_capsule,
> -	.query_capsule_caps       = xen_efi_query_capsule_caps,
> -	.get_next_high_mono_count = xen_efi_get_next_high_mono_count,
> -	.reset_system             = NULL, /* Functionality provided by Xen. */
> -	.set_virtual_address_map  = NULL, /* Not used under Xen. */
> -	.memmap                   = NULL, /* Not used under Xen. */
> -	.flags			  = 0     /* Initialized later. */
> -};
> -
> -efi_system_table_t __init *xen_efi_probe(void)
> -{
> -	struct xen_platform_op op = {
> -		.cmd = XENPF_firmware_info,
> -		.u.firmware_info = {
> -			.type = XEN_FW_EFI_INFO,
> -			.index = XEN_FW_EFI_CONFIG_TABLE
> -		}
> -	};
> -	union xenpf_efi_info *info = &op.u.firmware_info.u.efi_info;
> -
> -	if (!xen_initial_domain() || HYPERVISOR_platform_op(&op) < 0)
> -		return NULL;
> -
> -	/* Here we know that Xen runs on EFI platform. */
> -
> -	efi = efi_xen;
> -
> -	efi_systab_xen.tables = info->cfg.addr;
> -	efi_systab_xen.nr_tables = info->cfg.nent;
> -
> -	op.cmd = XENPF_firmware_info;
> -	op.u.firmware_info.type = XEN_FW_EFI_INFO;
> -	op.u.firmware_info.index = XEN_FW_EFI_VENDOR;
> -	info->vendor.bufsz = sizeof(vendor);
> -	set_xen_guest_handle(info->vendor.name, vendor);
> -
> -	if (HYPERVISOR_platform_op(&op) == 0) {
> -		efi_systab_xen.fw_vendor = __pa_symbol(vendor);
> -		efi_systab_xen.fw_revision = info->vendor.revision;
> -	} else
> -		efi_systab_xen.fw_vendor = __pa_symbol(L"UNKNOWN");
> -
> -	op.cmd = XENPF_firmware_info;
> -	op.u.firmware_info.type = XEN_FW_EFI_INFO;
> -	op.u.firmware_info.index = XEN_FW_EFI_VERSION;
> -
> -	if (HYPERVISOR_platform_op(&op) == 0)
> -		efi_systab_xen.hdr.revision = info->version;
> -
> -	op.cmd = XENPF_firmware_info;
> -	op.u.firmware_info.type = XEN_FW_EFI_INFO;
> -	op.u.firmware_info.index = XEN_FW_EFI_RT_VERSION;
> -
> -	if (HYPERVISOR_platform_op(&op) == 0)
> -		efi.runtime_version = info->version;
> -
> -	return &efi_systab_xen;
> -}
> +EXPORT_SYMBOL_GPL(xen_efi_query_capsule_caps);
> diff --git a/include/xen/xen-ops.h b/include/xen/xen-ops.h
> index 42be31a..c83a338 100644
> --- a/include/xen/xen-ops.h
> +++ b/include/xen/xen-ops.h
> @@ -85,14 +85,28 @@ int xen_xlate_map_ballooned_pages(xen_pfn_t **pfns, void **vaddr,
>  
>  bool xen_running_on_version_or_later(unsigned int major, unsigned int minor);
>  
> -#ifdef CONFIG_XEN_EFI
> -extern efi_system_table_t *xen_efi_probe(void);
> -#else
> -static inline efi_system_table_t __init *xen_efi_probe(void)
> -{
> -	return NULL;
> -}
> -#endif
> +efi_status_t xen_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc);
> +efi_status_t xen_efi_set_time(efi_time_t *tm);
> +efi_status_t xen_efi_get_wakeup_time(efi_bool_t *enabled, efi_bool_t *pending,
> +				     efi_time_t *tm);
> +efi_status_t xen_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm);
> +efi_status_t xen_efi_get_variable(efi_char16_t *name, efi_guid_t *vendor,
> +				  u32 *attr, unsigned long *data_size,
> +				  void *data);
> +efi_status_t xen_efi_get_next_variable(unsigned long *name_size,
> +				       efi_char16_t *name, efi_guid_t *vendor);
> +efi_status_t xen_efi_set_variable(efi_char16_t *name, efi_guid_t *vendor,
> +				  u32 attr, unsigned long data_size,
> +				  void *data);
> +efi_status_t xen_efi_query_variable_info(u32 attr, u64 *storage_space,
> +					 u64 *remaining_space,
> +					 u64 *max_variable_size);
> +efi_status_t xen_efi_get_next_high_mono_count(u32 *count);
> +efi_status_t xen_efi_update_capsule(efi_capsule_header_t **capsules,
> +				    unsigned long count, unsigned long sg_list);
> +efi_status_t xen_efi_query_capsule_caps(efi_capsule_header_t **capsules,
> +					unsigned long count, u64 *max_size,
> +					int *reset_type);
>  
>  #ifdef CONFIG_PREEMPT
>  
> -- 
> 2.0.4
> 
> 

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

* [PATCH v3 14/17] XEN: EFI: Move x86 specific codes to architecture directory
@ 2016-01-25 16:44     ` Stefano Stabellini
  0 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 16:44 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Move x86 specific codes to architecture directory and export those EFI
> runtime service functions. This will be useful for initializing runtime
> service on ARM later.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

This patch causes a build breakage on x86:

arch/x86/xen/efi.c: In function ?xen_efi_probe?:
arch/x86/xen/efi.c:101:2: error: implicit declaration of function ?HYPERVISOR_platform_op? [-Werror=implicit-function-declaration]



>  arch/x86/xen/efi.c    | 112 ++++++++++++++++++++++++++++++++
>  drivers/xen/efi.c     | 174 ++++++++++----------------------------------------
>  include/xen/xen-ops.h |  30 ++++++---
>  3 files changed, 168 insertions(+), 148 deletions(-)
> 
> diff --git a/arch/x86/xen/efi.c b/arch/x86/xen/efi.c
> index be14cc3..86527f1 100644
> --- a/arch/x86/xen/efi.c
> +++ b/arch/x86/xen/efi.c
> @@ -20,10 +20,122 @@
>  #include <linux/init.h>
>  #include <linux/string.h>
>  
> +#include <xen/xen.h>
>  #include <xen/xen-ops.h>
> +#include <xen/interface/platform.h>
>  
>  #include <asm/page.h>
>  #include <asm/setup.h>
> +#include <asm/xen/hypercall.h>
> +
> +static efi_char16_t vendor[100] __initdata;
> +
> +static efi_system_table_t efi_systab_xen __initdata = {
> +	.hdr = {
> +		.signature	= EFI_SYSTEM_TABLE_SIGNATURE,
> +		.revision	= 0, /* Initialized later. */
> +		.headersize	= 0, /* Ignored by Linux Kernel. */
> +		.crc32		= 0, /* Ignored by Linux Kernel. */
> +		.reserved	= 0
> +	},
> +	.fw_vendor	= EFI_INVALID_TABLE_ADDR, /* Initialized later. */
> +	.fw_revision	= 0,			  /* Initialized later. */
> +	.con_in_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> +	.con_in		= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> +	.con_out_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> +	.con_out	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> +	.stderr_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> +	.stderr		= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> +	.runtime	= (efi_runtime_services_t *)EFI_INVALID_TABLE_ADDR,
> +						  /* Not used under Xen. */
> +	.boottime	= (efi_boot_services_t *)EFI_INVALID_TABLE_ADDR,
> +						  /* Not used under Xen. */
> +	.nr_tables	= 0,			  /* Initialized later. */
> +	.tables		= EFI_INVALID_TABLE_ADDR  /* Initialized later. */
> +};
> +
> +static const struct efi efi_xen __initconst = {
> +	.systab                   = NULL, /* Initialized later. */
> +	.runtime_version	  = 0,    /* Initialized later. */
> +	.mps                      = EFI_INVALID_TABLE_ADDR,
> +	.acpi                     = EFI_INVALID_TABLE_ADDR,
> +	.acpi20                   = EFI_INVALID_TABLE_ADDR,
> +	.smbios                   = EFI_INVALID_TABLE_ADDR,
> +	.smbios3                  = EFI_INVALID_TABLE_ADDR,
> +	.sal_systab               = EFI_INVALID_TABLE_ADDR,
> +	.boot_info                = EFI_INVALID_TABLE_ADDR,
> +	.hcdp                     = EFI_INVALID_TABLE_ADDR,
> +	.uga                      = EFI_INVALID_TABLE_ADDR,
> +	.uv_systab                = EFI_INVALID_TABLE_ADDR,
> +	.fw_vendor                = EFI_INVALID_TABLE_ADDR,
> +	.runtime                  = EFI_INVALID_TABLE_ADDR,
> +	.config_table             = EFI_INVALID_TABLE_ADDR,
> +	.get_time                 = xen_efi_get_time,
> +	.set_time                 = xen_efi_set_time,
> +	.get_wakeup_time          = xen_efi_get_wakeup_time,
> +	.set_wakeup_time          = xen_efi_set_wakeup_time,
> +	.get_variable             = xen_efi_get_variable,
> +	.get_next_variable        = xen_efi_get_next_variable,
> +	.set_variable             = xen_efi_set_variable,
> +	.query_variable_info      = xen_efi_query_variable_info,
> +	.update_capsule           = xen_efi_update_capsule,
> +	.query_capsule_caps       = xen_efi_query_capsule_caps,
> +	.get_next_high_mono_count = xen_efi_get_next_high_mono_count,
> +	.reset_system             = NULL, /* Functionality provided by Xen. */
> +	.set_virtual_address_map  = NULL, /* Not used under Xen. */
> +	.memmap                   = NULL, /* Not used under Xen. */
> +	.flags			  = 0     /* Initialized later. */
> +};
> +
> +static efi_system_table_t __init *xen_efi_probe(void)
> +{
> +	struct xen_platform_op op = {
> +		.cmd = XENPF_firmware_info,
> +		.u.firmware_info = {
> +			.type = XEN_FW_EFI_INFO,
> +			.index = XEN_FW_EFI_CONFIG_TABLE
> +		}
> +	};
> +	union xenpf_efi_info *info = &op.u.firmware_info.u.efi_info;
> +
> +	if (!xen_initial_domain() || HYPERVISOR_platform_op(&op) < 0)
> +		return NULL;
> +
> +	/* Here we know that Xen runs on EFI platform. */
> +
> +	efi = efi_xen;
> +
> +	efi_systab_xen.tables = info->cfg.addr;
> +	efi_systab_xen.nr_tables = info->cfg.nent;
> +
> +	op.cmd = XENPF_firmware_info;
> +	op.u.firmware_info.type = XEN_FW_EFI_INFO;
> +	op.u.firmware_info.index = XEN_FW_EFI_VENDOR;
> +	info->vendor.bufsz = sizeof(vendor);
> +	set_xen_guest_handle(info->vendor.name, vendor);
> +
> +	if (HYPERVISOR_platform_op(&op) == 0) {
> +		efi_systab_xen.fw_vendor = __pa_symbol(vendor);
> +		efi_systab_xen.fw_revision = info->vendor.revision;
> +	} else
> +		efi_systab_xen.fw_vendor = __pa_symbol(L"UNKNOWN");
> +
> +	op.cmd = XENPF_firmware_info;
> +	op.u.firmware_info.type = XEN_FW_EFI_INFO;
> +	op.u.firmware_info.index = XEN_FW_EFI_VERSION;
> +
> +	if (HYPERVISOR_platform_op(&op) == 0)
> +		efi_systab_xen.hdr.revision = info->version;
> +
> +	op.cmd = XENPF_firmware_info;
> +	op.u.firmware_info.type = XEN_FW_EFI_INFO;
> +	op.u.firmware_info.index = XEN_FW_EFI_RT_VERSION;
> +
> +	if (HYPERVISOR_platform_op(&op) == 0)
> +		efi.runtime_version = info->version;
> +
> +	return &efi_systab_xen;
> +}
>  
>  void __init xen_efi_init(void)
>  {
> diff --git a/drivers/xen/efi.c b/drivers/xen/efi.c
> index be7e56a..22f71ff 100644
> --- a/drivers/xen/efi.c
> +++ b/drivers/xen/efi.c
> @@ -38,7 +38,7 @@
>  
>  #define efi_data(op)	(op.u.efi_runtime_call)
>  
> -static efi_status_t xen_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc)
> +efi_status_t xen_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(get_time);
>  
> @@ -59,8 +59,9 @@ static efi_status_t xen_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc)
>  
>  	return efi_data(op).status;
>  }
> +EXPORT_SYMBOL_GPL(xen_efi_get_time);
>  
> -static efi_status_t xen_efi_set_time(efi_time_t *tm)
> +efi_status_t xen_efi_set_time(efi_time_t *tm)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(set_time);
>  
> @@ -72,10 +73,10 @@ static efi_status_t xen_efi_set_time(efi_time_t *tm)
>  
>  	return efi_data(op).status;
>  }
> +EXPORT_SYMBOL_GPL(xen_efi_set_time);
>  
> -static efi_status_t xen_efi_get_wakeup_time(efi_bool_t *enabled,
> -					    efi_bool_t *pending,
> -					    efi_time_t *tm)
> +efi_status_t xen_efi_get_wakeup_time(efi_bool_t *enabled, efi_bool_t *pending,
> +				     efi_time_t *tm)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(get_wakeup_time);
>  
> @@ -95,8 +96,9 @@ static efi_status_t xen_efi_get_wakeup_time(efi_bool_t *enabled,
>  
>  	return efi_data(op).status;
>  }
> +EXPORT_SYMBOL_GPL(xen_efi_get_wakeup_time);
>  
> -static efi_status_t xen_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm)
> +efi_status_t xen_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(set_wakeup_time);
>  
> @@ -113,12 +115,11 @@ static efi_status_t xen_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm)
>  
>  	return efi_data(op).status;
>  }
> +EXPORT_SYMBOL_GPL(xen_efi_set_wakeup_time);
>  
> -static efi_status_t xen_efi_get_variable(efi_char16_t *name,
> -					 efi_guid_t *vendor,
> -					 u32 *attr,
> -					 unsigned long *data_size,
> -					 void *data)
> +efi_status_t xen_efi_get_variable(efi_char16_t *name, efi_guid_t *vendor,
> +				  u32 *attr, unsigned long *data_size,
> +				  void *data)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(get_variable);
>  
> @@ -138,10 +139,11 @@ static efi_status_t xen_efi_get_variable(efi_char16_t *name,
>  
>  	return efi_data(op).status;
>  }
> +EXPORT_SYMBOL_GPL(xen_efi_get_variable);
>  
> -static efi_status_t xen_efi_get_next_variable(unsigned long *name_size,
> -					      efi_char16_t *name,
> -					      efi_guid_t *vendor)
> +efi_status_t xen_efi_get_next_variable(unsigned long *name_size,
> +				       efi_char16_t *name,
> +				       efi_guid_t *vendor)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(get_next_variable_name);
>  
> @@ -161,12 +163,11 @@ static efi_status_t xen_efi_get_next_variable(unsigned long *name_size,
>  
>  	return efi_data(op).status;
>  }
> +EXPORT_SYMBOL_GPL(xen_efi_get_next_variable);
>  
> -static efi_status_t xen_efi_set_variable(efi_char16_t *name,
> -					 efi_guid_t *vendor,
> -					 u32 attr,
> -					 unsigned long data_size,
> -					 void *data)
> +efi_status_t xen_efi_set_variable(efi_char16_t *name, efi_guid_t *vendor,
> +				 u32 attr, unsigned long data_size,
> +				 void *data)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(set_variable);
>  
> @@ -183,11 +184,11 @@ static efi_status_t xen_efi_set_variable(efi_char16_t *name,
>  
>  	return efi_data(op).status;
>  }
> +EXPORT_SYMBOL_GPL(xen_efi_set_variable);
>  
> -static efi_status_t xen_efi_query_variable_info(u32 attr,
> -						u64 *storage_space,
> -						u64 *remaining_space,
> -						u64 *max_variable_size)
> +efi_status_t xen_efi_query_variable_info(u32 attr, u64 *storage_space,
> +					 u64 *remaining_space,
> +					 u64 *max_variable_size)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(query_variable_info);
>  
> @@ -205,8 +206,9 @@ static efi_status_t xen_efi_query_variable_info(u32 attr,
>  
>  	return efi_data(op).status;
>  }
> +EXPORT_SYMBOL_GPL(xen_efi_query_variable_info);
>  
> -static efi_status_t xen_efi_get_next_high_mono_count(u32 *count)
> +efi_status_t xen_efi_get_next_high_mono_count(u32 *count)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(get_next_high_monotonic_count);
>  
> @@ -217,10 +219,10 @@ static efi_status_t xen_efi_get_next_high_mono_count(u32 *count)
>  
>  	return efi_data(op).status;
>  }
> +EXPORT_SYMBOL_GPL(xen_efi_get_next_high_mono_count);
>  
> -static efi_status_t xen_efi_update_capsule(efi_capsule_header_t **capsules,
> -					   unsigned long count,
> -					   unsigned long sg_list)
> +efi_status_t xen_efi_update_capsule(efi_capsule_header_t **capsules,
> +				    unsigned long count, unsigned long sg_list)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(update_capsule);
>  
> @@ -237,11 +239,11 @@ static efi_status_t xen_efi_update_capsule(efi_capsule_header_t **capsules,
>  
>  	return efi_data(op).status;
>  }
> +EXPORT_SYMBOL_GPL(xen_efi_update_capsule);
>  
> -static efi_status_t xen_efi_query_capsule_caps(efi_capsule_header_t **capsules,
> -					       unsigned long count,
> -					       u64 *max_size,
> -					       int *reset_type)
> +efi_status_t xen_efi_query_capsule_caps(efi_capsule_header_t **capsules,
> +					unsigned long count, u64 *max_size,
> +					int *reset_type)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(query_capsule_capabilities);
>  
> @@ -260,112 +262,4 @@ static efi_status_t xen_efi_query_capsule_caps(efi_capsule_header_t **capsules,
>  
>  	return efi_data(op).status;
>  }
> -
> -static efi_char16_t vendor[100] __initdata;
> -
> -static efi_system_table_t efi_systab_xen __initdata = {
> -	.hdr = {
> -		.signature	= EFI_SYSTEM_TABLE_SIGNATURE,
> -		.revision	= 0, /* Initialized later. */
> -		.headersize	= 0, /* Ignored by Linux Kernel. */
> -		.crc32		= 0, /* Ignored by Linux Kernel. */
> -		.reserved	= 0
> -	},
> -	.fw_vendor	= EFI_INVALID_TABLE_ADDR, /* Initialized later. */
> -	.fw_revision	= 0,			  /* Initialized later. */
> -	.con_in_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> -	.con_in		= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> -	.con_out_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> -	.con_out	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> -	.stderr_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> -	.stderr		= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> -	.runtime	= (efi_runtime_services_t *)EFI_INVALID_TABLE_ADDR,
> -						  /* Not used under Xen. */
> -	.boottime	= (efi_boot_services_t *)EFI_INVALID_TABLE_ADDR,
> -						  /* Not used under Xen. */
> -	.nr_tables	= 0,			  /* Initialized later. */
> -	.tables		= EFI_INVALID_TABLE_ADDR  /* Initialized later. */
> -};
> -
> -static const struct efi efi_xen __initconst = {
> -	.systab                   = NULL, /* Initialized later. */
> -	.runtime_version	  = 0,    /* Initialized later. */
> -	.mps                      = EFI_INVALID_TABLE_ADDR,
> -	.acpi                     = EFI_INVALID_TABLE_ADDR,
> -	.acpi20                   = EFI_INVALID_TABLE_ADDR,
> -	.smbios                   = EFI_INVALID_TABLE_ADDR,
> -	.smbios3                  = EFI_INVALID_TABLE_ADDR,
> -	.sal_systab               = EFI_INVALID_TABLE_ADDR,
> -	.boot_info                = EFI_INVALID_TABLE_ADDR,
> -	.hcdp                     = EFI_INVALID_TABLE_ADDR,
> -	.uga                      = EFI_INVALID_TABLE_ADDR,
> -	.uv_systab                = EFI_INVALID_TABLE_ADDR,
> -	.fw_vendor                = EFI_INVALID_TABLE_ADDR,
> -	.runtime                  = EFI_INVALID_TABLE_ADDR,
> -	.config_table             = EFI_INVALID_TABLE_ADDR,
> -	.get_time                 = xen_efi_get_time,
> -	.set_time                 = xen_efi_set_time,
> -	.get_wakeup_time          = xen_efi_get_wakeup_time,
> -	.set_wakeup_time          = xen_efi_set_wakeup_time,
> -	.get_variable             = xen_efi_get_variable,
> -	.get_next_variable        = xen_efi_get_next_variable,
> -	.set_variable             = xen_efi_set_variable,
> -	.query_variable_info      = xen_efi_query_variable_info,
> -	.update_capsule           = xen_efi_update_capsule,
> -	.query_capsule_caps       = xen_efi_query_capsule_caps,
> -	.get_next_high_mono_count = xen_efi_get_next_high_mono_count,
> -	.reset_system             = NULL, /* Functionality provided by Xen. */
> -	.set_virtual_address_map  = NULL, /* Not used under Xen. */
> -	.memmap                   = NULL, /* Not used under Xen. */
> -	.flags			  = 0     /* Initialized later. */
> -};
> -
> -efi_system_table_t __init *xen_efi_probe(void)
> -{
> -	struct xen_platform_op op = {
> -		.cmd = XENPF_firmware_info,
> -		.u.firmware_info = {
> -			.type = XEN_FW_EFI_INFO,
> -			.index = XEN_FW_EFI_CONFIG_TABLE
> -		}
> -	};
> -	union xenpf_efi_info *info = &op.u.firmware_info.u.efi_info;
> -
> -	if (!xen_initial_domain() || HYPERVISOR_platform_op(&op) < 0)
> -		return NULL;
> -
> -	/* Here we know that Xen runs on EFI platform. */
> -
> -	efi = efi_xen;
> -
> -	efi_systab_xen.tables = info->cfg.addr;
> -	efi_systab_xen.nr_tables = info->cfg.nent;
> -
> -	op.cmd = XENPF_firmware_info;
> -	op.u.firmware_info.type = XEN_FW_EFI_INFO;
> -	op.u.firmware_info.index = XEN_FW_EFI_VENDOR;
> -	info->vendor.bufsz = sizeof(vendor);
> -	set_xen_guest_handle(info->vendor.name, vendor);
> -
> -	if (HYPERVISOR_platform_op(&op) == 0) {
> -		efi_systab_xen.fw_vendor = __pa_symbol(vendor);
> -		efi_systab_xen.fw_revision = info->vendor.revision;
> -	} else
> -		efi_systab_xen.fw_vendor = __pa_symbol(L"UNKNOWN");
> -
> -	op.cmd = XENPF_firmware_info;
> -	op.u.firmware_info.type = XEN_FW_EFI_INFO;
> -	op.u.firmware_info.index = XEN_FW_EFI_VERSION;
> -
> -	if (HYPERVISOR_platform_op(&op) == 0)
> -		efi_systab_xen.hdr.revision = info->version;
> -
> -	op.cmd = XENPF_firmware_info;
> -	op.u.firmware_info.type = XEN_FW_EFI_INFO;
> -	op.u.firmware_info.index = XEN_FW_EFI_RT_VERSION;
> -
> -	if (HYPERVISOR_platform_op(&op) == 0)
> -		efi.runtime_version = info->version;
> -
> -	return &efi_systab_xen;
> -}
> +EXPORT_SYMBOL_GPL(xen_efi_query_capsule_caps);
> diff --git a/include/xen/xen-ops.h b/include/xen/xen-ops.h
> index 42be31a..c83a338 100644
> --- a/include/xen/xen-ops.h
> +++ b/include/xen/xen-ops.h
> @@ -85,14 +85,28 @@ int xen_xlate_map_ballooned_pages(xen_pfn_t **pfns, void **vaddr,
>  
>  bool xen_running_on_version_or_later(unsigned int major, unsigned int minor);
>  
> -#ifdef CONFIG_XEN_EFI
> -extern efi_system_table_t *xen_efi_probe(void);
> -#else
> -static inline efi_system_table_t __init *xen_efi_probe(void)
> -{
> -	return NULL;
> -}
> -#endif
> +efi_status_t xen_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc);
> +efi_status_t xen_efi_set_time(efi_time_t *tm);
> +efi_status_t xen_efi_get_wakeup_time(efi_bool_t *enabled, efi_bool_t *pending,
> +				     efi_time_t *tm);
> +efi_status_t xen_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm);
> +efi_status_t xen_efi_get_variable(efi_char16_t *name, efi_guid_t *vendor,
> +				  u32 *attr, unsigned long *data_size,
> +				  void *data);
> +efi_status_t xen_efi_get_next_variable(unsigned long *name_size,
> +				       efi_char16_t *name, efi_guid_t *vendor);
> +efi_status_t xen_efi_set_variable(efi_char16_t *name, efi_guid_t *vendor,
> +				  u32 attr, unsigned long data_size,
> +				  void *data);
> +efi_status_t xen_efi_query_variable_info(u32 attr, u64 *storage_space,
> +					 u64 *remaining_space,
> +					 u64 *max_variable_size);
> +efi_status_t xen_efi_get_next_high_mono_count(u32 *count);
> +efi_status_t xen_efi_update_capsule(efi_capsule_header_t **capsules,
> +				    unsigned long count, unsigned long sg_list);
> +efi_status_t xen_efi_query_capsule_caps(efi_capsule_header_t **capsules,
> +					unsigned long count, u64 *max_size,
> +					int *reset_type);
>  
>  #ifdef CONFIG_PREEMPT
>  
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v3 14/17] XEN: EFI: Move x86 specific codes to architecture directory
  2016-01-23  3:19   ` Shannon Zhao
                     ` (2 preceding siblings ...)
  (?)
@ 2016-01-25 16:44   ` Stefano Stabellini
  -1 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 16:44 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: mark.rutland, devicetree, linux-efi, ian.campbell,
	ard.biesheuvel, catalin.marinas, will.deacon, linux-kernel,
	xen-devel, julien.grall, stefano.stabellini, david.vrabel,
	peter.huangpeng, linux-arm-kernel, shannon.zhao

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

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
>
> Move x86 specific codes to architecture directory and export those EFI
> runtime service functions. This will be useful for initializing runtime
> service on ARM later.
>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

This patch causes a build breakage on x86:

arch/x86/xen/efi.c: In function ‘xen_efi_probe’:
arch/x86/xen/efi.c:101:2: error: implicit declaration of function ‘HYPERVISOR_platform_op’ [-Werror=implicit-function-declaration]



>  arch/x86/xen/efi.c    | 112 ++++++++++++++++++++++++++++++++
>  drivers/xen/efi.c     | 174 ++++++++++----------------------------------------
>  include/xen/xen-ops.h |  30 ++++++---
>  3 files changed, 168 insertions(+), 148 deletions(-)
>
> diff --git a/arch/x86/xen/efi.c b/arch/x86/xen/efi.c
> index be14cc3..86527f1 100644
> --- a/arch/x86/xen/efi.c
> +++ b/arch/x86/xen/efi.c
> @@ -20,10 +20,122 @@
>  #include <linux/init.h>
>  #include <linux/string.h>
>
> +#include <xen/xen.h>
>  #include <xen/xen-ops.h>
> +#include <xen/interface/platform.h>
>
>  #include <asm/page.h>
>  #include <asm/setup.h>
> +#include <asm/xen/hypercall.h>
> +
> +static efi_char16_t vendor[100] __initdata;
> +
> +static efi_system_table_t efi_systab_xen __initdata = {
> +	.hdr = {
> +		.signature	= EFI_SYSTEM_TABLE_SIGNATURE,
> +		.revision	= 0, /* Initialized later. */
> +		.headersize	= 0, /* Ignored by Linux Kernel. */
> +		.crc32		= 0, /* Ignored by Linux Kernel. */
> +		.reserved	= 0
> +	},
> +	.fw_vendor	= EFI_INVALID_TABLE_ADDR, /* Initialized later. */
> +	.fw_revision	= 0,			  /* Initialized later. */
> +	.con_in_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> +	.con_in		= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> +	.con_out_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> +	.con_out	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> +	.stderr_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> +	.stderr		= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> +	.runtime	= (efi_runtime_services_t *)EFI_INVALID_TABLE_ADDR,
> +						  /* Not used under Xen. */
> +	.boottime	= (efi_boot_services_t *)EFI_INVALID_TABLE_ADDR,
> +						  /* Not used under Xen. */
> +	.nr_tables	= 0,			  /* Initialized later. */
> +	.tables		= EFI_INVALID_TABLE_ADDR  /* Initialized later. */
> +};
> +
> +static const struct efi efi_xen __initconst = {
> +	.systab                   = NULL, /* Initialized later. */
> +	.runtime_version	  = 0,    /* Initialized later. */
> +	.mps                      = EFI_INVALID_TABLE_ADDR,
> +	.acpi                     = EFI_INVALID_TABLE_ADDR,
> +	.acpi20                   = EFI_INVALID_TABLE_ADDR,
> +	.smbios                   = EFI_INVALID_TABLE_ADDR,
> +	.smbios3                  = EFI_INVALID_TABLE_ADDR,
> +	.sal_systab               = EFI_INVALID_TABLE_ADDR,
> +	.boot_info                = EFI_INVALID_TABLE_ADDR,
> +	.hcdp                     = EFI_INVALID_TABLE_ADDR,
> +	.uga                      = EFI_INVALID_TABLE_ADDR,
> +	.uv_systab                = EFI_INVALID_TABLE_ADDR,
> +	.fw_vendor                = EFI_INVALID_TABLE_ADDR,
> +	.runtime                  = EFI_INVALID_TABLE_ADDR,
> +	.config_table             = EFI_INVALID_TABLE_ADDR,
> +	.get_time                 = xen_efi_get_time,
> +	.set_time                 = xen_efi_set_time,
> +	.get_wakeup_time          = xen_efi_get_wakeup_time,
> +	.set_wakeup_time          = xen_efi_set_wakeup_time,
> +	.get_variable             = xen_efi_get_variable,
> +	.get_next_variable        = xen_efi_get_next_variable,
> +	.set_variable             = xen_efi_set_variable,
> +	.query_variable_info      = xen_efi_query_variable_info,
> +	.update_capsule           = xen_efi_update_capsule,
> +	.query_capsule_caps       = xen_efi_query_capsule_caps,
> +	.get_next_high_mono_count = xen_efi_get_next_high_mono_count,
> +	.reset_system             = NULL, /* Functionality provided by Xen. */
> +	.set_virtual_address_map  = NULL, /* Not used under Xen. */
> +	.memmap                   = NULL, /* Not used under Xen. */
> +	.flags			  = 0     /* Initialized later. */
> +};
> +
> +static efi_system_table_t __init *xen_efi_probe(void)
> +{
> +	struct xen_platform_op op = {
> +		.cmd = XENPF_firmware_info,
> +		.u.firmware_info = {
> +			.type = XEN_FW_EFI_INFO,
> +			.index = XEN_FW_EFI_CONFIG_TABLE
> +		}
> +	};
> +	union xenpf_efi_info *info = &op.u.firmware_info.u.efi_info;
> +
> +	if (!xen_initial_domain() || HYPERVISOR_platform_op(&op) < 0)
> +		return NULL;
> +
> +	/* Here we know that Xen runs on EFI platform. */
> +
> +	efi = efi_xen;
> +
> +	efi_systab_xen.tables = info->cfg.addr;
> +	efi_systab_xen.nr_tables = info->cfg.nent;
> +
> +	op.cmd = XENPF_firmware_info;
> +	op.u.firmware_info.type = XEN_FW_EFI_INFO;
> +	op.u.firmware_info.index = XEN_FW_EFI_VENDOR;
> +	info->vendor.bufsz = sizeof(vendor);
> +	set_xen_guest_handle(info->vendor.name, vendor);
> +
> +	if (HYPERVISOR_platform_op(&op) == 0) {
> +		efi_systab_xen.fw_vendor = __pa_symbol(vendor);
> +		efi_systab_xen.fw_revision = info->vendor.revision;
> +	} else
> +		efi_systab_xen.fw_vendor = __pa_symbol(L"UNKNOWN");
> +
> +	op.cmd = XENPF_firmware_info;
> +	op.u.firmware_info.type = XEN_FW_EFI_INFO;
> +	op.u.firmware_info.index = XEN_FW_EFI_VERSION;
> +
> +	if (HYPERVISOR_platform_op(&op) == 0)
> +		efi_systab_xen.hdr.revision = info->version;
> +
> +	op.cmd = XENPF_firmware_info;
> +	op.u.firmware_info.type = XEN_FW_EFI_INFO;
> +	op.u.firmware_info.index = XEN_FW_EFI_RT_VERSION;
> +
> +	if (HYPERVISOR_platform_op(&op) == 0)
> +		efi.runtime_version = info->version;
> +
> +	return &efi_systab_xen;
> +}
>
>  void __init xen_efi_init(void)
>  {
> diff --git a/drivers/xen/efi.c b/drivers/xen/efi.c
> index be7e56a..22f71ff 100644
> --- a/drivers/xen/efi.c
> +++ b/drivers/xen/efi.c
> @@ -38,7 +38,7 @@
>
>  #define efi_data(op)	(op.u.efi_runtime_call)
>
> -static efi_status_t xen_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc)
> +efi_status_t xen_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(get_time);
>
> @@ -59,8 +59,9 @@ static efi_status_t xen_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc)
>
>  	return efi_data(op).status;
>  }
> +EXPORT_SYMBOL_GPL(xen_efi_get_time);
>
> -static efi_status_t xen_efi_set_time(efi_time_t *tm)
> +efi_status_t xen_efi_set_time(efi_time_t *tm)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(set_time);
>
> @@ -72,10 +73,10 @@ static efi_status_t xen_efi_set_time(efi_time_t *tm)
>
>  	return efi_data(op).status;
>  }
> +EXPORT_SYMBOL_GPL(xen_efi_set_time);
>
> -static efi_status_t xen_efi_get_wakeup_time(efi_bool_t *enabled,
> -					    efi_bool_t *pending,
> -					    efi_time_t *tm)
> +efi_status_t xen_efi_get_wakeup_time(efi_bool_t *enabled, efi_bool_t *pending,
> +				     efi_time_t *tm)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(get_wakeup_time);
>
> @@ -95,8 +96,9 @@ static efi_status_t xen_efi_get_wakeup_time(efi_bool_t *enabled,
>
>  	return efi_data(op).status;
>  }
> +EXPORT_SYMBOL_GPL(xen_efi_get_wakeup_time);
>
> -static efi_status_t xen_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm)
> +efi_status_t xen_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(set_wakeup_time);
>
> @@ -113,12 +115,11 @@ static efi_status_t xen_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm)
>
>  	return efi_data(op).status;
>  }
> +EXPORT_SYMBOL_GPL(xen_efi_set_wakeup_time);
>
> -static efi_status_t xen_efi_get_variable(efi_char16_t *name,
> -					 efi_guid_t *vendor,
> -					 u32 *attr,
> -					 unsigned long *data_size,
> -					 void *data)
> +efi_status_t xen_efi_get_variable(efi_char16_t *name, efi_guid_t *vendor,
> +				  u32 *attr, unsigned long *data_size,
> +				  void *data)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(get_variable);
>
> @@ -138,10 +139,11 @@ static efi_status_t xen_efi_get_variable(efi_char16_t *name,
>
>  	return efi_data(op).status;
>  }
> +EXPORT_SYMBOL_GPL(xen_efi_get_variable);
>
> -static efi_status_t xen_efi_get_next_variable(unsigned long *name_size,
> -					      efi_char16_t *name,
> -					      efi_guid_t *vendor)
> +efi_status_t xen_efi_get_next_variable(unsigned long *name_size,
> +				       efi_char16_t *name,
> +				       efi_guid_t *vendor)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(get_next_variable_name);
>
> @@ -161,12 +163,11 @@ static efi_status_t xen_efi_get_next_variable(unsigned long *name_size,
>
>  	return efi_data(op).status;
>  }
> +EXPORT_SYMBOL_GPL(xen_efi_get_next_variable);
>
> -static efi_status_t xen_efi_set_variable(efi_char16_t *name,
> -					 efi_guid_t *vendor,
> -					 u32 attr,
> -					 unsigned long data_size,
> -					 void *data)
> +efi_status_t xen_efi_set_variable(efi_char16_t *name, efi_guid_t *vendor,
> +				 u32 attr, unsigned long data_size,
> +				 void *data)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(set_variable);
>
> @@ -183,11 +184,11 @@ static efi_status_t xen_efi_set_variable(efi_char16_t *name,
>
>  	return efi_data(op).status;
>  }
> +EXPORT_SYMBOL_GPL(xen_efi_set_variable);
>
> -static efi_status_t xen_efi_query_variable_info(u32 attr,
> -						u64 *storage_space,
> -						u64 *remaining_space,
> -						u64 *max_variable_size)
> +efi_status_t xen_efi_query_variable_info(u32 attr, u64 *storage_space,
> +					 u64 *remaining_space,
> +					 u64 *max_variable_size)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(query_variable_info);
>
> @@ -205,8 +206,9 @@ static efi_status_t xen_efi_query_variable_info(u32 attr,
>
>  	return efi_data(op).status;
>  }
> +EXPORT_SYMBOL_GPL(xen_efi_query_variable_info);
>
> -static efi_status_t xen_efi_get_next_high_mono_count(u32 *count)
> +efi_status_t xen_efi_get_next_high_mono_count(u32 *count)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(get_next_high_monotonic_count);
>
> @@ -217,10 +219,10 @@ static efi_status_t xen_efi_get_next_high_mono_count(u32 *count)
>
>  	return efi_data(op).status;
>  }
> +EXPORT_SYMBOL_GPL(xen_efi_get_next_high_mono_count);
>
> -static efi_status_t xen_efi_update_capsule(efi_capsule_header_t **capsules,
> -					   unsigned long count,
> -					   unsigned long sg_list)
> +efi_status_t xen_efi_update_capsule(efi_capsule_header_t **capsules,
> +				    unsigned long count, unsigned long sg_list)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(update_capsule);
>
> @@ -237,11 +239,11 @@ static efi_status_t xen_efi_update_capsule(efi_capsule_header_t **capsules,
>
>  	return efi_data(op).status;
>  }
> +EXPORT_SYMBOL_GPL(xen_efi_update_capsule);
>
> -static efi_status_t xen_efi_query_capsule_caps(efi_capsule_header_t **capsules,
> -					       unsigned long count,
> -					       u64 *max_size,
> -					       int *reset_type)
> +efi_status_t xen_efi_query_capsule_caps(efi_capsule_header_t **capsules,
> +					unsigned long count, u64 *max_size,
> +					int *reset_type)
>  {
>  	struct xen_platform_op op = INIT_EFI_OP(query_capsule_capabilities);
>
> @@ -260,112 +262,4 @@ static efi_status_t xen_efi_query_capsule_caps(efi_capsule_header_t **capsules,
>
>  	return efi_data(op).status;
>  }
> -
> -static efi_char16_t vendor[100] __initdata;
> -
> -static efi_system_table_t efi_systab_xen __initdata = {
> -	.hdr = {
> -		.signature	= EFI_SYSTEM_TABLE_SIGNATURE,
> -		.revision	= 0, /* Initialized later. */
> -		.headersize	= 0, /* Ignored by Linux Kernel. */
> -		.crc32		= 0, /* Ignored by Linux Kernel. */
> -		.reserved	= 0
> -	},
> -	.fw_vendor	= EFI_INVALID_TABLE_ADDR, /* Initialized later. */
> -	.fw_revision	= 0,			  /* Initialized later. */
> -	.con_in_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> -	.con_in		= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> -	.con_out_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> -	.con_out	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> -	.stderr_handle	= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> -	.stderr		= EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
> -	.runtime	= (efi_runtime_services_t *)EFI_INVALID_TABLE_ADDR,
> -						  /* Not used under Xen. */
> -	.boottime	= (efi_boot_services_t *)EFI_INVALID_TABLE_ADDR,
> -						  /* Not used under Xen. */
> -	.nr_tables	= 0,			  /* Initialized later. */
> -	.tables		= EFI_INVALID_TABLE_ADDR  /* Initialized later. */
> -};
> -
> -static const struct efi efi_xen __initconst = {
> -	.systab                   = NULL, /* Initialized later. */
> -	.runtime_version	  = 0,    /* Initialized later. */
> -	.mps                      = EFI_INVALID_TABLE_ADDR,
> -	.acpi                     = EFI_INVALID_TABLE_ADDR,
> -	.acpi20                   = EFI_INVALID_TABLE_ADDR,
> -	.smbios                   = EFI_INVALID_TABLE_ADDR,
> -	.smbios3                  = EFI_INVALID_TABLE_ADDR,
> -	.sal_systab               = EFI_INVALID_TABLE_ADDR,
> -	.boot_info                = EFI_INVALID_TABLE_ADDR,
> -	.hcdp                     = EFI_INVALID_TABLE_ADDR,
> -	.uga                      = EFI_INVALID_TABLE_ADDR,
> -	.uv_systab                = EFI_INVALID_TABLE_ADDR,
> -	.fw_vendor                = EFI_INVALID_TABLE_ADDR,
> -	.runtime                  = EFI_INVALID_TABLE_ADDR,
> -	.config_table             = EFI_INVALID_TABLE_ADDR,
> -	.get_time                 = xen_efi_get_time,
> -	.set_time                 = xen_efi_set_time,
> -	.get_wakeup_time          = xen_efi_get_wakeup_time,
> -	.set_wakeup_time          = xen_efi_set_wakeup_time,
> -	.get_variable             = xen_efi_get_variable,
> -	.get_next_variable        = xen_efi_get_next_variable,
> -	.set_variable             = xen_efi_set_variable,
> -	.query_variable_info      = xen_efi_query_variable_info,
> -	.update_capsule           = xen_efi_update_capsule,
> -	.query_capsule_caps       = xen_efi_query_capsule_caps,
> -	.get_next_high_mono_count = xen_efi_get_next_high_mono_count,
> -	.reset_system             = NULL, /* Functionality provided by Xen. */
> -	.set_virtual_address_map  = NULL, /* Not used under Xen. */
> -	.memmap                   = NULL, /* Not used under Xen. */
> -	.flags			  = 0     /* Initialized later. */
> -};
> -
> -efi_system_table_t __init *xen_efi_probe(void)
> -{
> -	struct xen_platform_op op = {
> -		.cmd = XENPF_firmware_info,
> -		.u.firmware_info = {
> -			.type = XEN_FW_EFI_INFO,
> -			.index = XEN_FW_EFI_CONFIG_TABLE
> -		}
> -	};
> -	union xenpf_efi_info *info = &op.u.firmware_info.u.efi_info;
> -
> -	if (!xen_initial_domain() || HYPERVISOR_platform_op(&op) < 0)
> -		return NULL;
> -
> -	/* Here we know that Xen runs on EFI platform. */
> -
> -	efi = efi_xen;
> -
> -	efi_systab_xen.tables = info->cfg.addr;
> -	efi_systab_xen.nr_tables = info->cfg.nent;
> -
> -	op.cmd = XENPF_firmware_info;
> -	op.u.firmware_info.type = XEN_FW_EFI_INFO;
> -	op.u.firmware_info.index = XEN_FW_EFI_VENDOR;
> -	info->vendor.bufsz = sizeof(vendor);
> -	set_xen_guest_handle(info->vendor.name, vendor);
> -
> -	if (HYPERVISOR_platform_op(&op) == 0) {
> -		efi_systab_xen.fw_vendor = __pa_symbol(vendor);
> -		efi_systab_xen.fw_revision = info->vendor.revision;
> -	} else
> -		efi_systab_xen.fw_vendor = __pa_symbol(L"UNKNOWN");
> -
> -	op.cmd = XENPF_firmware_info;
> -	op.u.firmware_info.type = XEN_FW_EFI_INFO;
> -	op.u.firmware_info.index = XEN_FW_EFI_VERSION;
> -
> -	if (HYPERVISOR_platform_op(&op) == 0)
> -		efi_systab_xen.hdr.revision = info->version;
> -
> -	op.cmd = XENPF_firmware_info;
> -	op.u.firmware_info.type = XEN_FW_EFI_INFO;
> -	op.u.firmware_info.index = XEN_FW_EFI_RT_VERSION;
> -
> -	if (HYPERVISOR_platform_op(&op) == 0)
> -		efi.runtime_version = info->version;
> -
> -	return &efi_systab_xen;
> -}
> +EXPORT_SYMBOL_GPL(xen_efi_query_capsule_caps);
> diff --git a/include/xen/xen-ops.h b/include/xen/xen-ops.h
> index 42be31a..c83a338 100644
> --- a/include/xen/xen-ops.h
> +++ b/include/xen/xen-ops.h
> @@ -85,14 +85,28 @@ int xen_xlate_map_ballooned_pages(xen_pfn_t **pfns, void **vaddr,
>
>  bool xen_running_on_version_or_later(unsigned int major, unsigned int minor);
>
> -#ifdef CONFIG_XEN_EFI
> -extern efi_system_table_t *xen_efi_probe(void);
> -#else
> -static inline efi_system_table_t __init *xen_efi_probe(void)
> -{
> -	return NULL;
> -}
> -#endif
> +efi_status_t xen_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc);
> +efi_status_t xen_efi_set_time(efi_time_t *tm);
> +efi_status_t xen_efi_get_wakeup_time(efi_bool_t *enabled, efi_bool_t *pending,
> +				     efi_time_t *tm);
> +efi_status_t xen_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm);
> +efi_status_t xen_efi_get_variable(efi_char16_t *name, efi_guid_t *vendor,
> +				  u32 *attr, unsigned long *data_size,
> +				  void *data);
> +efi_status_t xen_efi_get_next_variable(unsigned long *name_size,
> +				       efi_char16_t *name, efi_guid_t *vendor);
> +efi_status_t xen_efi_set_variable(efi_char16_t *name, efi_guid_t *vendor,
> +				  u32 attr, unsigned long data_size,
> +				  void *data);
> +efi_status_t xen_efi_query_variable_info(u32 attr, u64 *storage_space,
> +					 u64 *remaining_space,
> +					 u64 *max_variable_size);
> +efi_status_t xen_efi_get_next_high_mono_count(u32 *count);
> +efi_status_t xen_efi_update_capsule(efi_capsule_header_t **capsules,
> +				    unsigned long count, unsigned long sg_list);
> +efi_status_t xen_efi_query_capsule_caps(efi_capsule_header_t **capsules,
> +					unsigned long count, u64 *max_size,
> +					int *reset_type);
>
>  #ifdef CONFIG_PREEMPT
>
> --
> 2.0.4
>
> 

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

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

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

* Re: [PATCH v3 15/17] ARM64: XEN: Add a function to initialize Xen specific UEFI runtime services
@ 2016-01-25 16:47     ` Stefano Stabellini
  0 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 16:47 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel, catalin.marinas, will.deacon,
	julien.grall, xen-devel, devicetree, linux-efi, linux-kernel,
	ian.campbell, shannon.zhao, peter.huangpeng

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> When running on Xen hypervisor, runtime services are supported through
> hypercall. Add a Xen specific function to initialize runtime services.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  arch/arm64/include/asm/xen/xen-ops.h |  6 ++++++
>  arch/arm64/xen/Makefile              |  1 +
>  arch/arm64/xen/efi.c                 | 40 ++++++++++++++++++++++++++++++++++++
>  drivers/xen/Kconfig                  |  2 +-
>  4 files changed, 48 insertions(+), 1 deletion(-)
>  create mode 100644 arch/arm64/include/asm/xen/xen-ops.h
>  create mode 100644 arch/arm64/xen/efi.c
> 
> diff --git a/arch/arm64/include/asm/xen/xen-ops.h b/arch/arm64/include/asm/xen/xen-ops.h
> new file mode 100644
> index 0000000..ec154e7
> --- /dev/null
> +++ b/arch/arm64/include/asm/xen/xen-ops.h
> @@ -0,0 +1,6 @@
> +#ifndef _ASM_XEN_OPS_H
> +#define _ASM_XEN_OPS_H
> +
> +void xen_efi_runtime_setup(void);
> +
> +#endif /* _ASM_XEN_OPS_H */
> diff --git a/arch/arm64/xen/Makefile b/arch/arm64/xen/Makefile
> index 74a8d87..62e6fe2 100644
> --- a/arch/arm64/xen/Makefile
> +++ b/arch/arm64/xen/Makefile
> @@ -1,2 +1,3 @@
>  xen-arm-y	+= $(addprefix ../../arm/xen/, enlighten.o grant-table.o p2m.o mm.o)
>  obj-y		:= xen-arm.o hypercall.o
> +obj-$(CONFIG_XEN_EFI) += efi.o
> diff --git a/arch/arm64/xen/efi.c b/arch/arm64/xen/efi.c
> new file mode 100644
> index 0000000..b9cae65
> --- /dev/null
> +++ b/arch/arm64/xen/efi.c
> @@ -0,0 +1,40 @@
> +/*
> + * Copyright (c) 2015, Linaro Limited, Shannon Zhao
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License along
> + * with this program.  If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#include <linux/efi.h>
> +#include <xen/xen-ops.h>
> +#include <asm/xen/xen-ops.h>
> +
> +/* Set XEN EFI runtime services function pointers. Other fileds of struct efi,
                                                              ^ fields

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


> + * e.g. efi.systab, will be set like normal EFI.
> + */
> +void __init xen_efi_runtime_setup(void)
> +{
> +	efi.get_time                 = xen_efi_get_time;
> +	efi.set_time                 = xen_efi_set_time;
> +	efi.get_wakeup_time          = xen_efi_get_wakeup_time;
> +	efi.set_wakeup_time          = xen_efi_set_wakeup_time;
> +	efi.get_variable             = xen_efi_get_variable;
> +	efi.get_next_variable        = xen_efi_get_next_variable;
> +	efi.set_variable             = xen_efi_set_variable;
> +	efi.query_variable_info      = xen_efi_query_variable_info;
> +	efi.update_capsule           = xen_efi_update_capsule;
> +	efi.query_capsule_caps       = xen_efi_query_capsule_caps;
> +	efi.get_next_high_mono_count = xen_efi_get_next_high_mono_count;
> +	efi.reset_system             = NULL; /* Functionality provided by Xen. */
> +}
> +EXPORT_SYMBOL_GPL(xen_efi_runtime_setup);
> diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig
> index 73708ac..27d216a 100644
> --- a/drivers/xen/Kconfig
> +++ b/drivers/xen/Kconfig
> @@ -268,7 +268,7 @@ config XEN_HAVE_PVMMU
>  
>  config XEN_EFI
>  	def_bool y
> -	depends on X86_64 && EFI
> +	depends on (ARM64 || X86_64) && EFI
>  
>  config XEN_AUTO_XLATE
>  	def_bool y
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v3 15/17] ARM64: XEN: Add a function to initialize Xen specific UEFI runtime services
@ 2016-01-25 16:47     ` Stefano Stabellini
  0 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 16:47 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	stefano.stabellini-Sxgqhf6Nn4DQT0dZR+AlfA,
	david.vrabel-Sxgqhf6Nn4DQT0dZR+AlfA, catalin.marinas-5wv7dgnIgG8,
	will.deacon-5wv7dgnIgG8, julien.grall-Sxgqhf6Nn4DQT0dZR+AlfA,
	xen-devel-GuqFBffKawuEi8DpZVb4nw,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-efi-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	ian.campbell-Sxgqhf6Nn4DQT0dZR+AlfA,
	shannon.zhao-QSEj5FYQhm4dnm+yROfE0A,
	peter.huangpeng-hv44wF8Li93QT0dZR+AlfA

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> 
> When running on Xen hypervisor, runtime services are supported through
> hypercall. Add a Xen specific function to initialize runtime services.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> ---
>  arch/arm64/include/asm/xen/xen-ops.h |  6 ++++++
>  arch/arm64/xen/Makefile              |  1 +
>  arch/arm64/xen/efi.c                 | 40 ++++++++++++++++++++++++++++++++++++
>  drivers/xen/Kconfig                  |  2 +-
>  4 files changed, 48 insertions(+), 1 deletion(-)
>  create mode 100644 arch/arm64/include/asm/xen/xen-ops.h
>  create mode 100644 arch/arm64/xen/efi.c
> 
> diff --git a/arch/arm64/include/asm/xen/xen-ops.h b/arch/arm64/include/asm/xen/xen-ops.h
> new file mode 100644
> index 0000000..ec154e7
> --- /dev/null
> +++ b/arch/arm64/include/asm/xen/xen-ops.h
> @@ -0,0 +1,6 @@
> +#ifndef _ASM_XEN_OPS_H
> +#define _ASM_XEN_OPS_H
> +
> +void xen_efi_runtime_setup(void);
> +
> +#endif /* _ASM_XEN_OPS_H */
> diff --git a/arch/arm64/xen/Makefile b/arch/arm64/xen/Makefile
> index 74a8d87..62e6fe2 100644
> --- a/arch/arm64/xen/Makefile
> +++ b/arch/arm64/xen/Makefile
> @@ -1,2 +1,3 @@
>  xen-arm-y	+= $(addprefix ../../arm/xen/, enlighten.o grant-table.o p2m.o mm.o)
>  obj-y		:= xen-arm.o hypercall.o
> +obj-$(CONFIG_XEN_EFI) += efi.o
> diff --git a/arch/arm64/xen/efi.c b/arch/arm64/xen/efi.c
> new file mode 100644
> index 0000000..b9cae65
> --- /dev/null
> +++ b/arch/arm64/xen/efi.c
> @@ -0,0 +1,40 @@
> +/*
> + * Copyright (c) 2015, Linaro Limited, Shannon Zhao
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License along
> + * with this program.  If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#include <linux/efi.h>
> +#include <xen/xen-ops.h>
> +#include <asm/xen/xen-ops.h>
> +
> +/* Set XEN EFI runtime services function pointers. Other fileds of struct efi,
                                                              ^ fields

Reviewed-by: Stefano Stabellini <stefano.stabellini-mvvWK6WmYclDPfheJLI6IQ@public.gmane.org>


> + * e.g. efi.systab, will be set like normal EFI.
> + */
> +void __init xen_efi_runtime_setup(void)
> +{
> +	efi.get_time                 = xen_efi_get_time;
> +	efi.set_time                 = xen_efi_set_time;
> +	efi.get_wakeup_time          = xen_efi_get_wakeup_time;
> +	efi.set_wakeup_time          = xen_efi_set_wakeup_time;
> +	efi.get_variable             = xen_efi_get_variable;
> +	efi.get_next_variable        = xen_efi_get_next_variable;
> +	efi.set_variable             = xen_efi_set_variable;
> +	efi.query_variable_info      = xen_efi_query_variable_info;
> +	efi.update_capsule           = xen_efi_update_capsule;
> +	efi.query_capsule_caps       = xen_efi_query_capsule_caps;
> +	efi.get_next_high_mono_count = xen_efi_get_next_high_mono_count;
> +	efi.reset_system             = NULL; /* Functionality provided by Xen. */
> +}
> +EXPORT_SYMBOL_GPL(xen_efi_runtime_setup);
> diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig
> index 73708ac..27d216a 100644
> --- a/drivers/xen/Kconfig
> +++ b/drivers/xen/Kconfig
> @@ -268,7 +268,7 @@ config XEN_HAVE_PVMMU
>  
>  config XEN_EFI
>  	def_bool y
> -	depends on X86_64 && EFI
> +	depends on (ARM64 || X86_64) && EFI
>  
>  config XEN_AUTO_XLATE
>  	def_bool y
> -- 
> 2.0.4
> 
> 

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

* [PATCH v3 15/17] ARM64: XEN: Add a function to initialize Xen specific UEFI runtime services
@ 2016-01-25 16:47     ` Stefano Stabellini
  0 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 16:47 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> When running on Xen hypervisor, runtime services are supported through
> hypercall. Add a Xen specific function to initialize runtime services.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  arch/arm64/include/asm/xen/xen-ops.h |  6 ++++++
>  arch/arm64/xen/Makefile              |  1 +
>  arch/arm64/xen/efi.c                 | 40 ++++++++++++++++++++++++++++++++++++
>  drivers/xen/Kconfig                  |  2 +-
>  4 files changed, 48 insertions(+), 1 deletion(-)
>  create mode 100644 arch/arm64/include/asm/xen/xen-ops.h
>  create mode 100644 arch/arm64/xen/efi.c
> 
> diff --git a/arch/arm64/include/asm/xen/xen-ops.h b/arch/arm64/include/asm/xen/xen-ops.h
> new file mode 100644
> index 0000000..ec154e7
> --- /dev/null
> +++ b/arch/arm64/include/asm/xen/xen-ops.h
> @@ -0,0 +1,6 @@
> +#ifndef _ASM_XEN_OPS_H
> +#define _ASM_XEN_OPS_H
> +
> +void xen_efi_runtime_setup(void);
> +
> +#endif /* _ASM_XEN_OPS_H */
> diff --git a/arch/arm64/xen/Makefile b/arch/arm64/xen/Makefile
> index 74a8d87..62e6fe2 100644
> --- a/arch/arm64/xen/Makefile
> +++ b/arch/arm64/xen/Makefile
> @@ -1,2 +1,3 @@
>  xen-arm-y	+= $(addprefix ../../arm/xen/, enlighten.o grant-table.o p2m.o mm.o)
>  obj-y		:= xen-arm.o hypercall.o
> +obj-$(CONFIG_XEN_EFI) += efi.o
> diff --git a/arch/arm64/xen/efi.c b/arch/arm64/xen/efi.c
> new file mode 100644
> index 0000000..b9cae65
> --- /dev/null
> +++ b/arch/arm64/xen/efi.c
> @@ -0,0 +1,40 @@
> +/*
> + * Copyright (c) 2015, Linaro Limited, Shannon Zhao
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License along
> + * with this program.  If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#include <linux/efi.h>
> +#include <xen/xen-ops.h>
> +#include <asm/xen/xen-ops.h>
> +
> +/* Set XEN EFI runtime services function pointers. Other fileds of struct efi,
                                                              ^ fields

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


> + * e.g. efi.systab, will be set like normal EFI.
> + */
> +void __init xen_efi_runtime_setup(void)
> +{
> +	efi.get_time                 = xen_efi_get_time;
> +	efi.set_time                 = xen_efi_set_time;
> +	efi.get_wakeup_time          = xen_efi_get_wakeup_time;
> +	efi.set_wakeup_time          = xen_efi_set_wakeup_time;
> +	efi.get_variable             = xen_efi_get_variable;
> +	efi.get_next_variable        = xen_efi_get_next_variable;
> +	efi.set_variable             = xen_efi_set_variable;
> +	efi.query_variable_info      = xen_efi_query_variable_info;
> +	efi.update_capsule           = xen_efi_update_capsule;
> +	efi.query_capsule_caps       = xen_efi_query_capsule_caps;
> +	efi.get_next_high_mono_count = xen_efi_get_next_high_mono_count;
> +	efi.reset_system             = NULL; /* Functionality provided by Xen. */
> +}
> +EXPORT_SYMBOL_GPL(xen_efi_runtime_setup);
> diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig
> index 73708ac..27d216a 100644
> --- a/drivers/xen/Kconfig
> +++ b/drivers/xen/Kconfig
> @@ -268,7 +268,7 @@ config XEN_HAVE_PVMMU
>  
>  config XEN_EFI
>  	def_bool y
> -	depends on X86_64 && EFI
> +	depends on (ARM64 || X86_64) && EFI
>  
>  config XEN_AUTO_XLATE
>  	def_bool y
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v3 15/17] ARM64: XEN: Add a function to initialize Xen specific UEFI runtime services
  2016-01-23  3:19   ` Shannon Zhao
  (?)
  (?)
@ 2016-01-25 16:47   ` Stefano Stabellini
  -1 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-25 16:47 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: mark.rutland, devicetree, linux-efi, ian.campbell,
	ard.biesheuvel, catalin.marinas, will.deacon, linux-kernel,
	xen-devel, julien.grall, stefano.stabellini, david.vrabel,
	peter.huangpeng, linux-arm-kernel, shannon.zhao

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> When running on Xen hypervisor, runtime services are supported through
> hypercall. Add a Xen specific function to initialize runtime services.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  arch/arm64/include/asm/xen/xen-ops.h |  6 ++++++
>  arch/arm64/xen/Makefile              |  1 +
>  arch/arm64/xen/efi.c                 | 40 ++++++++++++++++++++++++++++++++++++
>  drivers/xen/Kconfig                  |  2 +-
>  4 files changed, 48 insertions(+), 1 deletion(-)
>  create mode 100644 arch/arm64/include/asm/xen/xen-ops.h
>  create mode 100644 arch/arm64/xen/efi.c
> 
> diff --git a/arch/arm64/include/asm/xen/xen-ops.h b/arch/arm64/include/asm/xen/xen-ops.h
> new file mode 100644
> index 0000000..ec154e7
> --- /dev/null
> +++ b/arch/arm64/include/asm/xen/xen-ops.h
> @@ -0,0 +1,6 @@
> +#ifndef _ASM_XEN_OPS_H
> +#define _ASM_XEN_OPS_H
> +
> +void xen_efi_runtime_setup(void);
> +
> +#endif /* _ASM_XEN_OPS_H */
> diff --git a/arch/arm64/xen/Makefile b/arch/arm64/xen/Makefile
> index 74a8d87..62e6fe2 100644
> --- a/arch/arm64/xen/Makefile
> +++ b/arch/arm64/xen/Makefile
> @@ -1,2 +1,3 @@
>  xen-arm-y	+= $(addprefix ../../arm/xen/, enlighten.o grant-table.o p2m.o mm.o)
>  obj-y		:= xen-arm.o hypercall.o
> +obj-$(CONFIG_XEN_EFI) += efi.o
> diff --git a/arch/arm64/xen/efi.c b/arch/arm64/xen/efi.c
> new file mode 100644
> index 0000000..b9cae65
> --- /dev/null
> +++ b/arch/arm64/xen/efi.c
> @@ -0,0 +1,40 @@
> +/*
> + * Copyright (c) 2015, Linaro Limited, Shannon Zhao
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License along
> + * with this program.  If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#include <linux/efi.h>
> +#include <xen/xen-ops.h>
> +#include <asm/xen/xen-ops.h>
> +
> +/* Set XEN EFI runtime services function pointers. Other fileds of struct efi,
                                                              ^ fields

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


> + * e.g. efi.systab, will be set like normal EFI.
> + */
> +void __init xen_efi_runtime_setup(void)
> +{
> +	efi.get_time                 = xen_efi_get_time;
> +	efi.set_time                 = xen_efi_set_time;
> +	efi.get_wakeup_time          = xen_efi_get_wakeup_time;
> +	efi.set_wakeup_time          = xen_efi_set_wakeup_time;
> +	efi.get_variable             = xen_efi_get_variable;
> +	efi.get_next_variable        = xen_efi_get_next_variable;
> +	efi.set_variable             = xen_efi_set_variable;
> +	efi.query_variable_info      = xen_efi_query_variable_info;
> +	efi.update_capsule           = xen_efi_update_capsule;
> +	efi.query_capsule_caps       = xen_efi_query_capsule_caps;
> +	efi.get_next_high_mono_count = xen_efi_get_next_high_mono_count;
> +	efi.reset_system             = NULL; /* Functionality provided by Xen. */
> +}
> +EXPORT_SYMBOL_GPL(xen_efi_runtime_setup);
> diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig
> index 73708ac..27d216a 100644
> --- a/drivers/xen/Kconfig
> +++ b/drivers/xen/Kconfig
> @@ -268,7 +268,7 @@ config XEN_HAVE_PVMMU
>  
>  config XEN_EFI
>  	def_bool y
> -	depends on X86_64 && EFI
> +	depends on (ARM64 || X86_64) && EFI
>  
>  config XEN_AUTO_XLATE
>  	def_bool y
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v3 14/17] XEN: EFI: Move x86 specific codes to architecture directory
  2016-01-25 16:44     ` Stefano Stabellini
  (?)
@ 2016-01-26  8:16       ` Shannon Zhao
  -1 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-26  8:16 UTC (permalink / raw)
  To: Stefano Stabellini
  Cc: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel, catalin.marinas, will.deacon,
	julien.grall, xen-devel, devicetree, linux-efi, linux-kernel,
	ian.campbell, shannon.zhao, peter.huangpeng



On 2016/1/26 0:44, Stefano Stabellini wrote:
> On Sat, 23 Jan 2016, Shannon Zhao wrote:
>> > From: Shannon Zhao <shannon.zhao@linaro.org>
>> > 
>> > Move x86 specific codes to architecture directory and export those EFI
>> > runtime service functions. This will be useful for initializing runtime
>> > service on ARM later.
>> > 
>> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> This patch causes a build breakage on x86:
> 
> arch/x86/xen/efi.c: In function ‘xen_efi_probe’:
> arch/x86/xen/efi.c:101:2: error: implicit declaration of function ‘HYPERVISOR_platform_op’ [-Werror=implicit-function-declaration]
> 
This patch is based on following patch [1]. Maybe you need to update
your branch. :)

[1] xen: rename dom0_op to platform_op
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=cfafae940381207d48b11a73a211142dba5947d3

-- 
Shannon

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

* Re: [PATCH v3 14/17] XEN: EFI: Move x86 specific codes to architecture directory
@ 2016-01-26  8:16       ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-26  8:16 UTC (permalink / raw)
  To: Stefano Stabellini
  Cc: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel, catalin.marinas, will.deacon,
	julien.grall, xen-devel, devicetree, linux-efi, linux-kernel,
	ian.campbell, shannon.zhao, peter.huangpeng



On 2016/1/26 0:44, Stefano Stabellini wrote:
> On Sat, 23 Jan 2016, Shannon Zhao wrote:
>> > From: Shannon Zhao <shannon.zhao@linaro.org>
>> > 
>> > Move x86 specific codes to architecture directory and export those EFI
>> > runtime service functions. This will be useful for initializing runtime
>> > service on ARM later.
>> > 
>> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> This patch causes a build breakage on x86:
> 
> arch/x86/xen/efi.c: In function ‘xen_efi_probe’:
> arch/x86/xen/efi.c:101:2: error: implicit declaration of function ‘HYPERVISOR_platform_op’ [-Werror=implicit-function-declaration]
> 
This patch is based on following patch [1]. Maybe you need to update
your branch. :)

[1] xen: rename dom0_op to platform_op
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=cfafae940381207d48b11a73a211142dba5947d3

-- 
Shannon

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

* [PATCH v3 14/17] XEN: EFI: Move x86 specific codes to architecture directory
@ 2016-01-26  8:16       ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-26  8:16 UTC (permalink / raw)
  To: linux-arm-kernel



On 2016/1/26 0:44, Stefano Stabellini wrote:
> On Sat, 23 Jan 2016, Shannon Zhao wrote:
>> > From: Shannon Zhao <shannon.zhao@linaro.org>
>> > 
>> > Move x86 specific codes to architecture directory and export those EFI
>> > runtime service functions. This will be useful for initializing runtime
>> > service on ARM later.
>> > 
>> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> This patch causes a build breakage on x86:
> 
> arch/x86/xen/efi.c: In function ?xen_efi_probe?:
> arch/x86/xen/efi.c:101:2: error: implicit declaration of function ?HYPERVISOR_platform_op? [-Werror=implicit-function-declaration]
> 
This patch is based on following patch [1]. Maybe you need to update
your branch. :)

[1] xen: rename dom0_op to platform_op
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=cfafae940381207d48b11a73a211142dba5947d3

-- 
Shannon

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

* Re: [PATCH v3 14/17] XEN: EFI: Move x86 specific codes to architecture directory
  2016-01-25 16:44     ` Stefano Stabellini
  (?)
  (?)
@ 2016-01-26  8:16     ` Shannon Zhao
  -1 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-26  8:16 UTC (permalink / raw)
  To: Stefano Stabellini
  Cc: mark.rutland, devicetree, linux-efi, ian.campbell,
	ard.biesheuvel, catalin.marinas, will.deacon, linux-kernel,
	xen-devel, julien.grall, stefano.stabellini, david.vrabel,
	peter.huangpeng, linux-arm-kernel, shannon.zhao



On 2016/1/26 0:44, Stefano Stabellini wrote:
> On Sat, 23 Jan 2016, Shannon Zhao wrote:
>> > From: Shannon Zhao <shannon.zhao@linaro.org>
>> > 
>> > Move x86 specific codes to architecture directory and export those EFI
>> > runtime service functions. This will be useful for initializing runtime
>> > service on ARM later.
>> > 
>> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> This patch causes a build breakage on x86:
> 
> arch/x86/xen/efi.c: In function ‘xen_efi_probe’:
> arch/x86/xen/efi.c:101:2: error: implicit declaration of function ‘HYPERVISOR_platform_op’ [-Werror=implicit-function-declaration]
> 
This patch is based on following patch [1]. Maybe you need to update
your branch. :)

[1] xen: rename dom0_op to platform_op
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=cfafae940381207d48b11a73a211142dba5947d3

-- 
Shannon


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

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

* Re: [PATCH v3 14/17] XEN: EFI: Move x86 specific codes to architecture directory
  2016-01-26  8:16       ` Shannon Zhao
  (?)
@ 2016-01-26 11:31         ` Stefano Stabellini
  -1 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-26 11:31 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: Stefano Stabellini, linux-arm-kernel, ard.biesheuvel,
	mark.rutland, stefano.stabellini, david.vrabel, catalin.marinas,
	will.deacon, julien.grall, xen-devel, devicetree, linux-efi,
	linux-kernel, ian.campbell, shannon.zhao, peter.huangpeng

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

On Tue, 26 Jan 2016, Shannon Zhao wrote:
> On 2016/1/26 0:44, Stefano Stabellini wrote:
> > On Sat, 23 Jan 2016, Shannon Zhao wrote:
> >> > From: Shannon Zhao <shannon.zhao@linaro.org>
> >> > 
> >> > Move x86 specific codes to architecture directory and export those EFI
> >> > runtime service functions. This will be useful for initializing runtime
> >> > service on ARM later.
> >> > 
> >> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> > This patch causes a build breakage on x86:
> > 
> > arch/x86/xen/efi.c: In function ‘xen_efi_probe’:
> > arch/x86/xen/efi.c:101:2: error: implicit declaration of function ‘HYPERVISOR_platform_op’ [-Werror=implicit-function-declaration]
> > 
> This patch is based on following patch [1]. Maybe you need to update
> your branch. :)
> 
> [1] xen: rename dom0_op to platform_op
> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=cfafae940381207d48b11a73a211142dba5947d3

Sorry, I made a mistake rebasing the series. It doesn't help that I
couldn't find any Linux RCs on top of which it applies cleanly. As Linus
tags RCs often enough, it is usually helpful to base one's work on a tag
so that it is easier for other people to work on it.

Please add my Reviewed-by to this patch.

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

* Re: [PATCH v3 14/17] XEN: EFI: Move x86 specific codes to architecture directory
@ 2016-01-26 11:31         ` Stefano Stabellini
  0 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-26 11:31 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: Stefano Stabellini, linux-arm-kernel, ard.biesheuvel,
	mark.rutland, stefano.stabellini, david.vrabel, catalin.marinas,
	will.deacon, julien.grall, xen-devel, devicetree, linux-efi,
	linux-kernel, ian.campbell, shannon.zhao, peter.huangpeng

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

On Tue, 26 Jan 2016, Shannon Zhao wrote:
> On 2016/1/26 0:44, Stefano Stabellini wrote:
> > On Sat, 23 Jan 2016, Shannon Zhao wrote:
> >> > From: Shannon Zhao <shannon.zhao@linaro.org>
> >> > 
> >> > Move x86 specific codes to architecture directory and export those EFI
> >> > runtime service functions. This will be useful for initializing runtime
> >> > service on ARM later.
> >> > 
> >> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> > This patch causes a build breakage on x86:
> > 
> > arch/x86/xen/efi.c: In function ‘xen_efi_probe’:
> > arch/x86/xen/efi.c:101:2: error: implicit declaration of function ‘HYPERVISOR_platform_op’ [-Werror=implicit-function-declaration]
> > 
> This patch is based on following patch [1]. Maybe you need to update
> your branch. :)
> 
> [1] xen: rename dom0_op to platform_op
> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=cfafae940381207d48b11a73a211142dba5947d3

Sorry, I made a mistake rebasing the series. It doesn't help that I
couldn't find any Linux RCs on top of which it applies cleanly. As Linus
tags RCs often enough, it is usually helpful to base one's work on a tag
so that it is easier for other people to work on it.

Please add my Reviewed-by to this patch.

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

* [PATCH v3 14/17] XEN: EFI: Move x86 specific codes to architecture directory
@ 2016-01-26 11:31         ` Stefano Stabellini
  0 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-26 11:31 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, 26 Jan 2016, Shannon Zhao wrote:
> On 2016/1/26 0:44, Stefano Stabellini wrote:
> > On Sat, 23 Jan 2016, Shannon Zhao wrote:
> >> > From: Shannon Zhao <shannon.zhao@linaro.org>
> >> > 
> >> > Move x86 specific codes to architecture directory and export those EFI
> >> > runtime service functions. This will be useful for initializing runtime
> >> > service on ARM later.
> >> > 
> >> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> > This patch causes a build breakage on x86:
> > 
> > arch/x86/xen/efi.c: In function ?xen_efi_probe?:
> > arch/x86/xen/efi.c:101:2: error: implicit declaration of function ?HYPERVISOR_platform_op? [-Werror=implicit-function-declaration]
> > 
> This patch is based on following patch [1]. Maybe you need to update
> your branch. :)
> 
> [1] xen: rename dom0_op to platform_op
> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=cfafae940381207d48b11a73a211142dba5947d3

Sorry, I made a mistake rebasing the series. It doesn't help that I
couldn't find any Linux RCs on top of which it applies cleanly. As Linus
tags RCs often enough, it is usually helpful to base one's work on a tag
so that it is easier for other people to work on it.

Please add my Reviewed-by to this patch.

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

* Re: [PATCH v3 14/17] XEN: EFI: Move x86 specific codes to architecture directory
  2016-01-26  8:16       ` Shannon Zhao
                         ` (2 preceding siblings ...)
  (?)
@ 2016-01-26 11:31       ` Stefano Stabellini
  -1 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-26 11:31 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: mark.rutland, devicetree, linux-efi, ian.campbell,
	ard.biesheuvel, catalin.marinas, Stefano Stabellini, will.deacon,
	linux-kernel, xen-devel, julien.grall, stefano.stabellini,
	david.vrabel, peter.huangpeng, linux-arm-kernel, shannon.zhao

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

On Tue, 26 Jan 2016, Shannon Zhao wrote:
> On 2016/1/26 0:44, Stefano Stabellini wrote:
> > On Sat, 23 Jan 2016, Shannon Zhao wrote:
> >> > From: Shannon Zhao <shannon.zhao@linaro.org>
> >> >
> >> > Move x86 specific codes to architecture directory and export those EFI
> >> > runtime service functions. This will be useful for initializing runtime
> >> > service on ARM later.
> >> >
> >> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> > This patch causes a build breakage on x86:
> >
> > arch/x86/xen/efi.c: In function ‘xen_efi_probe’:
> > arch/x86/xen/efi.c:101:2: error: implicit declaration of function ‘HYPERVISOR_platform_op’ [-Werror=implicit-function-declaration]
> >
> This patch is based on following patch [1]. Maybe you need to update
> your branch. :)
>
> [1] xen: rename dom0_op to platform_op
> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=cfafae940381207d48b11a73a211142dba5947d3

Sorry, I made a mistake rebasing the series. It doesn't help that I
couldn't find any Linux RCs on top of which it applies cleanly. As Linus
tags RCs often enough, it is usually helpful to base one's work on a tag
so that it is easier for other people to work on it.

Please add my Reviewed-by to this patch.

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

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

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

* Re: [PATCH v3 17/17] Xen: EFI: Parse DT parameters for Xen specific UEFI
  2016-01-23  3:19   ` Shannon Zhao
  (?)
@ 2016-01-26 11:41     ` Stefano Stabellini
  -1 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-26 11:41 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel, catalin.marinas, will.deacon,
	julien.grall, xen-devel, devicetree, linux-efi, linux-kernel,
	ian.campbell, shannon.zhao, peter.huangpeng, Matt Fleming

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Add a new function to parse DT parameters for Xen specific UEFI just
> like the way for normal UEFI. Then it could reuse the existing codes.
> 
> If Xen supports EFI, initialize runtime services.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

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


> CC: Matt Fleming <matt@codeblueprint.co.uk>
> ---
>  arch/arm/xen/enlighten.c   |  6 ++++++
>  arch/arm64/kernel/efi.c    | 17 ++++++++++++-----
>  drivers/firmware/efi/efi.c | 45 ++++++++++++++++++++++++++++++++++++++-------
>  3 files changed, 56 insertions(+), 12 deletions(-)
> 
> diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
> index cdc0bd2..608d735 100644
> --- a/arch/arm/xen/enlighten.c
> +++ b/arch/arm/xen/enlighten.c
> @@ -245,6 +245,12 @@ static int __init fdt_find_hyper_node(unsigned long node, const char *uname,
>  	    !strncmp(hyper_node.prefix, s, strlen(hyper_node.prefix)))
>  		hyper_node.version = s + strlen(hyper_node.prefix);
>  
> +	if (IS_ENABLED(CONFIG_XEN_EFI)) {
> +		/* Check if Xen supports EFI */
> +		if (of_get_flat_dt_subnode_by_name(node, "uefi") > 0)
> +			set_bit(EFI_PARAVIRT, &efi.flags);
> +	}
> +
>  	return 0;
>  }
>  
> diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c
> index 4eeb171..3c46129 100644
> --- a/arch/arm64/kernel/efi.c
> +++ b/arch/arm64/kernel/efi.c
> @@ -33,6 +33,7 @@
>  #include <asm/mmu_context.h>
>  #include <asm/mmu.h>
>  #include <asm/pgtable.h>
> +#include <asm/xen/xen-ops.h>
>  
>  struct efi_memory_map memmap;
>  
> @@ -308,13 +309,19 @@ static int __init arm64_enable_runtime_services(void)
>  	}
>  	set_bit(EFI_SYSTEM_TABLES, &efi.flags);
>  
> -	if (!efi_virtmap_init()) {
> -		pr_err("No UEFI virtual mapping was installed -- runtime services will not be available\n");
> -		return -ENOMEM;
> +	if (IS_ENABLED(CONFIG_XEN_EFI) && efi_enabled(EFI_PARAVIRT)) {
> +		/* Set up runtime services function pointers for Xen Dom0 */
> +		xen_efi_runtime_setup();
> +	} else {
> +		if (!efi_virtmap_init()) {
> +			pr_err("No UEFI virtual mapping was installed -- runtime services will not be available\n");
> +			return -ENOMEM;
> +		}
> +
> +		/* Set up runtime services function pointers */
> +		efi_native_runtime_setup();
>  	}
>  
> -	/* Set up runtime services function pointers */
> -	efi_native_runtime_setup();
>  	set_bit(EFI_RUNTIME_SERVICES, &efi.flags);
>  
>  	efi.runtime_version = efi.systab->hdr.revision;
> diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
> index 027ca21..bdcf6d7 100644
> --- a/drivers/firmware/efi/efi.c
> +++ b/drivers/firmware/efi/efi.c
> @@ -498,12 +498,14 @@ device_initcall(efi_load_efivars);
>  		FIELD_SIZEOF(struct efi_fdt_params, field) \
>  	}
>  
> -static __initdata struct {
> +struct params {
>  	const char name[32];
>  	const char propname[32];
>  	int offset;
>  	int size;
> -} dt_params[] = {
> +};
> +
> +static struct params fdt_params[] __initdata = {
>  	UEFI_PARAM("System Table", "linux,uefi-system-table", system_table),
>  	UEFI_PARAM("MemMap Address", "linux,uefi-mmap-start", mmap),
>  	UEFI_PARAM("MemMap Size", "linux,uefi-mmap-size", mmap_size),
> @@ -511,24 +513,45 @@ static __initdata struct {
>  	UEFI_PARAM("MemMap Desc. Version", "linux,uefi-mmap-desc-ver", desc_ver)
>  };
>  
> +static struct params xen_fdt_params[] __initdata = {
> +	UEFI_PARAM("System Table", "xen,uefi-system-table", system_table),
> +	UEFI_PARAM("MemMap Address", "xen,uefi-mmap-start", mmap),
> +	UEFI_PARAM("MemMap Size", "xen,uefi-mmap-size", mmap_size),
> +	UEFI_PARAM("MemMap Desc. Size", "xen,uefi-mmap-desc-size", desc_size),
> +	UEFI_PARAM("MemMap Desc. Version", "xen,uefi-mmap-desc-ver", desc_ver)
> +};
> +
>  struct param_info {
>  	int found;
>  	void *params;
> +	struct params *dt_params;
> +	int size;
>  };
>  
>  static int __init fdt_find_uefi_params(unsigned long node, const char *uname,
>  				       int depth, void *data)
>  {
>  	struct param_info *info = data;
> +	struct params *dt_params = info->dt_params;
>  	const void *prop;
>  	void *dest;
>  	u64 val;
> -	int i, len;
> +	int i, len, offset;
>  
> -	if (depth != 1 || strcmp(uname, "chosen") != 0)
> -		return 0;
> +	if (efi_enabled(EFI_PARAVIRT)) {
> +		if (depth != 1 || strcmp(uname, "hypervisor") != 0)
> +			return 0;
>  
> -	for (i = 0; i < ARRAY_SIZE(dt_params); i++) {
> +		offset = of_get_flat_dt_subnode_by_name(node, "uefi");
> +		if (offset < 0)
> +			return 0;
> +		node = offset;
> +	} else {
> +		if (depth != 1 || strcmp(uname, "chosen") != 0)
> +			return 0;
> +	}
> +
> +	for (i = 0; i < info->size; i++) {
>  		prop = of_get_flat_dt_prop(node, dt_params[i].propname, &len);
>  		if (!prop)
>  			return 0;
> @@ -559,12 +582,20 @@ int __init efi_get_fdt_params(struct efi_fdt_params *params)
>  	info.found = 0;
>  	info.params = params;
>  
> +	if (efi_enabled(EFI_PARAVIRT)) {
> +		info.dt_params = xen_fdt_params;
> +		info.size = ARRAY_SIZE(xen_fdt_params);
> +	} else {
> +		info.dt_params = fdt_params;
> +		info.size = ARRAY_SIZE(fdt_params);
> +	}
> +
>  	ret = of_scan_flat_dt(fdt_find_uefi_params, &info);
>  	if (!info.found)
>  		pr_info("UEFI not found.\n");
>  	else if (!ret)
>  		pr_err("Can't find '%s' in device tree!\n",
> -		       dt_params[info.found].name);
> +		       info.dt_params[info.found].name);
>  
>  	return ret;
>  }
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v3 17/17] Xen: EFI: Parse DT parameters for Xen specific UEFI
@ 2016-01-26 11:41     ` Stefano Stabellini
  0 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-26 11:41 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel, catalin.marinas, will.deacon,
	julien.grall, xen-devel, devicetree, linux-efi, linux-kernel,
	ian.campbell, shannon.zhao, peter.huangpeng, Matt Fleming

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Add a new function to parse DT parameters for Xen specific UEFI just
> like the way for normal UEFI. Then it could reuse the existing codes.
> 
> If Xen supports EFI, initialize runtime services.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

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


> CC: Matt Fleming <matt@codeblueprint.co.uk>
> ---
>  arch/arm/xen/enlighten.c   |  6 ++++++
>  arch/arm64/kernel/efi.c    | 17 ++++++++++++-----
>  drivers/firmware/efi/efi.c | 45 ++++++++++++++++++++++++++++++++++++++-------
>  3 files changed, 56 insertions(+), 12 deletions(-)
> 
> diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
> index cdc0bd2..608d735 100644
> --- a/arch/arm/xen/enlighten.c
> +++ b/arch/arm/xen/enlighten.c
> @@ -245,6 +245,12 @@ static int __init fdt_find_hyper_node(unsigned long node, const char *uname,
>  	    !strncmp(hyper_node.prefix, s, strlen(hyper_node.prefix)))
>  		hyper_node.version = s + strlen(hyper_node.prefix);
>  
> +	if (IS_ENABLED(CONFIG_XEN_EFI)) {
> +		/* Check if Xen supports EFI */
> +		if (of_get_flat_dt_subnode_by_name(node, "uefi") > 0)
> +			set_bit(EFI_PARAVIRT, &efi.flags);
> +	}
> +
>  	return 0;
>  }
>  
> diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c
> index 4eeb171..3c46129 100644
> --- a/arch/arm64/kernel/efi.c
> +++ b/arch/arm64/kernel/efi.c
> @@ -33,6 +33,7 @@
>  #include <asm/mmu_context.h>
>  #include <asm/mmu.h>
>  #include <asm/pgtable.h>
> +#include <asm/xen/xen-ops.h>
>  
>  struct efi_memory_map memmap;
>  
> @@ -308,13 +309,19 @@ static int __init arm64_enable_runtime_services(void)
>  	}
>  	set_bit(EFI_SYSTEM_TABLES, &efi.flags);
>  
> -	if (!efi_virtmap_init()) {
> -		pr_err("No UEFI virtual mapping was installed -- runtime services will not be available\n");
> -		return -ENOMEM;
> +	if (IS_ENABLED(CONFIG_XEN_EFI) && efi_enabled(EFI_PARAVIRT)) {
> +		/* Set up runtime services function pointers for Xen Dom0 */
> +		xen_efi_runtime_setup();
> +	} else {
> +		if (!efi_virtmap_init()) {
> +			pr_err("No UEFI virtual mapping was installed -- runtime services will not be available\n");
> +			return -ENOMEM;
> +		}
> +
> +		/* Set up runtime services function pointers */
> +		efi_native_runtime_setup();
>  	}
>  
> -	/* Set up runtime services function pointers */
> -	efi_native_runtime_setup();
>  	set_bit(EFI_RUNTIME_SERVICES, &efi.flags);
>  
>  	efi.runtime_version = efi.systab->hdr.revision;
> diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
> index 027ca21..bdcf6d7 100644
> --- a/drivers/firmware/efi/efi.c
> +++ b/drivers/firmware/efi/efi.c
> @@ -498,12 +498,14 @@ device_initcall(efi_load_efivars);
>  		FIELD_SIZEOF(struct efi_fdt_params, field) \
>  	}
>  
> -static __initdata struct {
> +struct params {
>  	const char name[32];
>  	const char propname[32];
>  	int offset;
>  	int size;
> -} dt_params[] = {
> +};
> +
> +static struct params fdt_params[] __initdata = {
>  	UEFI_PARAM("System Table", "linux,uefi-system-table", system_table),
>  	UEFI_PARAM("MemMap Address", "linux,uefi-mmap-start", mmap),
>  	UEFI_PARAM("MemMap Size", "linux,uefi-mmap-size", mmap_size),
> @@ -511,24 +513,45 @@ static __initdata struct {
>  	UEFI_PARAM("MemMap Desc. Version", "linux,uefi-mmap-desc-ver", desc_ver)
>  };
>  
> +static struct params xen_fdt_params[] __initdata = {
> +	UEFI_PARAM("System Table", "xen,uefi-system-table", system_table),
> +	UEFI_PARAM("MemMap Address", "xen,uefi-mmap-start", mmap),
> +	UEFI_PARAM("MemMap Size", "xen,uefi-mmap-size", mmap_size),
> +	UEFI_PARAM("MemMap Desc. Size", "xen,uefi-mmap-desc-size", desc_size),
> +	UEFI_PARAM("MemMap Desc. Version", "xen,uefi-mmap-desc-ver", desc_ver)
> +};
> +
>  struct param_info {
>  	int found;
>  	void *params;
> +	struct params *dt_params;
> +	int size;
>  };
>  
>  static int __init fdt_find_uefi_params(unsigned long node, const char *uname,
>  				       int depth, void *data)
>  {
>  	struct param_info *info = data;
> +	struct params *dt_params = info->dt_params;
>  	const void *prop;
>  	void *dest;
>  	u64 val;
> -	int i, len;
> +	int i, len, offset;
>  
> -	if (depth != 1 || strcmp(uname, "chosen") != 0)
> -		return 0;
> +	if (efi_enabled(EFI_PARAVIRT)) {
> +		if (depth != 1 || strcmp(uname, "hypervisor") != 0)
> +			return 0;
>  
> -	for (i = 0; i < ARRAY_SIZE(dt_params); i++) {
> +		offset = of_get_flat_dt_subnode_by_name(node, "uefi");
> +		if (offset < 0)
> +			return 0;
> +		node = offset;
> +	} else {
> +		if (depth != 1 || strcmp(uname, "chosen") != 0)
> +			return 0;
> +	}
> +
> +	for (i = 0; i < info->size; i++) {
>  		prop = of_get_flat_dt_prop(node, dt_params[i].propname, &len);
>  		if (!prop)
>  			return 0;
> @@ -559,12 +582,20 @@ int __init efi_get_fdt_params(struct efi_fdt_params *params)
>  	info.found = 0;
>  	info.params = params;
>  
> +	if (efi_enabled(EFI_PARAVIRT)) {
> +		info.dt_params = xen_fdt_params;
> +		info.size = ARRAY_SIZE(xen_fdt_params);
> +	} else {
> +		info.dt_params = fdt_params;
> +		info.size = ARRAY_SIZE(fdt_params);
> +	}
> +
>  	ret = of_scan_flat_dt(fdt_find_uefi_params, &info);
>  	if (!info.found)
>  		pr_info("UEFI not found.\n");
>  	else if (!ret)
>  		pr_err("Can't find '%s' in device tree!\n",
> -		       dt_params[info.found].name);
> +		       info.dt_params[info.found].name);
>  
>  	return ret;
>  }
> -- 
> 2.0.4
> 
> 

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

* [PATCH v3 17/17] Xen: EFI: Parse DT parameters for Xen specific UEFI
@ 2016-01-26 11:41     ` Stefano Stabellini
  0 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-26 11:41 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Add a new function to parse DT parameters for Xen specific UEFI just
> like the way for normal UEFI. Then it could reuse the existing codes.
> 
> If Xen supports EFI, initialize runtime services.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

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


> CC: Matt Fleming <matt@codeblueprint.co.uk>
> ---
>  arch/arm/xen/enlighten.c   |  6 ++++++
>  arch/arm64/kernel/efi.c    | 17 ++++++++++++-----
>  drivers/firmware/efi/efi.c | 45 ++++++++++++++++++++++++++++++++++++++-------
>  3 files changed, 56 insertions(+), 12 deletions(-)
> 
> diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
> index cdc0bd2..608d735 100644
> --- a/arch/arm/xen/enlighten.c
> +++ b/arch/arm/xen/enlighten.c
> @@ -245,6 +245,12 @@ static int __init fdt_find_hyper_node(unsigned long node, const char *uname,
>  	    !strncmp(hyper_node.prefix, s, strlen(hyper_node.prefix)))
>  		hyper_node.version = s + strlen(hyper_node.prefix);
>  
> +	if (IS_ENABLED(CONFIG_XEN_EFI)) {
> +		/* Check if Xen supports EFI */
> +		if (of_get_flat_dt_subnode_by_name(node, "uefi") > 0)
> +			set_bit(EFI_PARAVIRT, &efi.flags);
> +	}
> +
>  	return 0;
>  }
>  
> diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c
> index 4eeb171..3c46129 100644
> --- a/arch/arm64/kernel/efi.c
> +++ b/arch/arm64/kernel/efi.c
> @@ -33,6 +33,7 @@
>  #include <asm/mmu_context.h>
>  #include <asm/mmu.h>
>  #include <asm/pgtable.h>
> +#include <asm/xen/xen-ops.h>
>  
>  struct efi_memory_map memmap;
>  
> @@ -308,13 +309,19 @@ static int __init arm64_enable_runtime_services(void)
>  	}
>  	set_bit(EFI_SYSTEM_TABLES, &efi.flags);
>  
> -	if (!efi_virtmap_init()) {
> -		pr_err("No UEFI virtual mapping was installed -- runtime services will not be available\n");
> -		return -ENOMEM;
> +	if (IS_ENABLED(CONFIG_XEN_EFI) && efi_enabled(EFI_PARAVIRT)) {
> +		/* Set up runtime services function pointers for Xen Dom0 */
> +		xen_efi_runtime_setup();
> +	} else {
> +		if (!efi_virtmap_init()) {
> +			pr_err("No UEFI virtual mapping was installed -- runtime services will not be available\n");
> +			return -ENOMEM;
> +		}
> +
> +		/* Set up runtime services function pointers */
> +		efi_native_runtime_setup();
>  	}
>  
> -	/* Set up runtime services function pointers */
> -	efi_native_runtime_setup();
>  	set_bit(EFI_RUNTIME_SERVICES, &efi.flags);
>  
>  	efi.runtime_version = efi.systab->hdr.revision;
> diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
> index 027ca21..bdcf6d7 100644
> --- a/drivers/firmware/efi/efi.c
> +++ b/drivers/firmware/efi/efi.c
> @@ -498,12 +498,14 @@ device_initcall(efi_load_efivars);
>  		FIELD_SIZEOF(struct efi_fdt_params, field) \
>  	}
>  
> -static __initdata struct {
> +struct params {
>  	const char name[32];
>  	const char propname[32];
>  	int offset;
>  	int size;
> -} dt_params[] = {
> +};
> +
> +static struct params fdt_params[] __initdata = {
>  	UEFI_PARAM("System Table", "linux,uefi-system-table", system_table),
>  	UEFI_PARAM("MemMap Address", "linux,uefi-mmap-start", mmap),
>  	UEFI_PARAM("MemMap Size", "linux,uefi-mmap-size", mmap_size),
> @@ -511,24 +513,45 @@ static __initdata struct {
>  	UEFI_PARAM("MemMap Desc. Version", "linux,uefi-mmap-desc-ver", desc_ver)
>  };
>  
> +static struct params xen_fdt_params[] __initdata = {
> +	UEFI_PARAM("System Table", "xen,uefi-system-table", system_table),
> +	UEFI_PARAM("MemMap Address", "xen,uefi-mmap-start", mmap),
> +	UEFI_PARAM("MemMap Size", "xen,uefi-mmap-size", mmap_size),
> +	UEFI_PARAM("MemMap Desc. Size", "xen,uefi-mmap-desc-size", desc_size),
> +	UEFI_PARAM("MemMap Desc. Version", "xen,uefi-mmap-desc-ver", desc_ver)
> +};
> +
>  struct param_info {
>  	int found;
>  	void *params;
> +	struct params *dt_params;
> +	int size;
>  };
>  
>  static int __init fdt_find_uefi_params(unsigned long node, const char *uname,
>  				       int depth, void *data)
>  {
>  	struct param_info *info = data;
> +	struct params *dt_params = info->dt_params;
>  	const void *prop;
>  	void *dest;
>  	u64 val;
> -	int i, len;
> +	int i, len, offset;
>  
> -	if (depth != 1 || strcmp(uname, "chosen") != 0)
> -		return 0;
> +	if (efi_enabled(EFI_PARAVIRT)) {
> +		if (depth != 1 || strcmp(uname, "hypervisor") != 0)
> +			return 0;
>  
> -	for (i = 0; i < ARRAY_SIZE(dt_params); i++) {
> +		offset = of_get_flat_dt_subnode_by_name(node, "uefi");
> +		if (offset < 0)
> +			return 0;
> +		node = offset;
> +	} else {
> +		if (depth != 1 || strcmp(uname, "chosen") != 0)
> +			return 0;
> +	}
> +
> +	for (i = 0; i < info->size; i++) {
>  		prop = of_get_flat_dt_prop(node, dt_params[i].propname, &len);
>  		if (!prop)
>  			return 0;
> @@ -559,12 +582,20 @@ int __init efi_get_fdt_params(struct efi_fdt_params *params)
>  	info.found = 0;
>  	info.params = params;
>  
> +	if (efi_enabled(EFI_PARAVIRT)) {
> +		info.dt_params = xen_fdt_params;
> +		info.size = ARRAY_SIZE(xen_fdt_params);
> +	} else {
> +		info.dt_params = fdt_params;
> +		info.size = ARRAY_SIZE(fdt_params);
> +	}
> +
>  	ret = of_scan_flat_dt(fdt_find_uefi_params, &info);
>  	if (!info.found)
>  		pr_info("UEFI not found.\n");
>  	else if (!ret)
>  		pr_err("Can't find '%s' in device tree!\n",
> -		       dt_params[info.found].name);
> +		       info.dt_params[info.found].name);
>  
>  	return ret;
>  }
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v3 17/17] Xen: EFI: Parse DT parameters for Xen specific UEFI
  2016-01-23  3:19   ` Shannon Zhao
                     ` (2 preceding siblings ...)
  (?)
@ 2016-01-26 11:41   ` Stefano Stabellini
  -1 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-26 11:41 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: mark.rutland, devicetree, linux-efi, ian.campbell,
	ard.biesheuvel, Matt Fleming, catalin.marinas, will.deacon,
	linux-kernel, xen-devel, julien.grall, stefano.stabellini,
	david.vrabel, peter.huangpeng, linux-arm-kernel, shannon.zhao

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Add a new function to parse DT parameters for Xen specific UEFI just
> like the way for normal UEFI. Then it could reuse the existing codes.
> 
> If Xen supports EFI, initialize runtime services.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>

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


> CC: Matt Fleming <matt@codeblueprint.co.uk>
> ---
>  arch/arm/xen/enlighten.c   |  6 ++++++
>  arch/arm64/kernel/efi.c    | 17 ++++++++++++-----
>  drivers/firmware/efi/efi.c | 45 ++++++++++++++++++++++++++++++++++++++-------
>  3 files changed, 56 insertions(+), 12 deletions(-)
> 
> diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
> index cdc0bd2..608d735 100644
> --- a/arch/arm/xen/enlighten.c
> +++ b/arch/arm/xen/enlighten.c
> @@ -245,6 +245,12 @@ static int __init fdt_find_hyper_node(unsigned long node, const char *uname,
>  	    !strncmp(hyper_node.prefix, s, strlen(hyper_node.prefix)))
>  		hyper_node.version = s + strlen(hyper_node.prefix);
>  
> +	if (IS_ENABLED(CONFIG_XEN_EFI)) {
> +		/* Check if Xen supports EFI */
> +		if (of_get_flat_dt_subnode_by_name(node, "uefi") > 0)
> +			set_bit(EFI_PARAVIRT, &efi.flags);
> +	}
> +
>  	return 0;
>  }
>  
> diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c
> index 4eeb171..3c46129 100644
> --- a/arch/arm64/kernel/efi.c
> +++ b/arch/arm64/kernel/efi.c
> @@ -33,6 +33,7 @@
>  #include <asm/mmu_context.h>
>  #include <asm/mmu.h>
>  #include <asm/pgtable.h>
> +#include <asm/xen/xen-ops.h>
>  
>  struct efi_memory_map memmap;
>  
> @@ -308,13 +309,19 @@ static int __init arm64_enable_runtime_services(void)
>  	}
>  	set_bit(EFI_SYSTEM_TABLES, &efi.flags);
>  
> -	if (!efi_virtmap_init()) {
> -		pr_err("No UEFI virtual mapping was installed -- runtime services will not be available\n");
> -		return -ENOMEM;
> +	if (IS_ENABLED(CONFIG_XEN_EFI) && efi_enabled(EFI_PARAVIRT)) {
> +		/* Set up runtime services function pointers for Xen Dom0 */
> +		xen_efi_runtime_setup();
> +	} else {
> +		if (!efi_virtmap_init()) {
> +			pr_err("No UEFI virtual mapping was installed -- runtime services will not be available\n");
> +			return -ENOMEM;
> +		}
> +
> +		/* Set up runtime services function pointers */
> +		efi_native_runtime_setup();
>  	}
>  
> -	/* Set up runtime services function pointers */
> -	efi_native_runtime_setup();
>  	set_bit(EFI_RUNTIME_SERVICES, &efi.flags);
>  
>  	efi.runtime_version = efi.systab->hdr.revision;
> diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
> index 027ca21..bdcf6d7 100644
> --- a/drivers/firmware/efi/efi.c
> +++ b/drivers/firmware/efi/efi.c
> @@ -498,12 +498,14 @@ device_initcall(efi_load_efivars);
>  		FIELD_SIZEOF(struct efi_fdt_params, field) \
>  	}
>  
> -static __initdata struct {
> +struct params {
>  	const char name[32];
>  	const char propname[32];
>  	int offset;
>  	int size;
> -} dt_params[] = {
> +};
> +
> +static struct params fdt_params[] __initdata = {
>  	UEFI_PARAM("System Table", "linux,uefi-system-table", system_table),
>  	UEFI_PARAM("MemMap Address", "linux,uefi-mmap-start", mmap),
>  	UEFI_PARAM("MemMap Size", "linux,uefi-mmap-size", mmap_size),
> @@ -511,24 +513,45 @@ static __initdata struct {
>  	UEFI_PARAM("MemMap Desc. Version", "linux,uefi-mmap-desc-ver", desc_ver)
>  };
>  
> +static struct params xen_fdt_params[] __initdata = {
> +	UEFI_PARAM("System Table", "xen,uefi-system-table", system_table),
> +	UEFI_PARAM("MemMap Address", "xen,uefi-mmap-start", mmap),
> +	UEFI_PARAM("MemMap Size", "xen,uefi-mmap-size", mmap_size),
> +	UEFI_PARAM("MemMap Desc. Size", "xen,uefi-mmap-desc-size", desc_size),
> +	UEFI_PARAM("MemMap Desc. Version", "xen,uefi-mmap-desc-ver", desc_ver)
> +};
> +
>  struct param_info {
>  	int found;
>  	void *params;
> +	struct params *dt_params;
> +	int size;
>  };
>  
>  static int __init fdt_find_uefi_params(unsigned long node, const char *uname,
>  				       int depth, void *data)
>  {
>  	struct param_info *info = data;
> +	struct params *dt_params = info->dt_params;
>  	const void *prop;
>  	void *dest;
>  	u64 val;
> -	int i, len;
> +	int i, len, offset;
>  
> -	if (depth != 1 || strcmp(uname, "chosen") != 0)
> -		return 0;
> +	if (efi_enabled(EFI_PARAVIRT)) {
> +		if (depth != 1 || strcmp(uname, "hypervisor") != 0)
> +			return 0;
>  
> -	for (i = 0; i < ARRAY_SIZE(dt_params); i++) {
> +		offset = of_get_flat_dt_subnode_by_name(node, "uefi");
> +		if (offset < 0)
> +			return 0;
> +		node = offset;
> +	} else {
> +		if (depth != 1 || strcmp(uname, "chosen") != 0)
> +			return 0;
> +	}
> +
> +	for (i = 0; i < info->size; i++) {
>  		prop = of_get_flat_dt_prop(node, dt_params[i].propname, &len);
>  		if (!prop)
>  			return 0;
> @@ -559,12 +582,20 @@ int __init efi_get_fdt_params(struct efi_fdt_params *params)
>  	info.found = 0;
>  	info.params = params;
>  
> +	if (efi_enabled(EFI_PARAVIRT)) {
> +		info.dt_params = xen_fdt_params;
> +		info.size = ARRAY_SIZE(xen_fdt_params);
> +	} else {
> +		info.dt_params = fdt_params;
> +		info.size = ARRAY_SIZE(fdt_params);
> +	}
> +
>  	ret = of_scan_flat_dt(fdt_find_uefi_params, &info);
>  	if (!info.found)
>  		pr_info("UEFI not found.\n");
>  	else if (!ret)
>  		pr_err("Can't find '%s' in device tree!\n",
> -		       dt_params[info.found].name);
> +		       info.dt_params[info.found].name);
>  
>  	return ret;
>  }
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v3 17/17] Xen: EFI: Parse DT parameters for Xen specific UEFI
  2016-01-23  3:19   ` Shannon Zhao
@ 2016-01-26 12:05     ` Matt Fleming
  -1 siblings, 0 replies; 145+ messages in thread
From: Matt Fleming @ 2016-01-26 12:05 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel, catalin.marinas, will.deacon,
	julien.grall, xen-devel, devicetree, linux-efi, linux-kernel,
	ian.campbell, shannon.zhao, peter.huangpeng, Mark Salter,
	Leif Lindholm

On Sat, 23 Jan, at 11:19:44AM, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Add a new function to parse DT parameters for Xen specific UEFI just
> like the way for normal UEFI. Then it could reuse the existing codes.
> 
> If Xen supports EFI, initialize runtime services.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
> CC: Matt Fleming <matt@codeblueprint.co.uk>
> ---
>  arch/arm/xen/enlighten.c   |  6 ++++++
>  arch/arm64/kernel/efi.c    | 17 ++++++++++++-----
>  drivers/firmware/efi/efi.c | 45 ++++++++++++++++++++++++++++++++++++++-------
>  3 files changed, 56 insertions(+), 12 deletions(-)
 
Looks OK to me, but I've added some people to Cc that have touched
these files in the past, and it would be good to get their ACKs.

Reviewed-by: Matt Fleming <matt@codeblueprint.co.uk>

> diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
> index cdc0bd2..608d735 100644
> --- a/arch/arm/xen/enlighten.c
> +++ b/arch/arm/xen/enlighten.c
> @@ -245,6 +245,12 @@ static int __init fdt_find_hyper_node(unsigned long node, const char *uname,
>  	    !strncmp(hyper_node.prefix, s, strlen(hyper_node.prefix)))
>  		hyper_node.version = s + strlen(hyper_node.prefix);
>  
> +	if (IS_ENABLED(CONFIG_XEN_EFI)) {
> +		/* Check if Xen supports EFI */
> +		if (of_get_flat_dt_subnode_by_name(node, "uefi") > 0)
> +			set_bit(EFI_PARAVIRT, &efi.flags);
> +	}
> +
>  	return 0;
>  }
>  
> diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c
> index 4eeb171..3c46129 100644
> --- a/arch/arm64/kernel/efi.c
> +++ b/arch/arm64/kernel/efi.c
> @@ -33,6 +33,7 @@
>  #include <asm/mmu_context.h>
>  #include <asm/mmu.h>
>  #include <asm/pgtable.h>
> +#include <asm/xen/xen-ops.h>
>  
>  struct efi_memory_map memmap;
>  
> @@ -308,13 +309,19 @@ static int __init arm64_enable_runtime_services(void)
>  	}
>  	set_bit(EFI_SYSTEM_TABLES, &efi.flags);
>  
> -	if (!efi_virtmap_init()) {
> -		pr_err("No UEFI virtual mapping was installed -- runtime services will not be available\n");
> -		return -ENOMEM;
> +	if (IS_ENABLED(CONFIG_XEN_EFI) && efi_enabled(EFI_PARAVIRT)) {
> +		/* Set up runtime services function pointers for Xen Dom0 */
> +		xen_efi_runtime_setup();
> +	} else {
> +		if (!efi_virtmap_init()) {
> +			pr_err("No UEFI virtual mapping was installed -- runtime services will not be available\n");
> +			return -ENOMEM;
> +		}
> +
> +		/* Set up runtime services function pointers */
> +		efi_native_runtime_setup();
>  	}
>  
> -	/* Set up runtime services function pointers */
> -	efi_native_runtime_setup();
>  	set_bit(EFI_RUNTIME_SERVICES, &efi.flags);
>  
>  	efi.runtime_version = efi.systab->hdr.revision;
> diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
> index 027ca21..bdcf6d7 100644
> --- a/drivers/firmware/efi/efi.c
> +++ b/drivers/firmware/efi/efi.c
> @@ -498,12 +498,14 @@ device_initcall(efi_load_efivars);
>  		FIELD_SIZEOF(struct efi_fdt_params, field) \
>  	}
>  
> -static __initdata struct {
> +struct params {
>  	const char name[32];
>  	const char propname[32];
>  	int offset;
>  	int size;
> -} dt_params[] = {
> +};
> +
> +static struct params fdt_params[] __initdata = {
>  	UEFI_PARAM("System Table", "linux,uefi-system-table", system_table),
>  	UEFI_PARAM("MemMap Address", "linux,uefi-mmap-start", mmap),
>  	UEFI_PARAM("MemMap Size", "linux,uefi-mmap-size", mmap_size),
> @@ -511,24 +513,45 @@ static __initdata struct {
>  	UEFI_PARAM("MemMap Desc. Version", "linux,uefi-mmap-desc-ver", desc_ver)
>  };
>  
> +static struct params xen_fdt_params[] __initdata = {
> +	UEFI_PARAM("System Table", "xen,uefi-system-table", system_table),
> +	UEFI_PARAM("MemMap Address", "xen,uefi-mmap-start", mmap),
> +	UEFI_PARAM("MemMap Size", "xen,uefi-mmap-size", mmap_size),
> +	UEFI_PARAM("MemMap Desc. Size", "xen,uefi-mmap-desc-size", desc_size),
> +	UEFI_PARAM("MemMap Desc. Version", "xen,uefi-mmap-desc-ver", desc_ver)
> +};
> +
>  struct param_info {
>  	int found;
>  	void *params;
> +	struct params *dt_params;
> +	int size;
>  };
>  
>  static int __init fdt_find_uefi_params(unsigned long node, const char *uname,
>  				       int depth, void *data)
>  {
>  	struct param_info *info = data;
> +	struct params *dt_params = info->dt_params;
>  	const void *prop;
>  	void *dest;
>  	u64 val;
> -	int i, len;
> +	int i, len, offset;
>  
> -	if (depth != 1 || strcmp(uname, "chosen") != 0)
> -		return 0;
> +	if (efi_enabled(EFI_PARAVIRT)) {
> +		if (depth != 1 || strcmp(uname, "hypervisor") != 0)
> +			return 0;
>  
> -	for (i = 0; i < ARRAY_SIZE(dt_params); i++) {
> +		offset = of_get_flat_dt_subnode_by_name(node, "uefi");
> +		if (offset < 0)
> +			return 0;
> +		node = offset;
> +	} else {
> +		if (depth != 1 || strcmp(uname, "chosen") != 0)
> +			return 0;
> +	}
> +
> +	for (i = 0; i < info->size; i++) {
>  		prop = of_get_flat_dt_prop(node, dt_params[i].propname, &len);
>  		if (!prop)
>  			return 0;
> @@ -559,12 +582,20 @@ int __init efi_get_fdt_params(struct efi_fdt_params *params)
>  	info.found = 0;
>  	info.params = params;
>  
> +	if (efi_enabled(EFI_PARAVIRT)) {
> +		info.dt_params = xen_fdt_params;
> +		info.size = ARRAY_SIZE(xen_fdt_params);
> +	} else {
> +		info.dt_params = fdt_params;
> +		info.size = ARRAY_SIZE(fdt_params);
> +	}
> +
>  	ret = of_scan_flat_dt(fdt_find_uefi_params, &info);
>  	if (!info.found)
>  		pr_info("UEFI not found.\n");
>  	else if (!ret)
>  		pr_err("Can't find '%s' in device tree!\n",
> -		       dt_params[info.found].name);
> +		       info.dt_params[info.found].name);
>  
>  	return ret;
>  }
> -- 
> 2.0.4
> 
> 

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

* [PATCH v3 17/17] Xen: EFI: Parse DT parameters for Xen specific UEFI
@ 2016-01-26 12:05     ` Matt Fleming
  0 siblings, 0 replies; 145+ messages in thread
From: Matt Fleming @ 2016-01-26 12:05 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, 23 Jan, at 11:19:44AM, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Add a new function to parse DT parameters for Xen specific UEFI just
> like the way for normal UEFI. Then it could reuse the existing codes.
> 
> If Xen supports EFI, initialize runtime services.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
> CC: Matt Fleming <matt@codeblueprint.co.uk>
> ---
>  arch/arm/xen/enlighten.c   |  6 ++++++
>  arch/arm64/kernel/efi.c    | 17 ++++++++++++-----
>  drivers/firmware/efi/efi.c | 45 ++++++++++++++++++++++++++++++++++++++-------
>  3 files changed, 56 insertions(+), 12 deletions(-)
 
Looks OK to me, but I've added some people to Cc that have touched
these files in the past, and it would be good to get their ACKs.

Reviewed-by: Matt Fleming <matt@codeblueprint.co.uk>

> diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
> index cdc0bd2..608d735 100644
> --- a/arch/arm/xen/enlighten.c
> +++ b/arch/arm/xen/enlighten.c
> @@ -245,6 +245,12 @@ static int __init fdt_find_hyper_node(unsigned long node, const char *uname,
>  	    !strncmp(hyper_node.prefix, s, strlen(hyper_node.prefix)))
>  		hyper_node.version = s + strlen(hyper_node.prefix);
>  
> +	if (IS_ENABLED(CONFIG_XEN_EFI)) {
> +		/* Check if Xen supports EFI */
> +		if (of_get_flat_dt_subnode_by_name(node, "uefi") > 0)
> +			set_bit(EFI_PARAVIRT, &efi.flags);
> +	}
> +
>  	return 0;
>  }
>  
> diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c
> index 4eeb171..3c46129 100644
> --- a/arch/arm64/kernel/efi.c
> +++ b/arch/arm64/kernel/efi.c
> @@ -33,6 +33,7 @@
>  #include <asm/mmu_context.h>
>  #include <asm/mmu.h>
>  #include <asm/pgtable.h>
> +#include <asm/xen/xen-ops.h>
>  
>  struct efi_memory_map memmap;
>  
> @@ -308,13 +309,19 @@ static int __init arm64_enable_runtime_services(void)
>  	}
>  	set_bit(EFI_SYSTEM_TABLES, &efi.flags);
>  
> -	if (!efi_virtmap_init()) {
> -		pr_err("No UEFI virtual mapping was installed -- runtime services will not be available\n");
> -		return -ENOMEM;
> +	if (IS_ENABLED(CONFIG_XEN_EFI) && efi_enabled(EFI_PARAVIRT)) {
> +		/* Set up runtime services function pointers for Xen Dom0 */
> +		xen_efi_runtime_setup();
> +	} else {
> +		if (!efi_virtmap_init()) {
> +			pr_err("No UEFI virtual mapping was installed -- runtime services will not be available\n");
> +			return -ENOMEM;
> +		}
> +
> +		/* Set up runtime services function pointers */
> +		efi_native_runtime_setup();
>  	}
>  
> -	/* Set up runtime services function pointers */
> -	efi_native_runtime_setup();
>  	set_bit(EFI_RUNTIME_SERVICES, &efi.flags);
>  
>  	efi.runtime_version = efi.systab->hdr.revision;
> diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
> index 027ca21..bdcf6d7 100644
> --- a/drivers/firmware/efi/efi.c
> +++ b/drivers/firmware/efi/efi.c
> @@ -498,12 +498,14 @@ device_initcall(efi_load_efivars);
>  		FIELD_SIZEOF(struct efi_fdt_params, field) \
>  	}
>  
> -static __initdata struct {
> +struct params {
>  	const char name[32];
>  	const char propname[32];
>  	int offset;
>  	int size;
> -} dt_params[] = {
> +};
> +
> +static struct params fdt_params[] __initdata = {
>  	UEFI_PARAM("System Table", "linux,uefi-system-table", system_table),
>  	UEFI_PARAM("MemMap Address", "linux,uefi-mmap-start", mmap),
>  	UEFI_PARAM("MemMap Size", "linux,uefi-mmap-size", mmap_size),
> @@ -511,24 +513,45 @@ static __initdata struct {
>  	UEFI_PARAM("MemMap Desc. Version", "linux,uefi-mmap-desc-ver", desc_ver)
>  };
>  
> +static struct params xen_fdt_params[] __initdata = {
> +	UEFI_PARAM("System Table", "xen,uefi-system-table", system_table),
> +	UEFI_PARAM("MemMap Address", "xen,uefi-mmap-start", mmap),
> +	UEFI_PARAM("MemMap Size", "xen,uefi-mmap-size", mmap_size),
> +	UEFI_PARAM("MemMap Desc. Size", "xen,uefi-mmap-desc-size", desc_size),
> +	UEFI_PARAM("MemMap Desc. Version", "xen,uefi-mmap-desc-ver", desc_ver)
> +};
> +
>  struct param_info {
>  	int found;
>  	void *params;
> +	struct params *dt_params;
> +	int size;
>  };
>  
>  static int __init fdt_find_uefi_params(unsigned long node, const char *uname,
>  				       int depth, void *data)
>  {
>  	struct param_info *info = data;
> +	struct params *dt_params = info->dt_params;
>  	const void *prop;
>  	void *dest;
>  	u64 val;
> -	int i, len;
> +	int i, len, offset;
>  
> -	if (depth != 1 || strcmp(uname, "chosen") != 0)
> -		return 0;
> +	if (efi_enabled(EFI_PARAVIRT)) {
> +		if (depth != 1 || strcmp(uname, "hypervisor") != 0)
> +			return 0;
>  
> -	for (i = 0; i < ARRAY_SIZE(dt_params); i++) {
> +		offset = of_get_flat_dt_subnode_by_name(node, "uefi");
> +		if (offset < 0)
> +			return 0;
> +		node = offset;
> +	} else {
> +		if (depth != 1 || strcmp(uname, "chosen") != 0)
> +			return 0;
> +	}
> +
> +	for (i = 0; i < info->size; i++) {
>  		prop = of_get_flat_dt_prop(node, dt_params[i].propname, &len);
>  		if (!prop)
>  			return 0;
> @@ -559,12 +582,20 @@ int __init efi_get_fdt_params(struct efi_fdt_params *params)
>  	info.found = 0;
>  	info.params = params;
>  
> +	if (efi_enabled(EFI_PARAVIRT)) {
> +		info.dt_params = xen_fdt_params;
> +		info.size = ARRAY_SIZE(xen_fdt_params);
> +	} else {
> +		info.dt_params = fdt_params;
> +		info.size = ARRAY_SIZE(fdt_params);
> +	}
> +
>  	ret = of_scan_flat_dt(fdt_find_uefi_params, &info);
>  	if (!info.found)
>  		pr_info("UEFI not found.\n");
>  	else if (!ret)
>  		pr_err("Can't find '%s' in device tree!\n",
> -		       dt_params[info.found].name);
> +		       info.dt_params[info.found].name);
>  
>  	return ret;
>  }
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v3 17/17] Xen: EFI: Parse DT parameters for Xen specific UEFI
  2016-01-23  3:19   ` Shannon Zhao
                     ` (4 preceding siblings ...)
  (?)
@ 2016-01-26 12:05   ` Matt Fleming
  -1 siblings, 0 replies; 145+ messages in thread
From: Matt Fleming @ 2016-01-26 12:05 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: mark.rutland, devicetree, linux-efi, ian.campbell,
	ard.biesheuvel, catalin.marinas, will.deacon, linux-kernel,
	Leif Lindholm, xen-devel, julien.grall, stefano.stabellini,
	david.vrabel, Mark Salter, peter.huangpeng, linux-arm-kernel,
	shannon.zhao

On Sat, 23 Jan, at 11:19:44AM, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Add a new function to parse DT parameters for Xen specific UEFI just
> like the way for normal UEFI. Then it could reuse the existing codes.
> 
> If Xen supports EFI, initialize runtime services.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
> CC: Matt Fleming <matt@codeblueprint.co.uk>
> ---
>  arch/arm/xen/enlighten.c   |  6 ++++++
>  arch/arm64/kernel/efi.c    | 17 ++++++++++++-----
>  drivers/firmware/efi/efi.c | 45 ++++++++++++++++++++++++++++++++++++++-------
>  3 files changed, 56 insertions(+), 12 deletions(-)
 
Looks OK to me, but I've added some people to Cc that have touched
these files in the past, and it would be good to get their ACKs.

Reviewed-by: Matt Fleming <matt@codeblueprint.co.uk>

> diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
> index cdc0bd2..608d735 100644
> --- a/arch/arm/xen/enlighten.c
> +++ b/arch/arm/xen/enlighten.c
> @@ -245,6 +245,12 @@ static int __init fdt_find_hyper_node(unsigned long node, const char *uname,
>  	    !strncmp(hyper_node.prefix, s, strlen(hyper_node.prefix)))
>  		hyper_node.version = s + strlen(hyper_node.prefix);
>  
> +	if (IS_ENABLED(CONFIG_XEN_EFI)) {
> +		/* Check if Xen supports EFI */
> +		if (of_get_flat_dt_subnode_by_name(node, "uefi") > 0)
> +			set_bit(EFI_PARAVIRT, &efi.flags);
> +	}
> +
>  	return 0;
>  }
>  
> diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c
> index 4eeb171..3c46129 100644
> --- a/arch/arm64/kernel/efi.c
> +++ b/arch/arm64/kernel/efi.c
> @@ -33,6 +33,7 @@
>  #include <asm/mmu_context.h>
>  #include <asm/mmu.h>
>  #include <asm/pgtable.h>
> +#include <asm/xen/xen-ops.h>
>  
>  struct efi_memory_map memmap;
>  
> @@ -308,13 +309,19 @@ static int __init arm64_enable_runtime_services(void)
>  	}
>  	set_bit(EFI_SYSTEM_TABLES, &efi.flags);
>  
> -	if (!efi_virtmap_init()) {
> -		pr_err("No UEFI virtual mapping was installed -- runtime services will not be available\n");
> -		return -ENOMEM;
> +	if (IS_ENABLED(CONFIG_XEN_EFI) && efi_enabled(EFI_PARAVIRT)) {
> +		/* Set up runtime services function pointers for Xen Dom0 */
> +		xen_efi_runtime_setup();
> +	} else {
> +		if (!efi_virtmap_init()) {
> +			pr_err("No UEFI virtual mapping was installed -- runtime services will not be available\n");
> +			return -ENOMEM;
> +		}
> +
> +		/* Set up runtime services function pointers */
> +		efi_native_runtime_setup();
>  	}
>  
> -	/* Set up runtime services function pointers */
> -	efi_native_runtime_setup();
>  	set_bit(EFI_RUNTIME_SERVICES, &efi.flags);
>  
>  	efi.runtime_version = efi.systab->hdr.revision;
> diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
> index 027ca21..bdcf6d7 100644
> --- a/drivers/firmware/efi/efi.c
> +++ b/drivers/firmware/efi/efi.c
> @@ -498,12 +498,14 @@ device_initcall(efi_load_efivars);
>  		FIELD_SIZEOF(struct efi_fdt_params, field) \
>  	}
>  
> -static __initdata struct {
> +struct params {
>  	const char name[32];
>  	const char propname[32];
>  	int offset;
>  	int size;
> -} dt_params[] = {
> +};
> +
> +static struct params fdt_params[] __initdata = {
>  	UEFI_PARAM("System Table", "linux,uefi-system-table", system_table),
>  	UEFI_PARAM("MemMap Address", "linux,uefi-mmap-start", mmap),
>  	UEFI_PARAM("MemMap Size", "linux,uefi-mmap-size", mmap_size),
> @@ -511,24 +513,45 @@ static __initdata struct {
>  	UEFI_PARAM("MemMap Desc. Version", "linux,uefi-mmap-desc-ver", desc_ver)
>  };
>  
> +static struct params xen_fdt_params[] __initdata = {
> +	UEFI_PARAM("System Table", "xen,uefi-system-table", system_table),
> +	UEFI_PARAM("MemMap Address", "xen,uefi-mmap-start", mmap),
> +	UEFI_PARAM("MemMap Size", "xen,uefi-mmap-size", mmap_size),
> +	UEFI_PARAM("MemMap Desc. Size", "xen,uefi-mmap-desc-size", desc_size),
> +	UEFI_PARAM("MemMap Desc. Version", "xen,uefi-mmap-desc-ver", desc_ver)
> +};
> +
>  struct param_info {
>  	int found;
>  	void *params;
> +	struct params *dt_params;
> +	int size;
>  };
>  
>  static int __init fdt_find_uefi_params(unsigned long node, const char *uname,
>  				       int depth, void *data)
>  {
>  	struct param_info *info = data;
> +	struct params *dt_params = info->dt_params;
>  	const void *prop;
>  	void *dest;
>  	u64 val;
> -	int i, len;
> +	int i, len, offset;
>  
> -	if (depth != 1 || strcmp(uname, "chosen") != 0)
> -		return 0;
> +	if (efi_enabled(EFI_PARAVIRT)) {
> +		if (depth != 1 || strcmp(uname, "hypervisor") != 0)
> +			return 0;
>  
> -	for (i = 0; i < ARRAY_SIZE(dt_params); i++) {
> +		offset = of_get_flat_dt_subnode_by_name(node, "uefi");
> +		if (offset < 0)
> +			return 0;
> +		node = offset;
> +	} else {
> +		if (depth != 1 || strcmp(uname, "chosen") != 0)
> +			return 0;
> +	}
> +
> +	for (i = 0; i < info->size; i++) {
>  		prop = of_get_flat_dt_prop(node, dt_params[i].propname, &len);
>  		if (!prop)
>  			return 0;
> @@ -559,12 +582,20 @@ int __init efi_get_fdt_params(struct efi_fdt_params *params)
>  	info.found = 0;
>  	info.params = params;
>  
> +	if (efi_enabled(EFI_PARAVIRT)) {
> +		info.dt_params = xen_fdt_params;
> +		info.size = ARRAY_SIZE(xen_fdt_params);
> +	} else {
> +		info.dt_params = fdt_params;
> +		info.size = ARRAY_SIZE(fdt_params);
> +	}
> +
>  	ret = of_scan_flat_dt(fdt_find_uefi_params, &info);
>  	if (!info.found)
>  		pr_info("UEFI not found.\n");
>  	else if (!ret)
>  		pr_err("Can't find '%s' in device tree!\n",
> -		       dt_params[info.found].name);
> +		       info.dt_params[info.found].name);
>  
>  	return ret;
>  }
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v3 16/17] FDT: Add a helper to get specified name subnode
@ 2016-01-26 12:11     ` Stefano Stabellini
  0 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-26 12:11 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel, catalin.marinas, will.deacon,
	julien.grall, xen-devel, devicetree, linux-efi, linux-kernel,
	ian.campbell, shannon.zhao, peter.huangpeng, Rob Herring

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Sometimes it needs to check if there is a node in FDT by full path.
> Introduce this helper to get the specified name subnode if it exists.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
> CC: Rob Herring <robh@kernel.org>
> ---
>  drivers/of/fdt.c       | 35 +++++++++++++++++++++++++++++++++++
>  include/linux/of_fdt.h |  2 ++
>  2 files changed, 37 insertions(+)
> 
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index 655f79d..112ec16 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -645,6 +645,41 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node,
>  }
>  
>  /**
> + * of_get_flat_dt_subnode_by_name - get subnode of specified node by name
> + *
> + * @node: the parent node
> + * @uname: the name of subnode
> + * @return offset of the subnode, or -FDT_ERR_NOTFOUND if there is none
> + */
> +
> +int of_get_flat_dt_subnode_by_name(unsigned long node, const char *uname)
> +{
> +	const void *blob = initial_boot_params;
> +	int offset;
> +	const char *pathp;
> +
> +	/* Find first subnode if it exists */
> +	offset = fdt_first_subnode(blob, node);
> +	if (offset < 0)
> +		return -FDT_ERR_NOTFOUND;
> +	pathp = fdt_get_name(blob, offset, NULL);
> +	if (strncmp(pathp, uname, strlen(uname)) == 0)
> +		return offset;

Wouldn't this check succeed even if uname is "uefi" and the node
name is actually "uefiiiii"?  You might have to use strcmp.


> +	/* Find other subnodes */
> +	do {
> +		offset = fdt_next_subnode(blob, offset);
> +		if (offset < 0)
> +			return -FDT_ERR_NOTFOUND;
> +		pathp = fdt_get_name(blob, offset, NULL);
> +		if (strncmp(pathp, uname, strlen(uname)) == 0)
> +			return offset;
> +	} while (offset >= 0);

Rather than writing the name check twice, I think it would be best to
code this loop as:

    for (offset = fdt_first_subnode(blob, offset);
         offset >= 0;
         offset = fdt_next_subnode(blob, offset)) {

         /* do name check */



> +	return -FDT_ERR_NOTFOUND;
> +}
> +
> +/**
>   * of_get_flat_dt_root - find the root node in the flat blob
>   */
>  unsigned long __init of_get_flat_dt_root(void)
> diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
> index df9ef38..fc28162 100644
> --- a/include/linux/of_fdt.h
> +++ b/include/linux/of_fdt.h
> @@ -52,6 +52,8 @@ extern char __dtb_end[];
>  extern int of_scan_flat_dt(int (*it)(unsigned long node, const char *uname,
>  				     int depth, void *data),
>  			   void *data);
> +extern int of_get_flat_dt_subnode_by_name(unsigned long node,
> +					  const char *uname);
>  extern const void *of_get_flat_dt_prop(unsigned long node, const char *name,
>  				       int *size);
>  extern int of_flat_dt_is_compatible(unsigned long node, const char *name);
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v3 16/17] FDT: Add a helper to get specified name subnode
@ 2016-01-26 12:11     ` Stefano Stabellini
  0 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-26 12:11 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	stefano.stabellini-Sxgqhf6Nn4DQT0dZR+AlfA,
	david.vrabel-Sxgqhf6Nn4DQT0dZR+AlfA, catalin.marinas-5wv7dgnIgG8,
	will.deacon-5wv7dgnIgG8, julien.grall-Sxgqhf6Nn4DQT0dZR+AlfA,
	xen-devel-GuqFBffKawuEi8DpZVb4nw,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-efi-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	ian.campbell-Sxgqhf6Nn4DQT0dZR+AlfA,
	shannon.zhao-QSEj5FYQhm4dnm+yROfE0A,
	peter.huangpeng-hv44wF8Li93QT0dZR+AlfA, Rob Herring

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> 
> Sometimes it needs to check if there is a node in FDT by full path.
> Introduce this helper to get the specified name subnode if it exists.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
> ---
> CC: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> ---
>  drivers/of/fdt.c       | 35 +++++++++++++++++++++++++++++++++++
>  include/linux/of_fdt.h |  2 ++
>  2 files changed, 37 insertions(+)
> 
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index 655f79d..112ec16 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -645,6 +645,41 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node,
>  }
>  
>  /**
> + * of_get_flat_dt_subnode_by_name - get subnode of specified node by name
> + *
> + * @node: the parent node
> + * @uname: the name of subnode
> + * @return offset of the subnode, or -FDT_ERR_NOTFOUND if there is none
> + */
> +
> +int of_get_flat_dt_subnode_by_name(unsigned long node, const char *uname)
> +{
> +	const void *blob = initial_boot_params;
> +	int offset;
> +	const char *pathp;
> +
> +	/* Find first subnode if it exists */
> +	offset = fdt_first_subnode(blob, node);
> +	if (offset < 0)
> +		return -FDT_ERR_NOTFOUND;
> +	pathp = fdt_get_name(blob, offset, NULL);
> +	if (strncmp(pathp, uname, strlen(uname)) == 0)
> +		return offset;

Wouldn't this check succeed even if uname is "uefi" and the node
name is actually "uefiiiii"?  You might have to use strcmp.


> +	/* Find other subnodes */
> +	do {
> +		offset = fdt_next_subnode(blob, offset);
> +		if (offset < 0)
> +			return -FDT_ERR_NOTFOUND;
> +		pathp = fdt_get_name(blob, offset, NULL);
> +		if (strncmp(pathp, uname, strlen(uname)) == 0)
> +			return offset;
> +	} while (offset >= 0);

Rather than writing the name check twice, I think it would be best to
code this loop as:

    for (offset = fdt_first_subnode(blob, offset);
         offset >= 0;
         offset = fdt_next_subnode(blob, offset)) {

         /* do name check */



> +	return -FDT_ERR_NOTFOUND;
> +}
> +
> +/**
>   * of_get_flat_dt_root - find the root node in the flat blob
>   */
>  unsigned long __init of_get_flat_dt_root(void)
> diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
> index df9ef38..fc28162 100644
> --- a/include/linux/of_fdt.h
> +++ b/include/linux/of_fdt.h
> @@ -52,6 +52,8 @@ extern char __dtb_end[];
>  extern int of_scan_flat_dt(int (*it)(unsigned long node, const char *uname,
>  				     int depth, void *data),
>  			   void *data);
> +extern int of_get_flat_dt_subnode_by_name(unsigned long node,
> +					  const char *uname);
>  extern const void *of_get_flat_dt_prop(unsigned long node, const char *name,
>  				       int *size);
>  extern int of_flat_dt_is_compatible(unsigned long node, const char *name);
> -- 
> 2.0.4
> 
> 
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v3 16/17] FDT: Add a helper to get specified name subnode
@ 2016-01-26 12:11     ` Stefano Stabellini
  0 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-26 12:11 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Sometimes it needs to check if there is a node in FDT by full path.
> Introduce this helper to get the specified name subnode if it exists.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
> CC: Rob Herring <robh@kernel.org>
> ---
>  drivers/of/fdt.c       | 35 +++++++++++++++++++++++++++++++++++
>  include/linux/of_fdt.h |  2 ++
>  2 files changed, 37 insertions(+)
> 
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index 655f79d..112ec16 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -645,6 +645,41 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node,
>  }
>  
>  /**
> + * of_get_flat_dt_subnode_by_name - get subnode of specified node by name
> + *
> + * @node: the parent node
> + * @uname: the name of subnode
> + * @return offset of the subnode, or -FDT_ERR_NOTFOUND if there is none
> + */
> +
> +int of_get_flat_dt_subnode_by_name(unsigned long node, const char *uname)
> +{
> +	const void *blob = initial_boot_params;
> +	int offset;
> +	const char *pathp;
> +
> +	/* Find first subnode if it exists */
> +	offset = fdt_first_subnode(blob, node);
> +	if (offset < 0)
> +		return -FDT_ERR_NOTFOUND;
> +	pathp = fdt_get_name(blob, offset, NULL);
> +	if (strncmp(pathp, uname, strlen(uname)) == 0)
> +		return offset;

Wouldn't this check succeed even if uname is "uefi" and the node
name is actually "uefiiiii"?  You might have to use strcmp.


> +	/* Find other subnodes */
> +	do {
> +		offset = fdt_next_subnode(blob, offset);
> +		if (offset < 0)
> +			return -FDT_ERR_NOTFOUND;
> +		pathp = fdt_get_name(blob, offset, NULL);
> +		if (strncmp(pathp, uname, strlen(uname)) == 0)
> +			return offset;
> +	} while (offset >= 0);

Rather than writing the name check twice, I think it would be best to
code this loop as:

    for (offset = fdt_first_subnode(blob, offset);
         offset >= 0;
         offset = fdt_next_subnode(blob, offset)) {

         /* do name check */



> +	return -FDT_ERR_NOTFOUND;
> +}
> +
> +/**
>   * of_get_flat_dt_root - find the root node in the flat blob
>   */
>  unsigned long __init of_get_flat_dt_root(void)
> diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
> index df9ef38..fc28162 100644
> --- a/include/linux/of_fdt.h
> +++ b/include/linux/of_fdt.h
> @@ -52,6 +52,8 @@ extern char __dtb_end[];
>  extern int of_scan_flat_dt(int (*it)(unsigned long node, const char *uname,
>  				     int depth, void *data),
>  			   void *data);
> +extern int of_get_flat_dt_subnode_by_name(unsigned long node,
> +					  const char *uname);
>  extern const void *of_get_flat_dt_prop(unsigned long node, const char *name,
>  				       int *size);
>  extern int of_flat_dt_is_compatible(unsigned long node, const char *name);
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v3 16/17] FDT: Add a helper to get specified name subnode
  2016-01-23  3:19   ` Shannon Zhao
                     ` (2 preceding siblings ...)
  (?)
@ 2016-01-26 12:11   ` Stefano Stabellini
  -1 siblings, 0 replies; 145+ messages in thread
From: Stefano Stabellini @ 2016-01-26 12:11 UTC (permalink / raw)
  To: Shannon Zhao
  Cc: mark.rutland, devicetree, linux-efi, ian.campbell,
	ard.biesheuvel, catalin.marinas, will.deacon, linux-kernel,
	xen-devel, julien.grall, stefano.stabellini, david.vrabel,
	peter.huangpeng, Rob Herring, linux-arm-kernel, shannon.zhao

On Sat, 23 Jan 2016, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Sometimes it needs to check if there is a node in FDT by full path.
> Introduce this helper to get the specified name subnode if it exists.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
> CC: Rob Herring <robh@kernel.org>
> ---
>  drivers/of/fdt.c       | 35 +++++++++++++++++++++++++++++++++++
>  include/linux/of_fdt.h |  2 ++
>  2 files changed, 37 insertions(+)
> 
> diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
> index 655f79d..112ec16 100644
> --- a/drivers/of/fdt.c
> +++ b/drivers/of/fdt.c
> @@ -645,6 +645,41 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node,
>  }
>  
>  /**
> + * of_get_flat_dt_subnode_by_name - get subnode of specified node by name
> + *
> + * @node: the parent node
> + * @uname: the name of subnode
> + * @return offset of the subnode, or -FDT_ERR_NOTFOUND if there is none
> + */
> +
> +int of_get_flat_dt_subnode_by_name(unsigned long node, const char *uname)
> +{
> +	const void *blob = initial_boot_params;
> +	int offset;
> +	const char *pathp;
> +
> +	/* Find first subnode if it exists */
> +	offset = fdt_first_subnode(blob, node);
> +	if (offset < 0)
> +		return -FDT_ERR_NOTFOUND;
> +	pathp = fdt_get_name(blob, offset, NULL);
> +	if (strncmp(pathp, uname, strlen(uname)) == 0)
> +		return offset;

Wouldn't this check succeed even if uname is "uefi" and the node
name is actually "uefiiiii"?  You might have to use strcmp.


> +	/* Find other subnodes */
> +	do {
> +		offset = fdt_next_subnode(blob, offset);
> +		if (offset < 0)
> +			return -FDT_ERR_NOTFOUND;
> +		pathp = fdt_get_name(blob, offset, NULL);
> +		if (strncmp(pathp, uname, strlen(uname)) == 0)
> +			return offset;
> +	} while (offset >= 0);

Rather than writing the name check twice, I think it would be best to
code this loop as:

    for (offset = fdt_first_subnode(blob, offset);
         offset >= 0;
         offset = fdt_next_subnode(blob, offset)) {

         /* do name check */



> +	return -FDT_ERR_NOTFOUND;
> +}
> +
> +/**
>   * of_get_flat_dt_root - find the root node in the flat blob
>   */
>  unsigned long __init of_get_flat_dt_root(void)
> diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h
> index df9ef38..fc28162 100644
> --- a/include/linux/of_fdt.h
> +++ b/include/linux/of_fdt.h
> @@ -52,6 +52,8 @@ extern char __dtb_end[];
>  extern int of_scan_flat_dt(int (*it)(unsigned long node, const char *uname,
>  				     int depth, void *data),
>  			   void *data);
> +extern int of_get_flat_dt_subnode_by_name(unsigned long node,
> +					  const char *uname);
>  extern const void *of_get_flat_dt_prop(unsigned long node, const char *name,
>  				       int *size);
>  extern int of_flat_dt_is_compatible(unsigned long node, const char *name);
> -- 
> 2.0.4
> 
> 

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

* Re: [PATCH v3 14/17] XEN: EFI: Move x86 specific codes to architecture directory
@ 2016-01-26 12:26           ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-26 12:26 UTC (permalink / raw)
  To: Stefano Stabellini
  Cc: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel, catalin.marinas, will.deacon,
	julien.grall, xen-devel, devicetree, linux-efi, linux-kernel,
	ian.campbell, shannon.zhao, peter.huangpeng



On 2016/1/26 19:31, Stefano Stabellini wrote:
> On Tue, 26 Jan 2016, Shannon Zhao wrote:
>> > On 2016/1/26 0:44, Stefano Stabellini wrote:
>>> > > On Sat, 23 Jan 2016, Shannon Zhao wrote:
>>>>> > >> > From: Shannon Zhao <shannon.zhao@linaro.org>
>>>>> > >> > 
>>>>> > >> > Move x86 specific codes to architecture directory and export those EFI
>>>>> > >> > runtime service functions. This will be useful for initializing runtime
>>>>> > >> > service on ARM later.
>>>>> > >> > 
>>>>> > >> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>>> > > This patch causes a build breakage on x86:
>>> > > 
>>> > > arch/x86/xen/efi.c: In function ‘xen_efi_probe’:
>>> > > arch/x86/xen/efi.c:101:2: error: implicit declaration of function ‘HYPERVISOR_platform_op’ [-Werror=implicit-function-declaration]
>>> > > 
>> > This patch is based on following patch [1]. Maybe you need to update
>> > your branch. :)
>> > 
>> > [1] xen: rename dom0_op to platform_op
>> > https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=cfafae940381207d48b11a73a211142dba5947d3
> Sorry, I made a mistake rebasing the series. It doesn't help that I
> couldn't find any Linux RCs on top of which it applies cleanly. As Linus
> tags RCs often enough, it is usually helpful to base one's work on a tag
> so that it is easier for other people to work on it.
>
Ah, I'll rebase this series on top of the newest master at next version
since the relevant patches are in master.

> Please add my Reviewed-by to this patch.
Thanks a lot!

-- 
Shannon

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

* Re: [PATCH v3 14/17] XEN: EFI: Move x86 specific codes to architecture directory
@ 2016-01-26 12:26           ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-26 12:26 UTC (permalink / raw)
  To: Stefano Stabellini
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	stefano.stabellini-Sxgqhf6Nn4DQT0dZR+AlfA,
	david.vrabel-Sxgqhf6Nn4DQT0dZR+AlfA, catalin.marinas-5wv7dgnIgG8,
	will.deacon-5wv7dgnIgG8, julien.grall-Sxgqhf6Nn4DQT0dZR+AlfA,
	xen-devel-GuqFBffKawuEi8DpZVb4nw,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-efi-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	ian.campbell-Sxgqhf6Nn4DQT0dZR+AlfA,
	shannon.zhao-QSEj5FYQhm4dnm+yROfE0A,
	peter.huangpeng-hv44wF8Li93QT0dZR+AlfA



On 2016/1/26 19:31, Stefano Stabellini wrote:
> On Tue, 26 Jan 2016, Shannon Zhao wrote:
>> > On 2016/1/26 0:44, Stefano Stabellini wrote:
>>> > > On Sat, 23 Jan 2016, Shannon Zhao wrote:
>>>>> > >> > From: Shannon Zhao <shannon.zhao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
>>>>> > >> > 
>>>>> > >> > Move x86 specific codes to architecture directory and export those EFI
>>>>> > >> > runtime service functions. This will be useful for initializing runtime
>>>>> > >> > service on ARM later.
>>>>> > >> > 
>>>>> > >> > Signed-off-by: Shannon Zhao <shannon.zhao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
>>> > > This patch causes a build breakage on x86:
>>> > > 
>>> > > arch/x86/xen/efi.c: In function ‘xen_efi_probe’:
>>> > > arch/x86/xen/efi.c:101:2: error: implicit declaration of function ‘HYPERVISOR_platform_op’ [-Werror=implicit-function-declaration]
>>> > > 
>> > This patch is based on following patch [1]. Maybe you need to update
>> > your branch. :)
>> > 
>> > [1] xen: rename dom0_op to platform_op
>> > https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=cfafae940381207d48b11a73a211142dba5947d3
> Sorry, I made a mistake rebasing the series. It doesn't help that I
> couldn't find any Linux RCs on top of which it applies cleanly. As Linus
> tags RCs often enough, it is usually helpful to base one's work on a tag
> so that it is easier for other people to work on it.
>
Ah, I'll rebase this series on top of the newest master at next version
since the relevant patches are in master.

> Please add my Reviewed-by to this patch.
Thanks a lot!

-- 
Shannon

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v3 14/17] XEN: EFI: Move x86 specific codes to architecture directory
@ 2016-01-26 12:26           ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-26 12:26 UTC (permalink / raw)
  To: linux-arm-kernel



On 2016/1/26 19:31, Stefano Stabellini wrote:
> On Tue, 26 Jan 2016, Shannon Zhao wrote:
>> > On 2016/1/26 0:44, Stefano Stabellini wrote:
>>> > > On Sat, 23 Jan 2016, Shannon Zhao wrote:
>>>>> > >> > From: Shannon Zhao <shannon.zhao@linaro.org>
>>>>> > >> > 
>>>>> > >> > Move x86 specific codes to architecture directory and export those EFI
>>>>> > >> > runtime service functions. This will be useful for initializing runtime
>>>>> > >> > service on ARM later.
>>>>> > >> > 
>>>>> > >> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>>> > > This patch causes a build breakage on x86:
>>> > > 
>>> > > arch/x86/xen/efi.c: In function ?xen_efi_probe?:
>>> > > arch/x86/xen/efi.c:101:2: error: implicit declaration of function ?HYPERVISOR_platform_op? [-Werror=implicit-function-declaration]
>>> > > 
>> > This patch is based on following patch [1]. Maybe you need to update
>> > your branch. :)
>> > 
>> > [1] xen: rename dom0_op to platform_op
>> > https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=cfafae940381207d48b11a73a211142dba5947d3
> Sorry, I made a mistake rebasing the series. It doesn't help that I
> couldn't find any Linux RCs on top of which it applies cleanly. As Linus
> tags RCs often enough, it is usually helpful to base one's work on a tag
> so that it is easier for other people to work on it.
>
Ah, I'll rebase this series on top of the newest master at next version
since the relevant patches are in master.

> Please add my Reviewed-by to this patch.
Thanks a lot!

-- 
Shannon

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

* Re: [PATCH v3 14/17] XEN: EFI: Move x86 specific codes to architecture directory
  2016-01-26 11:31         ` Stefano Stabellini
  (?)
  (?)
@ 2016-01-26 12:26         ` Shannon Zhao
  -1 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-26 12:26 UTC (permalink / raw)
  To: Stefano Stabellini
  Cc: mark.rutland, devicetree, linux-efi, ian.campbell,
	ard.biesheuvel, catalin.marinas, will.deacon, linux-kernel,
	xen-devel, julien.grall, stefano.stabellini, david.vrabel,
	peter.huangpeng, linux-arm-kernel, shannon.zhao



On 2016/1/26 19:31, Stefano Stabellini wrote:
> On Tue, 26 Jan 2016, Shannon Zhao wrote:
>> > On 2016/1/26 0:44, Stefano Stabellini wrote:
>>> > > On Sat, 23 Jan 2016, Shannon Zhao wrote:
>>>>> > >> > From: Shannon Zhao <shannon.zhao@linaro.org>
>>>>> > >> > 
>>>>> > >> > Move x86 specific codes to architecture directory and export those EFI
>>>>> > >> > runtime service functions. This will be useful for initializing runtime
>>>>> > >> > service on ARM later.
>>>>> > >> > 
>>>>> > >> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>>> > > This patch causes a build breakage on x86:
>>> > > 
>>> > > arch/x86/xen/efi.c: In function ‘xen_efi_probe’:
>>> > > arch/x86/xen/efi.c:101:2: error: implicit declaration of function ‘HYPERVISOR_platform_op’ [-Werror=implicit-function-declaration]
>>> > > 
>> > This patch is based on following patch [1]. Maybe you need to update
>> > your branch. :)
>> > 
>> > [1] xen: rename dom0_op to platform_op
>> > https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=cfafae940381207d48b11a73a211142dba5947d3
> Sorry, I made a mistake rebasing the series. It doesn't help that I
> couldn't find any Linux RCs on top of which it applies cleanly. As Linus
> tags RCs often enough, it is usually helpful to base one's work on a tag
> so that it is easier for other people to work on it.
>
Ah, I'll rebase this series on top of the newest master at next version
since the relevant patches are in master.

> Please add my Reviewed-by to this patch.
Thanks a lot!

-- 
Shannon


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

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

* Re: [PATCH v3 16/17] FDT: Add a helper to get specified name subnode
@ 2016-01-26 12:27       ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-26 12:27 UTC (permalink / raw)
  To: Stefano Stabellini
  Cc: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel, catalin.marinas, will.deacon,
	julien.grall, xen-devel, devicetree, linux-efi, linux-kernel,
	ian.campbell, shannon.zhao, peter.huangpeng, Rob Herring



On 2016/1/26 20:11, Stefano Stabellini wrote:
> On Sat, 23 Jan 2016, Shannon Zhao wrote:
>> > From: Shannon Zhao <shannon.zhao@linaro.org>
>> > 
>> > Sometimes it needs to check if there is a node in FDT by full path.
>> > Introduce this helper to get the specified name subnode if it exists.
>> > 
>> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> > ---
>> > CC: Rob Herring <robh@kernel.org>
>> > ---
>> >  drivers/of/fdt.c       | 35 +++++++++++++++++++++++++++++++++++
>> >  include/linux/of_fdt.h |  2 ++
>> >  2 files changed, 37 insertions(+)
>> > 
>> > diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
>> > index 655f79d..112ec16 100644
>> > --- a/drivers/of/fdt.c
>> > +++ b/drivers/of/fdt.c
>> > @@ -645,6 +645,41 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node,
>> >  }
>> >  
>> >  /**
>> > + * of_get_flat_dt_subnode_by_name - get subnode of specified node by name
>> > + *
>> > + * @node: the parent node
>> > + * @uname: the name of subnode
>> > + * @return offset of the subnode, or -FDT_ERR_NOTFOUND if there is none
>> > + */
>> > +
>> > +int of_get_flat_dt_subnode_by_name(unsigned long node, const char *uname)
>> > +{
>> > +	const void *blob = initial_boot_params;
>> > +	int offset;
>> > +	const char *pathp;
>> > +
>> > +	/* Find first subnode if it exists */
>> > +	offset = fdt_first_subnode(blob, node);
>> > +	if (offset < 0)
>> > +		return -FDT_ERR_NOTFOUND;
>> > +	pathp = fdt_get_name(blob, offset, NULL);
>> > +	if (strncmp(pathp, uname, strlen(uname)) == 0)
>> > +		return offset;
> Wouldn't this check succeed even if uname is "uefi" and the node
> name is actually "uefiiiii"?  You might have to use strcmp.
> 
Ah, yes. Will fix this.

> 
>> > +	/* Find other subnodes */
>> > +	do {
>> > +		offset = fdt_next_subnode(blob, offset);
>> > +		if (offset < 0)
>> > +			return -FDT_ERR_NOTFOUND;
>> > +		pathp = fdt_get_name(blob, offset, NULL);
>> > +		if (strncmp(pathp, uname, strlen(uname)) == 0)
>> > +			return offset;
>> > +	} while (offset >= 0);
> Rather than writing the name check twice, I think it would be best to
> code this loop as:
> 
>     for (offset = fdt_first_subnode(blob, offset);
>          offset >= 0;
>          offset = fdt_next_subnode(blob, offset)) {
> 
>          /* do name check */
> 
> 
> 
Thanks for your suggestion. Will change this.

-- 
Shannon

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

* Re: [PATCH v3 16/17] FDT: Add a helper to get specified name subnode
@ 2016-01-26 12:27       ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-26 12:27 UTC (permalink / raw)
  To: Stefano Stabellini
  Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	stefano.stabellini-Sxgqhf6Nn4DQT0dZR+AlfA,
	david.vrabel-Sxgqhf6Nn4DQT0dZR+AlfA, catalin.marinas-5wv7dgnIgG8,
	will.deacon-5wv7dgnIgG8, julien.grall-Sxgqhf6Nn4DQT0dZR+AlfA,
	xen-devel-GuqFBffKawuEi8DpZVb4nw,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-efi-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	ian.campbell-Sxgqhf6Nn4DQT0dZR+AlfA,
	shannon.zhao-QSEj5FYQhm4dnm+yROfE0A,
	peter.huangpeng-hv44wF8Li93QT0dZR+AlfA, Rob Herring



On 2016/1/26 20:11, Stefano Stabellini wrote:
> On Sat, 23 Jan 2016, Shannon Zhao wrote:
>> > From: Shannon Zhao <shannon.zhao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
>> > 
>> > Sometimes it needs to check if there is a node in FDT by full path.
>> > Introduce this helper to get the specified name subnode if it exists.
>> > 
>> > Signed-off-by: Shannon Zhao <shannon.zhao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
>> > ---
>> > CC: Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
>> > ---
>> >  drivers/of/fdt.c       | 35 +++++++++++++++++++++++++++++++++++
>> >  include/linux/of_fdt.h |  2 ++
>> >  2 files changed, 37 insertions(+)
>> > 
>> > diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
>> > index 655f79d..112ec16 100644
>> > --- a/drivers/of/fdt.c
>> > +++ b/drivers/of/fdt.c
>> > @@ -645,6 +645,41 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node,
>> >  }
>> >  
>> >  /**
>> > + * of_get_flat_dt_subnode_by_name - get subnode of specified node by name
>> > + *
>> > + * @node: the parent node
>> > + * @uname: the name of subnode
>> > + * @return offset of the subnode, or -FDT_ERR_NOTFOUND if there is none
>> > + */
>> > +
>> > +int of_get_flat_dt_subnode_by_name(unsigned long node, const char *uname)
>> > +{
>> > +	const void *blob = initial_boot_params;
>> > +	int offset;
>> > +	const char *pathp;
>> > +
>> > +	/* Find first subnode if it exists */
>> > +	offset = fdt_first_subnode(blob, node);
>> > +	if (offset < 0)
>> > +		return -FDT_ERR_NOTFOUND;
>> > +	pathp = fdt_get_name(blob, offset, NULL);
>> > +	if (strncmp(pathp, uname, strlen(uname)) == 0)
>> > +		return offset;
> Wouldn't this check succeed even if uname is "uefi" and the node
> name is actually "uefiiiii"?  You might have to use strcmp.
> 
Ah, yes. Will fix this.

> 
>> > +	/* Find other subnodes */
>> > +	do {
>> > +		offset = fdt_next_subnode(blob, offset);
>> > +		if (offset < 0)
>> > +			return -FDT_ERR_NOTFOUND;
>> > +		pathp = fdt_get_name(blob, offset, NULL);
>> > +		if (strncmp(pathp, uname, strlen(uname)) == 0)
>> > +			return offset;
>> > +	} while (offset >= 0);
> Rather than writing the name check twice, I think it would be best to
> code this loop as:
> 
>     for (offset = fdt_first_subnode(blob, offset);
>          offset >= 0;
>          offset = fdt_next_subnode(blob, offset)) {
> 
>          /* do name check */
> 
> 
> 
Thanks for your suggestion. Will change this.

-- 
Shannon

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

* [PATCH v3 16/17] FDT: Add a helper to get specified name subnode
@ 2016-01-26 12:27       ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-26 12:27 UTC (permalink / raw)
  To: linux-arm-kernel



On 2016/1/26 20:11, Stefano Stabellini wrote:
> On Sat, 23 Jan 2016, Shannon Zhao wrote:
>> > From: Shannon Zhao <shannon.zhao@linaro.org>
>> > 
>> > Sometimes it needs to check if there is a node in FDT by full path.
>> > Introduce this helper to get the specified name subnode if it exists.
>> > 
>> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> > ---
>> > CC: Rob Herring <robh@kernel.org>
>> > ---
>> >  drivers/of/fdt.c       | 35 +++++++++++++++++++++++++++++++++++
>> >  include/linux/of_fdt.h |  2 ++
>> >  2 files changed, 37 insertions(+)
>> > 
>> > diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
>> > index 655f79d..112ec16 100644
>> > --- a/drivers/of/fdt.c
>> > +++ b/drivers/of/fdt.c
>> > @@ -645,6 +645,41 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node,
>> >  }
>> >  
>> >  /**
>> > + * of_get_flat_dt_subnode_by_name - get subnode of specified node by name
>> > + *
>> > + * @node: the parent node
>> > + * @uname: the name of subnode
>> > + * @return offset of the subnode, or -FDT_ERR_NOTFOUND if there is none
>> > + */
>> > +
>> > +int of_get_flat_dt_subnode_by_name(unsigned long node, const char *uname)
>> > +{
>> > +	const void *blob = initial_boot_params;
>> > +	int offset;
>> > +	const char *pathp;
>> > +
>> > +	/* Find first subnode if it exists */
>> > +	offset = fdt_first_subnode(blob, node);
>> > +	if (offset < 0)
>> > +		return -FDT_ERR_NOTFOUND;
>> > +	pathp = fdt_get_name(blob, offset, NULL);
>> > +	if (strncmp(pathp, uname, strlen(uname)) == 0)
>> > +		return offset;
> Wouldn't this check succeed even if uname is "uefi" and the node
> name is actually "uefiiiii"?  You might have to use strcmp.
> 
Ah, yes. Will fix this.

> 
>> > +	/* Find other subnodes */
>> > +	do {
>> > +		offset = fdt_next_subnode(blob, offset);
>> > +		if (offset < 0)
>> > +			return -FDT_ERR_NOTFOUND;
>> > +		pathp = fdt_get_name(blob, offset, NULL);
>> > +		if (strncmp(pathp, uname, strlen(uname)) == 0)
>> > +			return offset;
>> > +	} while (offset >= 0);
> Rather than writing the name check twice, I think it would be best to
> code this loop as:
> 
>     for (offset = fdt_first_subnode(blob, offset);
>          offset >= 0;
>          offset = fdt_next_subnode(blob, offset)) {
> 
>          /* do name check */
> 
> 
> 
Thanks for your suggestion. Will change this.

-- 
Shannon

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

* Re: [PATCH v3 16/17] FDT: Add a helper to get specified name subnode
  2016-01-26 12:11     ` Stefano Stabellini
  (?)
  (?)
@ 2016-01-26 12:27     ` Shannon Zhao
  -1 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-26 12:27 UTC (permalink / raw)
  To: Stefano Stabellini
  Cc: mark.rutland, devicetree, linux-efi, ian.campbell,
	ard.biesheuvel, catalin.marinas, will.deacon, linux-kernel,
	xen-devel, julien.grall, stefano.stabellini, david.vrabel,
	peter.huangpeng, Rob Herring, linux-arm-kernel, shannon.zhao



On 2016/1/26 20:11, Stefano Stabellini wrote:
> On Sat, 23 Jan 2016, Shannon Zhao wrote:
>> > From: Shannon Zhao <shannon.zhao@linaro.org>
>> > 
>> > Sometimes it needs to check if there is a node in FDT by full path.
>> > Introduce this helper to get the specified name subnode if it exists.
>> > 
>> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> > ---
>> > CC: Rob Herring <robh@kernel.org>
>> > ---
>> >  drivers/of/fdt.c       | 35 +++++++++++++++++++++++++++++++++++
>> >  include/linux/of_fdt.h |  2 ++
>> >  2 files changed, 37 insertions(+)
>> > 
>> > diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
>> > index 655f79d..112ec16 100644
>> > --- a/drivers/of/fdt.c
>> > +++ b/drivers/of/fdt.c
>> > @@ -645,6 +645,41 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node,
>> >  }
>> >  
>> >  /**
>> > + * of_get_flat_dt_subnode_by_name - get subnode of specified node by name
>> > + *
>> > + * @node: the parent node
>> > + * @uname: the name of subnode
>> > + * @return offset of the subnode, or -FDT_ERR_NOTFOUND if there is none
>> > + */
>> > +
>> > +int of_get_flat_dt_subnode_by_name(unsigned long node, const char *uname)
>> > +{
>> > +	const void *blob = initial_boot_params;
>> > +	int offset;
>> > +	const char *pathp;
>> > +
>> > +	/* Find first subnode if it exists */
>> > +	offset = fdt_first_subnode(blob, node);
>> > +	if (offset < 0)
>> > +		return -FDT_ERR_NOTFOUND;
>> > +	pathp = fdt_get_name(blob, offset, NULL);
>> > +	if (strncmp(pathp, uname, strlen(uname)) == 0)
>> > +		return offset;
> Wouldn't this check succeed even if uname is "uefi" and the node
> name is actually "uefiiiii"?  You might have to use strcmp.
> 
Ah, yes. Will fix this.

> 
>> > +	/* Find other subnodes */
>> > +	do {
>> > +		offset = fdt_next_subnode(blob, offset);
>> > +		if (offset < 0)
>> > +			return -FDT_ERR_NOTFOUND;
>> > +		pathp = fdt_get_name(blob, offset, NULL);
>> > +		if (strncmp(pathp, uname, strlen(uname)) == 0)
>> > +			return offset;
>> > +	} while (offset >= 0);
> Rather than writing the name check twice, I think it would be best to
> code this loop as:
> 
>     for (offset = fdt_first_subnode(blob, offset);
>          offset >= 0;
>          offset = fdt_next_subnode(blob, offset)) {
> 
>          /* do name check */
> 
> 
> 
Thanks for your suggestion. Will change this.

-- 
Shannon

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

* Re: [PATCH v3 12/17] ARM64: ACPI: Check if it runs on Xen to enable or disable ACPI
  2016-01-23  3:19   ` Shannon Zhao
@ 2016-01-27  8:27     ` Hanjun Guo
  -1 siblings, 0 replies; 145+ messages in thread
From: Hanjun Guo @ 2016-01-27  8:27 UTC (permalink / raw)
  To: Shannon Zhao, linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: catalin.marinas, will.deacon, julien.grall, xen-devel,
	devicetree, linux-efi, linux-kernel, ian.campbell, shannon.zhao,
	peter.huangpeng

Hi Shannon,

On 2016/1/23 11:19, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
>
> When it's a Xen domain0 booting with ACPI, it will supply a /chosen and
> a /hypervisor node in DT. So check if it needs to enable ACPI.
>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
> CC: Hanjun Guo <hanjun.guo@linaro.org>
> ---
>   arch/arm64/kernel/acpi.c | 12 ++++++++----
>   1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
> index d1ce8e2..4e92be0 100644
> --- a/arch/arm64/kernel/acpi.c
> +++ b/arch/arm64/kernel/acpi.c
> @@ -67,10 +67,13 @@ static int __init dt_scan_depth1_nodes(unsigned long node,
>   {
>   	/*
>   	 * Return 1 as soon as we encounter a node at depth 1 that is
> -	 * not the /chosen node.
> +	 * not the /chosen node, or /hypervisor node when running on Xen.

The comment is bit misleading, we need to specify two mode, running on
Xen or not, if not on xen, then /chosen node is enough.

>   	 */
> -	if (depth == 1 && (strcmp(uname, "chosen") != 0))
> -		return 1;
> +	if (depth == 1 && (strcmp(uname, "chosen") != 0)) {
> +		if (!xen_initial_domain() || (strcmp(uname, "hypervisor") != 0))
> +			return 1;
> +	}
> +
>   	return 0;
>   }
>
> @@ -184,7 +187,8 @@ void __init acpi_boot_table_init(void)
>   	/*
>   	 * Enable ACPI instead of device tree unless
>   	 * - ACPI has been disabled explicitly (acpi=off), or
> -	 * - the device tree is not empty (it has more than just a /chosen node)
> +	 * - the device tree is not empty (it has more than just a /chosen node,
> +	 *   and a /hypervisor node when running on Xen)

and here too.

if that is addressed,

Acked-by: Hanjun Guo <hanjun.guo@linaro.org>

Thanks
Hanjun

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

* [PATCH v3 12/17] ARM64: ACPI: Check if it runs on Xen to enable or disable ACPI
@ 2016-01-27  8:27     ` Hanjun Guo
  0 siblings, 0 replies; 145+ messages in thread
From: Hanjun Guo @ 2016-01-27  8:27 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Shannon,

On 2016/1/23 11:19, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
>
> When it's a Xen domain0 booting with ACPI, it will supply a /chosen and
> a /hypervisor node in DT. So check if it needs to enable ACPI.
>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
> CC: Hanjun Guo <hanjun.guo@linaro.org>
> ---
>   arch/arm64/kernel/acpi.c | 12 ++++++++----
>   1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
> index d1ce8e2..4e92be0 100644
> --- a/arch/arm64/kernel/acpi.c
> +++ b/arch/arm64/kernel/acpi.c
> @@ -67,10 +67,13 @@ static int __init dt_scan_depth1_nodes(unsigned long node,
>   {
>   	/*
>   	 * Return 1 as soon as we encounter a node at depth 1 that is
> -	 * not the /chosen node.
> +	 * not the /chosen node, or /hypervisor node when running on Xen.

The comment is bit misleading, we need to specify two mode, running on
Xen or not, if not on xen, then /chosen node is enough.

>   	 */
> -	if (depth == 1 && (strcmp(uname, "chosen") != 0))
> -		return 1;
> +	if (depth == 1 && (strcmp(uname, "chosen") != 0)) {
> +		if (!xen_initial_domain() || (strcmp(uname, "hypervisor") != 0))
> +			return 1;
> +	}
> +
>   	return 0;
>   }
>
> @@ -184,7 +187,8 @@ void __init acpi_boot_table_init(void)
>   	/*
>   	 * Enable ACPI instead of device tree unless
>   	 * - ACPI has been disabled explicitly (acpi=off), or
> -	 * - the device tree is not empty (it has more than just a /chosen node)
> +	 * - the device tree is not empty (it has more than just a /chosen node,
> +	 *   and a /hypervisor node when running on Xen)

and here too.

if that is addressed,

Acked-by: Hanjun Guo <hanjun.guo@linaro.org>

Thanks
Hanjun

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

* Re: [PATCH v3 12/17] ARM64: ACPI: Check if it runs on Xen to enable or disable ACPI
  2016-01-23  3:19   ` Shannon Zhao
                     ` (4 preceding siblings ...)
  (?)
@ 2016-01-27  8:27   ` Hanjun Guo
  -1 siblings, 0 replies; 145+ messages in thread
From: Hanjun Guo @ 2016-01-27  8:27 UTC (permalink / raw)
  To: Shannon Zhao, linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: devicetree, linux-efi, ian.campbell, catalin.marinas,
	will.deacon, linux-kernel, xen-devel, julien.grall, shannon.zhao,
	peter.huangpeng

Hi Shannon,

On 2016/1/23 11:19, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
>
> When it's a Xen domain0 booting with ACPI, it will supply a /chosen and
> a /hypervisor node in DT. So check if it needs to enable ACPI.
>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
> CC: Hanjun Guo <hanjun.guo@linaro.org>
> ---
>   arch/arm64/kernel/acpi.c | 12 ++++++++----
>   1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
> index d1ce8e2..4e92be0 100644
> --- a/arch/arm64/kernel/acpi.c
> +++ b/arch/arm64/kernel/acpi.c
> @@ -67,10 +67,13 @@ static int __init dt_scan_depth1_nodes(unsigned long node,
>   {
>   	/*
>   	 * Return 1 as soon as we encounter a node at depth 1 that is
> -	 * not the /chosen node.
> +	 * not the /chosen node, or /hypervisor node when running on Xen.

The comment is bit misleading, we need to specify two mode, running on
Xen or not, if not on xen, then /chosen node is enough.

>   	 */
> -	if (depth == 1 && (strcmp(uname, "chosen") != 0))
> -		return 1;
> +	if (depth == 1 && (strcmp(uname, "chosen") != 0)) {
> +		if (!xen_initial_domain() || (strcmp(uname, "hypervisor") != 0))
> +			return 1;
> +	}
> +
>   	return 0;
>   }
>
> @@ -184,7 +187,8 @@ void __init acpi_boot_table_init(void)
>   	/*
>   	 * Enable ACPI instead of device tree unless
>   	 * - ACPI has been disabled explicitly (acpi=off), or
> -	 * - the device tree is not empty (it has more than just a /chosen node)
> +	 * - the device tree is not empty (it has more than just a /chosen node,
> +	 *   and a /hypervisor node when running on Xen)

and here too.

if that is addressed,

Acked-by: Hanjun Guo <hanjun.guo@linaro.org>

Thanks
Hanjun

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

* Re: [PATCH v3 12/17] ARM64: ACPI: Check if it runs on Xen to enable or disable ACPI
@ 2016-01-27  8:57       ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-27  8:57 UTC (permalink / raw)
  To: Hanjun Guo, linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: catalin.marinas, will.deacon, julien.grall, xen-devel,
	devicetree, linux-efi, linux-kernel, ian.campbell, shannon.zhao,
	peter.huangpeng



On 2016/1/27 16:27, Hanjun Guo wrote:
> Hi Shannon,
> 
> On 2016/1/23 11:19, Shannon Zhao wrote:
>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>
>> When it's a Xen domain0 booting with ACPI, it will supply a /chosen and
>> a /hypervisor node in DT. So check if it needs to enable ACPI.
>>
>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> ---
>> CC: Hanjun Guo <hanjun.guo@linaro.org>
>> ---
>>   arch/arm64/kernel/acpi.c | 12 ++++++++----
>>   1 file changed, 8 insertions(+), 4 deletions(-)
>>
>> diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
>> index d1ce8e2..4e92be0 100644
>> --- a/arch/arm64/kernel/acpi.c
>> +++ b/arch/arm64/kernel/acpi.c
>> @@ -67,10 +67,13 @@ static int __init dt_scan_depth1_nodes(unsigned
>> long node,
>>   {
>>       /*
>>        * Return 1 as soon as we encounter a node at depth 1 that is
>> -     * not the /chosen node.
>> +     * not the /chosen node, or /hypervisor node when running on Xen.
> 
> The comment is bit misleading, we need to specify two mode, running on
> Xen or not, if not on xen, then /chosen node is enough.
> 
Ok, will rephrase it.

>>        */
>> -    if (depth == 1 && (strcmp(uname, "chosen") != 0))
>> -        return 1;
>> +    if (depth == 1 && (strcmp(uname, "chosen") != 0)) {
>> +        if (!xen_initial_domain() || (strcmp(uname, "hypervisor") != 0))
>> +            return 1;
>> +    }
>> +
>>       return 0;
>>   }
>>
>> @@ -184,7 +187,8 @@ void __init acpi_boot_table_init(void)
>>       /*
>>        * Enable ACPI instead of device tree unless
>>        * - ACPI has been disabled explicitly (acpi=off), or
>> -     * - the device tree is not empty (it has more than just a
>> /chosen node)
>> +     * - the device tree is not empty (it has more than just a
>> /chosen node,
>> +     *   and a /hypervisor node when running on Xen)
> 
> and here too.
> 
> if that is addressed,
> 
> Acked-by: Hanjun Guo <hanjun.guo@linaro.org>
Thanks!

-- 
Shannon

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

* Re: [PATCH v3 12/17] ARM64: ACPI: Check if it runs on Xen to enable or disable ACPI
@ 2016-01-27  8:57       ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-27  8:57 UTC (permalink / raw)
  To: Hanjun Guo, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	stefano.stabellini-Sxgqhf6Nn4DQT0dZR+AlfA,
	david.vrabel-Sxgqhf6Nn4DQT0dZR+AlfA
  Cc: catalin.marinas-5wv7dgnIgG8, will.deacon-5wv7dgnIgG8,
	julien.grall-Sxgqhf6Nn4DQT0dZR+AlfA,
	xen-devel-GuqFBffKawuEi8DpZVb4nw,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-efi-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	ian.campbell-Sxgqhf6Nn4DQT0dZR+AlfA,
	shannon.zhao-QSEj5FYQhm4dnm+yROfE0A,
	peter.huangpeng-hv44wF8Li93QT0dZR+AlfA



On 2016/1/27 16:27, Hanjun Guo wrote:
> Hi Shannon,
> 
> On 2016/1/23 11:19, Shannon Zhao wrote:
>> From: Shannon Zhao <shannon.zhao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
>>
>> When it's a Xen domain0 booting with ACPI, it will supply a /chosen and
>> a /hypervisor node in DT. So check if it needs to enable ACPI.
>>
>> Signed-off-by: Shannon Zhao <shannon.zhao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
>> ---
>> CC: Hanjun Guo <hanjun.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
>> ---
>>   arch/arm64/kernel/acpi.c | 12 ++++++++----
>>   1 file changed, 8 insertions(+), 4 deletions(-)
>>
>> diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
>> index d1ce8e2..4e92be0 100644
>> --- a/arch/arm64/kernel/acpi.c
>> +++ b/arch/arm64/kernel/acpi.c
>> @@ -67,10 +67,13 @@ static int __init dt_scan_depth1_nodes(unsigned
>> long node,
>>   {
>>       /*
>>        * Return 1 as soon as we encounter a node at depth 1 that is
>> -     * not the /chosen node.
>> +     * not the /chosen node, or /hypervisor node when running on Xen.
> 
> The comment is bit misleading, we need to specify two mode, running on
> Xen or not, if not on xen, then /chosen node is enough.
> 
Ok, will rephrase it.

>>        */
>> -    if (depth == 1 && (strcmp(uname, "chosen") != 0))
>> -        return 1;
>> +    if (depth == 1 && (strcmp(uname, "chosen") != 0)) {
>> +        if (!xen_initial_domain() || (strcmp(uname, "hypervisor") != 0))
>> +            return 1;
>> +    }
>> +
>>       return 0;
>>   }
>>
>> @@ -184,7 +187,8 @@ void __init acpi_boot_table_init(void)
>>       /*
>>        * Enable ACPI instead of device tree unless
>>        * - ACPI has been disabled explicitly (acpi=off), or
>> -     * - the device tree is not empty (it has more than just a
>> /chosen node)
>> +     * - the device tree is not empty (it has more than just a
>> /chosen node,
>> +     *   and a /hypervisor node when running on Xen)
> 
> and here too.
> 
> if that is addressed,
> 
> Acked-by: Hanjun Guo <hanjun.guo-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Thanks!

-- 
Shannon

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

* [PATCH v3 12/17] ARM64: ACPI: Check if it runs on Xen to enable or disable ACPI
@ 2016-01-27  8:57       ` Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-27  8:57 UTC (permalink / raw)
  To: linux-arm-kernel



On 2016/1/27 16:27, Hanjun Guo wrote:
> Hi Shannon,
> 
> On 2016/1/23 11:19, Shannon Zhao wrote:
>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>
>> When it's a Xen domain0 booting with ACPI, it will supply a /chosen and
>> a /hypervisor node in DT. So check if it needs to enable ACPI.
>>
>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> ---
>> CC: Hanjun Guo <hanjun.guo@linaro.org>
>> ---
>>   arch/arm64/kernel/acpi.c | 12 ++++++++----
>>   1 file changed, 8 insertions(+), 4 deletions(-)
>>
>> diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
>> index d1ce8e2..4e92be0 100644
>> --- a/arch/arm64/kernel/acpi.c
>> +++ b/arch/arm64/kernel/acpi.c
>> @@ -67,10 +67,13 @@ static int __init dt_scan_depth1_nodes(unsigned
>> long node,
>>   {
>>       /*
>>        * Return 1 as soon as we encounter a node at depth 1 that is
>> -     * not the /chosen node.
>> +     * not the /chosen node, or /hypervisor node when running on Xen.
> 
> The comment is bit misleading, we need to specify two mode, running on
> Xen or not, if not on xen, then /chosen node is enough.
> 
Ok, will rephrase it.

>>        */
>> -    if (depth == 1 && (strcmp(uname, "chosen") != 0))
>> -        return 1;
>> +    if (depth == 1 && (strcmp(uname, "chosen") != 0)) {
>> +        if (!xen_initial_domain() || (strcmp(uname, "hypervisor") != 0))
>> +            return 1;
>> +    }
>> +
>>       return 0;
>>   }
>>
>> @@ -184,7 +187,8 @@ void __init acpi_boot_table_init(void)
>>       /*
>>        * Enable ACPI instead of device tree unless
>>        * - ACPI has been disabled explicitly (acpi=off), or
>> -     * - the device tree is not empty (it has more than just a
>> /chosen node)
>> +     * - the device tree is not empty (it has more than just a
>> /chosen node,
>> +     *   and a /hypervisor node when running on Xen)
> 
> and here too.
> 
> if that is addressed,
> 
> Acked-by: Hanjun Guo <hanjun.guo@linaro.org>
Thanks!

-- 
Shannon

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

* Re: [PATCH v3 12/17] ARM64: ACPI: Check if it runs on Xen to enable or disable ACPI
  2016-01-27  8:27     ` Hanjun Guo
  (?)
  (?)
@ 2016-01-27  8:57     ` Shannon Zhao
  -1 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-27  8:57 UTC (permalink / raw)
  To: Hanjun Guo, linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: devicetree, linux-efi, ian.campbell, catalin.marinas,
	will.deacon, linux-kernel, xen-devel, julien.grall, shannon.zhao,
	peter.huangpeng



On 2016/1/27 16:27, Hanjun Guo wrote:
> Hi Shannon,
> 
> On 2016/1/23 11:19, Shannon Zhao wrote:
>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>
>> When it's a Xen domain0 booting with ACPI, it will supply a /chosen and
>> a /hypervisor node in DT. So check if it needs to enable ACPI.
>>
>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> ---
>> CC: Hanjun Guo <hanjun.guo@linaro.org>
>> ---
>>   arch/arm64/kernel/acpi.c | 12 ++++++++----
>>   1 file changed, 8 insertions(+), 4 deletions(-)
>>
>> diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c
>> index d1ce8e2..4e92be0 100644
>> --- a/arch/arm64/kernel/acpi.c
>> +++ b/arch/arm64/kernel/acpi.c
>> @@ -67,10 +67,13 @@ static int __init dt_scan_depth1_nodes(unsigned
>> long node,
>>   {
>>       /*
>>        * Return 1 as soon as we encounter a node at depth 1 that is
>> -     * not the /chosen node.
>> +     * not the /chosen node, or /hypervisor node when running on Xen.
> 
> The comment is bit misleading, we need to specify two mode, running on
> Xen or not, if not on xen, then /chosen node is enough.
> 
Ok, will rephrase it.

>>        */
>> -    if (depth == 1 && (strcmp(uname, "chosen") != 0))
>> -        return 1;
>> +    if (depth == 1 && (strcmp(uname, "chosen") != 0)) {
>> +        if (!xen_initial_domain() || (strcmp(uname, "hypervisor") != 0))
>> +            return 1;
>> +    }
>> +
>>       return 0;
>>   }
>>
>> @@ -184,7 +187,8 @@ void __init acpi_boot_table_init(void)
>>       /*
>>        * Enable ACPI instead of device tree unless
>>        * - ACPI has been disabled explicitly (acpi=off), or
>> -     * - the device tree is not empty (it has more than just a
>> /chosen node)
>> +     * - the device tree is not empty (it has more than just a
>> /chosen node,
>> +     *   and a /hypervisor node when running on Xen)
> 
> and here too.
> 
> if that is addressed,
> 
> Acked-by: Hanjun Guo <hanjun.guo@linaro.org>
Thanks!

-- 
Shannon

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

* [PATCH v3 00/17] Add ACPI support for Xen Dom0 on ARM64
@ 2016-01-23  3:19 Shannon Zhao
  0 siblings, 0 replies; 145+ messages in thread
From: Shannon Zhao @ 2016-01-23  3:19 UTC (permalink / raw)
  To: linux-arm-kernel, ard.biesheuvel, mark.rutland,
	stefano.stabellini, david.vrabel
  Cc: devicetree, linux-efi, ian.campbell, catalin.marinas,
	will.deacon, linux-kernel, xen-devel, julien.grall, shannon.zhao,
	peter.huangpeng

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

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

This patch set adds a new FDT node "uefi" under /hypervisor to pass UEFI
information. Introduce a bus notifier of AMBA and Platform bus to map
the new added device's MMIO space. Make Xen domain use
xlated_setup_gnttab_pages to setup grant table and a new hypercall to
get event-channel irq.

Regarding the initialization flow of Linux kernel, it needs to move
xen_early_init() before efi_init(). Then xen_early_init() will check
whether it runs on Xen through the /hypervisor node and efi_init() will
call a new function fdt_find_xen_uefi_params(), to parse those
xen,uefi-* parameters just like the existing efi_get_fdt_params().

And in arm64_enable_runtime_services() it will check whether it runs on
Xen and call another new function xen_efi_runtime_setup() to setup
runtime service instead of efi_native_runtime_setup(). The
xen_efi_runtime_setup() will assign the runtime function pointers with
the functions of driver/xen/efi.c.

And since we pass a /hypervisor node and a /chosen node to Dom0, it
needs to check whether the DTS only contains a /hypervisor node and a
/chosen node in acpi_boot_table_init().

Patches are tested on FVP base model. The corresponding Xen patches can
be fetched from [2].

Thanks,
Shannon

[1] http://lists.xen.org/archives/html/xen-devel/2015-11/msg00488.html
[2] http://git.linaro.org/people/shannon.zhao/xen.git  ACPI_XEN_ARM_V3

Changes since v2:
* Use 0 to check if it should ignore the UART
* Fix the use of page_to_xen_pfn
* Factor ACPI and DT parts in xen_guest_init
* Check "uefi" node by full path
* Fix the statement of Documentation/devicetree/bindings/arm/xen.txt

Changes since v1:
* Rebase on linux mainline and wallclock patch from Stefano
* Refactor AMBA and platform device MMIO map to one file
* Use EFI_PARAVIRT to check if it supports XEN EFI
* Refactor Xen EFI codes
* Address other comments

Shannon Zhao (17):
  Xen: ACPI: Hide UART used by Xen
  xen/grant-table: Move xlated_setup_gnttab_pages to common place
  Xen: xlate: Use page_to_xen_pfn instead of page_to_pfn
  arm/xen: Use xen_xlate_map_ballooned_pages to setup grant table
  xen: memory : Add new XENMAPSPACE type XENMAPSPACE_dev_mmio
  Xen: ARM: Add support for mapping platform device mmio
  Xen: ARM: Add support for mapping AMBA device mmio
  Xen: public/hvm: sync changes of HVM_PARAM_CALLBACK_VIA ABI from Xen
  xen/hvm/params: Add a new delivery type for event-channel in
    HVM_PARAM_CALLBACK_IRQ
  arm/xen: Get event-channel irq through HVM_PARAM when booting with
    ACPI
  ARM: XEN: Move xen_early_init() before efi_init()
  ARM64: ACPI: Check if it runs on Xen to enable or disable ACPI
  ARM: Xen: Document UEFI support on Xen ARM virtual platforms
  XEN: EFI: Move x86 specific codes to architecture directory
  ARM64: XEN: Add a function to initialize Xen specific UEFI runtime
    services
  FDT: Add a helper to get specified name subnode
  Xen: EFI: Parse DT parameters for Xen specific UEFI

 Documentation/devicetree/bindings/arm/xen.txt |  34 +++++
 arch/arm/xen/enlighten.c                      | 109 +++++++++++----
 arch/arm64/include/asm/xen/xen-ops.h          |   6 +
 arch/arm64/kernel/acpi.c                      |  12 +-
 arch/arm64/kernel/efi.c                       |  17 ++-
 arch/arm64/kernel/setup.c                     |   2 +-
 arch/arm64/xen/Makefile                       |   1 +
 arch/arm64/xen/efi.c                          |  40 ++++++
 arch/x86/xen/efi.c                            | 112 ++++++++++++++++
 arch/x86/xen/grant-table.c                    |  57 +-------
 drivers/acpi/bus.c                            |  36 ++++-
 drivers/firmware/efi/efi.c                    |  45 ++++++-
 drivers/of/fdt.c                              |  35 +++++
 drivers/xen/Kconfig                           |   2 +-
 drivers/xen/Makefile                          |   1 +
 drivers/xen/arm-device.c                      | 184 ++++++++++++++++++++++++++
 drivers/xen/efi.c                             | 174 +++++-------------------
 drivers/xen/xlate_mmu.c                       |  67 ++++++++++
 include/linux/of_fdt.h                        |   2 +
 include/xen/interface/hvm/params.h            |  36 ++++-
 include/xen/interface/memory.h                |   1 +
 include/xen/xen-ops.h                         |  32 +++--
 22 files changed, 757 insertions(+), 248 deletions(-)
 create mode 100644 arch/arm64/include/asm/xen/xen-ops.h
 create mode 100644 arch/arm64/xen/efi.c
 create mode 100644 drivers/xen/arm-device.c

-- 
2.0.4

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

end of thread, other threads:[~2016-01-27  8:57 UTC | newest]

Thread overview: 145+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-23  3:19 [PATCH v3 00/17] Add ACPI support for Xen Dom0 on ARM64 Shannon Zhao
2016-01-23  3:19 ` Shannon Zhao
2016-01-23  3:19 ` Shannon Zhao
2016-01-23  3:19 ` [PATCH v3 01/17] Xen: ACPI: Hide UART used by Xen Shannon Zhao
2016-01-23  3:19 ` Shannon Zhao
2016-01-23  3:19   ` Shannon Zhao
2016-01-23  3:19   ` Shannon Zhao
2016-01-25 12:20   ` Stefano Stabellini
2016-01-25 12:20     ` Stefano Stabellini
2016-01-25 12:20     ` Stefano Stabellini
2016-01-25 12:20   ` Stefano Stabellini
2016-01-23  3:19 ` [PATCH v3 02/17] xen/grant-table: Move xlated_setup_gnttab_pages to common place Shannon Zhao
2016-01-23  3:19   ` Shannon Zhao
2016-01-23  3:19   ` Shannon Zhao
2016-01-23  3:19 ` [PATCH v3 03/17] Xen: xlate: Use page_to_xen_pfn instead of page_to_pfn Shannon Zhao
2016-01-23  3:19 ` Shannon Zhao
2016-01-23  3:19   ` Shannon Zhao
2016-01-23  3:19   ` Shannon Zhao
2016-01-25 13:55   ` Stefano Stabellini
2016-01-25 13:55   ` Stefano Stabellini
2016-01-25 13:55     ` Stefano Stabellini
2016-01-25 13:55     ` Stefano Stabellini
2016-01-23  3:19 ` [PATCH v3 04/17] arm/xen: Use xen_xlate_map_ballooned_pages to setup grant table Shannon Zhao
2016-01-23  3:19 ` Shannon Zhao
2016-01-23  3:19   ` Shannon Zhao
2016-01-23  3:19   ` Shannon Zhao
2016-01-23  3:19 ` [PATCH v3 05/17] xen: memory : Add new XENMAPSPACE type XENMAPSPACE_dev_mmio Shannon Zhao
2016-01-23  3:19 ` Shannon Zhao
2016-01-23  3:19   ` Shannon Zhao
2016-01-23  3:19   ` Shannon Zhao
2016-01-23  3:19 ` [PATCH v3 06/17] Xen: ARM: Add support for mapping platform device mmio Shannon Zhao
2016-01-23  3:19   ` Shannon Zhao
2016-01-23  3:19   ` Shannon Zhao
2016-01-23  3:19 ` [PATCH v3 07/17] Xen: ARM: Add support for mapping AMBA " Shannon Zhao
2016-01-23  3:19   ` Shannon Zhao
2016-01-23  3:19   ` Shannon Zhao
2016-01-23  3:19 ` [PATCH v3 08/17] Xen: public/hvm: sync changes of HVM_PARAM_CALLBACK_VIA ABI from Xen Shannon Zhao
2016-01-23  3:19   ` Shannon Zhao
2016-01-23  3:19   ` Shannon Zhao
2016-01-25 15:06   ` Stefano Stabellini
2016-01-25 15:06     ` Stefano Stabellini
2016-01-25 15:06     ` Stefano Stabellini
2016-01-25 15:06   ` Stefano Stabellini
2016-01-23  3:19 ` [PATCH v3 09/17] xen/hvm/params: Add a new delivery type for event-channel in HVM_PARAM_CALLBACK_IRQ Shannon Zhao
2016-01-23  3:19   ` Shannon Zhao
2016-01-23  3:19   ` Shannon Zhao
2016-01-25 15:08   ` Stefano Stabellini
2016-01-25 15:08   ` Stefano Stabellini
2016-01-25 15:08     ` Stefano Stabellini
2016-01-25 15:08     ` Stefano Stabellini
2016-01-23  3:19 ` Shannon Zhao
2016-01-23  3:19 ` [PATCH v3 10/17] arm/xen: Get event-channel irq through HVM_PARAM when booting with ACPI Shannon Zhao
2016-01-23  3:19   ` Shannon Zhao
2016-01-23  3:19   ` Shannon Zhao
2016-01-25 15:19   ` Stefano Stabellini
2016-01-25 15:19   ` Stefano Stabellini
2016-01-25 15:19     ` Stefano Stabellini
2016-01-25 15:19     ` Stefano Stabellini
2016-01-23  3:19 ` [PATCH v3 11/17] ARM: XEN: Move xen_early_init() before efi_init() Shannon Zhao
2016-01-23  3:19 ` Shannon Zhao
2016-01-23  3:19   ` Shannon Zhao
2016-01-23  3:19   ` Shannon Zhao
2016-01-25 15:25   ` Stefano Stabellini
2016-01-25 15:25     ` Stefano Stabellini
2016-01-25 15:25     ` Stefano Stabellini
2016-01-25 15:25   ` Stefano Stabellini
2016-01-23  3:19 ` [PATCH v3 12/17] ARM64: ACPI: Check if it runs on Xen to enable or disable ACPI Shannon Zhao
2016-01-23  3:19 ` Shannon Zhao
2016-01-23  3:19   ` Shannon Zhao
2016-01-23  3:19   ` Shannon Zhao
2016-01-25 15:32   ` Stefano Stabellini
2016-01-25 15:32     ` Stefano Stabellini
2016-01-25 15:32     ` Stefano Stabellini
2016-01-25 15:32   ` Stefano Stabellini
2016-01-27  8:27   ` Hanjun Guo
2016-01-27  8:27     ` Hanjun Guo
2016-01-27  8:57     ` Shannon Zhao
2016-01-27  8:57       ` Shannon Zhao
2016-01-27  8:57       ` Shannon Zhao
2016-01-27  8:57     ` Shannon Zhao
2016-01-27  8:27   ` Hanjun Guo
2016-01-23  3:19 ` [PATCH v3 13/17] ARM: Xen: Document UEFI support on Xen ARM virtual platforms Shannon Zhao
2016-01-23  3:19 ` Shannon Zhao
2016-01-23  3:19   ` Shannon Zhao
2016-01-23  3:19   ` Shannon Zhao
2016-01-25 15:50   ` Stefano Stabellini
2016-01-25 15:50     ` Stefano Stabellini
2016-01-25 15:50     ` Stefano Stabellini
2016-01-25 15:59     ` Mark Rutland
2016-01-25 15:59       ` Mark Rutland
2016-01-25 15:59       ` Mark Rutland
2016-01-25 16:06       ` Stefano Stabellini
2016-01-25 16:06       ` Stefano Stabellini
2016-01-25 16:06         ` Stefano Stabellini
2016-01-25 16:06         ` Stefano Stabellini
2016-01-25 15:50   ` Stefano Stabellini
2016-01-23  3:19 ` [PATCH v3 14/17] XEN: EFI: Move x86 specific codes to architecture directory Shannon Zhao
2016-01-23  3:19   ` Shannon Zhao
2016-01-23  3:19   ` Shannon Zhao
2016-01-25 16:44   ` Stefano Stabellini
2016-01-25 16:44     ` Stefano Stabellini
2016-01-25 16:44     ` Stefano Stabellini
2016-01-26  8:16     ` Shannon Zhao
2016-01-26  8:16     ` Shannon Zhao
2016-01-26  8:16       ` Shannon Zhao
2016-01-26  8:16       ` Shannon Zhao
2016-01-26 11:31       ` Stefano Stabellini
2016-01-26 11:31         ` Stefano Stabellini
2016-01-26 11:31         ` Stefano Stabellini
2016-01-26 12:26         ` Shannon Zhao
2016-01-26 12:26         ` Shannon Zhao
2016-01-26 12:26           ` Shannon Zhao
2016-01-26 12:26           ` Shannon Zhao
2016-01-26 11:31       ` Stefano Stabellini
2016-01-25 16:44   ` Stefano Stabellini
2016-01-23  3:19 ` [PATCH v3 15/17] ARM64: XEN: Add a function to initialize Xen specific UEFI runtime services Shannon Zhao
2016-01-23  3:19   ` Shannon Zhao
2016-01-23  3:19   ` Shannon Zhao
2016-01-25 16:47   ` Stefano Stabellini
2016-01-25 16:47   ` Stefano Stabellini
2016-01-25 16:47     ` Stefano Stabellini
2016-01-25 16:47     ` Stefano Stabellini
2016-01-23  3:19 ` [PATCH v3 16/17] FDT: Add a helper to get specified name subnode Shannon Zhao
2016-01-23  3:19   ` Shannon Zhao
2016-01-23  3:19   ` Shannon Zhao
2016-01-26 12:11   ` Stefano Stabellini
2016-01-26 12:11     ` Stefano Stabellini
2016-01-26 12:11     ` Stefano Stabellini
2016-01-26 12:27     ` Shannon Zhao
2016-01-26 12:27     ` Shannon Zhao
2016-01-26 12:27       ` Shannon Zhao
2016-01-26 12:27       ` Shannon Zhao
2016-01-26 12:11   ` Stefano Stabellini
2016-01-23  3:19 ` [PATCH v3 17/17] Xen: EFI: Parse DT parameters for Xen specific UEFI Shannon Zhao
2016-01-23  3:19 ` Shannon Zhao
2016-01-23  3:19   ` Shannon Zhao
2016-01-23  3:19   ` Shannon Zhao
2016-01-26 11:41   ` Stefano Stabellini
2016-01-26 11:41     ` Stefano Stabellini
2016-01-26 11:41     ` Stefano Stabellini
2016-01-26 11:41   ` Stefano Stabellini
2016-01-26 12:05   ` Matt Fleming
2016-01-26 12:05     ` Matt Fleming
2016-01-26 12:05   ` Matt Fleming
2016-01-23  3:19 [PATCH v3 00/17] Add ACPI support for Xen Dom0 on ARM64 Shannon Zhao

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.