Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1359694 > unrolled thread

[PATCH v6 00/17] Add ACPI support for Xen Dom0 on ARM64

Started byShannon Zhao <zhaoshenglong@huawei.com>
First post2016-03-17 11:10 +0100
Last post2016-03-24 13:30 +0100
Articles 8 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v6 00/17] Add ACPI support for Xen Dom0 on ARM64 Shannon Zhao <zhaoshenglong@huawei.com> - 2016-03-17 11:10 +0100
    [PATCH v6 03/17] Xen: xlate: Use page_to_xen_pfn instead of page_to_pfn Shannon Zhao <zhaoshenglong@huawei.com> - 2016-03-17 11:10 +0100
    [PATCH v6 05/17] xen: memory : Add new XENMAPSPACE type XENMAPSPACE_dev_mmio Shannon Zhao <zhaoshenglong@huawei.com> - 2016-03-17 11:10 +0100
    [PATCH v6 06/17] Xen: ARM: Add support for mapping platform device mmio Shannon Zhao <zhaoshenglong@huawei.com> - 2016-03-17 11:10 +0100
    [PATCH v6 01/17] Xen: ACPI: Hide UART used by Xen Shannon Zhao <zhaoshenglong@huawei.com> - 2016-03-17 11:10 +0100
      Re: [PATCH v6 01/17] Xen: ACPI: Hide UART used by Xen "Rafael J. Wysocki" <rafael@kernel.org> - 2016-03-17 14:00 +0100
    [PATCH v6 08/17] Xen: public/hvm: sync changes of HVM_PARAM_CALLBACK_VIA ABI from Xen Shannon Zhao <zhaoshenglong@huawei.com> - 2016-03-17 11:10 +0100
    Re: [PATCH v6 00/17] Add ACPI support for Xen Dom0 on ARM64 Stefano Stabellini <stefano.stabellini@eu.citrix.com> - 2016-03-24 13:30 +0100

#1359694 — [PATCH v6 00/17] Add ACPI support for Xen Dom0 on ARM64

FromShannon Zhao <zhaoshenglong@huawei.com>
Date2016-03-17 11:10 +0100
Subject[PATCH v6 00/17] Add ACPI support for Xen Dom0 on ARM64
Message-ID<rdCSK-5Ht-5@gated-at.bofh.it>
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.

Thanks,
Shannon

[1] http://lists.xen.org/archives/html/xen-devel/2015-11/msg00488.html

Changes since v5:
* rebase on linux master
* use acpi_dev_resource_memory to parse the device memory info(patch 1)
* sync with Xen (patch 9)

Changes since v4:
* rebase on linux master
* move the check acpi_device_should_be_hidden into
  acpi_bus_type_and_status (patch 1)
* use existing function fdt_subnode_offset (patch 16)

Changes since v3:
* rebase on linux master
* print a warning when there is no SPCR table
* rephase the commit message of PATCH 3
* rephase the words of PATCH 13
* use strcmp and factor the function in PATCH 16
* Add several ACKs and RBs, thanks a lot


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 the subnode by given name
  Xen: EFI: Parse DT parameters for Xen specific UEFI

 Documentation/devicetree/bindings/arm/xen.txt |  33 +++++
 arch/arm/include/asm/xen/xen-ops.h            |   6 +
 arch/arm/xen/Makefile                         |   1 +
 arch/arm/xen/efi.c                            |  40 ++++++
 arch/arm/xen/enlighten.c                      | 109 +++++++++++----
 arch/arm64/include/asm/xen/xen-ops.h          |   6 +
 arch/arm64/kernel/acpi.c                      |  12 +-
 arch/arm64/kernel/setup.c                     |   2 +-
 arch/arm64/xen/Makefile                       |   1 +
 arch/x86/xen/efi.c                            | 112 ++++++++++++++++
 arch/x86/xen/grant-table.c                    |  57 +-------
 drivers/acpi/scan.c                           |  63 +++++++++
 drivers/firmware/efi/arm-runtime.c            |  17 ++-
 drivers/firmware/efi/efi.c                    |  45 ++++++-
 drivers/of/fdt.c                              |  13 ++
 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            |  40 +++++-
 include/xen/interface/memory.h                |   1 +
 include/xen/xen-ops.h                         |  32 +++--
 24 files changed, 773 insertions(+), 247 deletions(-)
 create mode 100644 arch/arm/include/asm/xen/xen-ops.h
 create mode 100644 arch/arm/xen/efi.c
 create mode 100644 arch/arm64/include/asm/xen/xen-ops.h
 create mode 100644 drivers/xen/arm-device.c

-- 
2.0.4

[toc] | [next] | [standalone]


#1359695 — [PATCH v6 03/17] Xen: xlate: Use page_to_xen_pfn instead of page_to_pfn

FromShannon Zhao <zhaoshenglong@huawei.com>
Date2016-03-17 11:10 +0100
Subject[PATCH v6 03/17] Xen: xlate: Use page_to_xen_pfn instead of page_to_pfn
Message-ID<rdD2r-626-21@gated-at.bofh.it>
In reply to#1359694
From: Shannon Zhao <shannon.zhao@linaro.org>

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.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
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

[toc] | [prev] | [next] | [standalone]


#1359698 — [PATCH v6 05/17] xen: memory : Add new XENMAPSPACE type XENMAPSPACE_dev_mmio

FromShannon Zhao <zhaoshenglong@huawei.com>
Date2016-03-17 11:10 +0100
Subject[PATCH v6 05/17] xen: memory : Add new XENMAPSPACE type XENMAPSPACE_dev_mmio
Message-ID<rdD2s-626-31@gated-at.bofh.it>
In reply to#1359694
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

[toc] | [prev] | [next] | [standalone]


#1359699 — [PATCH v6 06/17] Xen: ARM: Add support for mapping platform device mmio

FromShannon Zhao <zhaoshenglong@huawei.com>
Date2016-03-17 11:10 +0100
Subject[PATCH v6 06/17] Xen: ARM: Add support for mapping platform device mmio
Message-ID<rdD2s-626-33@gated-at.bofh.it>
In reply to#1359694
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 9b7a35c..415f286 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

[toc] | [prev] | [next] | [standalone]


#1359700 — [PATCH v6 01/17] Xen: ACPI: Hide UART used by Xen

FromShannon Zhao <zhaoshenglong@huawei.com>
Date2016-03-17 11:10 +0100
Subject[PATCH v6 01/17] Xen: ACPI: Hide UART used by Xen
Message-ID<rdD2s-626-35@gated-at.bofh.it>
In reply to#1359694
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/scan.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)

diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 5f28cf7..55ceb69 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -45,6 +45,7 @@ static LIST_HEAD(acpi_scan_handlers_list);
 DEFINE_MUTEX(acpi_device_lock);
 LIST_HEAD(acpi_wakeup_device_list);
 static DEFINE_MUTEX(acpi_hp_context_lock);
+static u64 spcr_uart_addr;
 
 struct acpi_dep_data {
 	struct list_head node;
@@ -1453,6 +1454,41 @@ static int acpi_add_single_object(struct acpi_device **child,
 	return 0;
 }
 
+static acpi_status acpi_get_resource_memory(struct acpi_resource *ares,
+					    void *context)
+{
+	struct resource *res = context;
+
+	if (acpi_dev_resource_memory(ares, res))
+		return AE_CTRL_TERMINATE;
+
+	return AE_OK;
+}
+
+static bool acpi_device_should_be_hidden(acpi_handle handle)
+{
+	acpi_status status;
+	struct resource res;
+
+	/* Check if it should ignore the UART device */
+	if (spcr_uart_addr != 0) {
+		if (!acpi_has_method(handle, METHOD_NAME__CRS))
+			return false;
+
+		status = acpi_walk_resources(handle, METHOD_NAME__CRS,
+					     acpi_get_resource_memory, &res);
+		if (ACPI_FAILURE(status))
+			return false;
+
+		if (res.start == spcr_uart_addr) {
+			printk(KERN_INFO PREFIX "The UART device in SPCR table will be hidden\n");
+			return true;
+		}
+	}
+
+	return false;
+}
+
 static int acpi_bus_type_and_status(acpi_handle handle, int *type,
 				    unsigned long long *sta)
 {
@@ -1466,6 +1502,9 @@ static int acpi_bus_type_and_status(acpi_handle handle, int *type,
 	switch (acpi_type) {
 	case ACPI_TYPE_ANY:		/* for ACPI_ROOT_OBJECT */
 	case ACPI_TYPE_DEVICE:
+		if (acpi_device_should_be_hidden(handle))
+			return -ENODEV;
+
 		*type = ACPI_BUS_TYPE_DEVICE;
 		status = acpi_bus_get_status_handle(handle, sta);
 		if (ACPI_FAILURE(status))
@@ -1919,6 +1958,8 @@ static int acpi_bus_scan_fixed(void)
 int __init acpi_scan_init(void)
 {
 	int result;
+	acpi_status status;
+	struct acpi_table_stao *stao_ptr;
 
 	acpi_pci_root_init();
 	acpi_pci_link_init();
@@ -1934,6 +1975,28 @@ int __init acpi_scan_init(void)
 
 	acpi_scan_add_handler(&generic_device_handler);
 
+	/*
+	 * 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)) {
+		if (stao_ptr->header.length > sizeof(struct acpi_table_stao))
+			printk(KERN_INFO PREFIX "STAO Name List not yet supported.");
+
+		if (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 PREFIX "STAO table present, but SPCR is missing\n");
+		}
+	}
+
 	mutex_lock(&acpi_scan_lock);
 	/*
 	 * Enumerate devices in the ACPI namespace.
-- 
2.0.4

[toc] | [prev] | [next] | [standalone]


#1359828 — Re: [PATCH v6 01/17] Xen: ACPI: Hide UART used by Xen

From"Rafael J. Wysocki" <rafael@kernel.org>
Date2016-03-17 14:00 +0100
SubjectRe: [PATCH v6 01/17] Xen: ACPI: Hide UART used by Xen
Message-ID<rdFGY-7xG-33@gated-at.bofh.it>
In reply to#1359700
On Thu, Mar 17, 2016 at 10:57 AM, Shannon Zhao <zhaoshenglong@huawei.com> 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/scan.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 63 insertions(+)
>
> diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
> index 5f28cf7..55ceb69 100644
> --- a/drivers/acpi/scan.c
> +++ b/drivers/acpi/scan.c
> @@ -45,6 +45,7 @@ static LIST_HEAD(acpi_scan_handlers_list);
>  DEFINE_MUTEX(acpi_device_lock);
>  LIST_HEAD(acpi_wakeup_device_list);
>  static DEFINE_MUTEX(acpi_hp_context_lock);
> +static u64 spcr_uart_addr;
>
>  struct acpi_dep_data {
>         struct list_head node;
> @@ -1453,6 +1454,41 @@ static int acpi_add_single_object(struct acpi_device **child,
>         return 0;
>  }
>
> +static acpi_status acpi_get_resource_memory(struct acpi_resource *ares,
> +                                           void *context)
> +{
> +       struct resource *res = context;
> +
> +       if (acpi_dev_resource_memory(ares, res))
> +               return AE_CTRL_TERMINATE;
> +
> +       return AE_OK;
> +}
> +
> +static bool acpi_device_should_be_hidden(acpi_handle handle)
> +{
> +       acpi_status status;
> +       struct resource res;
> +
> +       /* Check if it should ignore the UART device */
> +       if (spcr_uart_addr != 0) {
> +               if (!acpi_has_method(handle, METHOD_NAME__CRS))
> +                       return false;
> +
> +               status = acpi_walk_resources(handle, METHOD_NAME__CRS,
> +                                            acpi_get_resource_memory, &res);
> +               if (ACPI_FAILURE(status))
> +                       return false;
> +
> +               if (res.start == spcr_uart_addr) {
> +                       printk(KERN_INFO PREFIX "The UART device in SPCR table will be hidden\n");
> +                       return true;
> +               }
> +       }
> +
> +       return false;
> +}
> +
>  static int acpi_bus_type_and_status(acpi_handle handle, int *type,
>                                     unsigned long long *sta)
>  {
> @@ -1466,6 +1502,9 @@ static int acpi_bus_type_and_status(acpi_handle handle, int *type,
>         switch (acpi_type) {
>         case ACPI_TYPE_ANY:             /* for ACPI_ROOT_OBJECT */
>         case ACPI_TYPE_DEVICE:
> +               if (acpi_device_should_be_hidden(handle))
> +                       return -ENODEV;
> +
>                 *type = ACPI_BUS_TYPE_DEVICE;
>                 status = acpi_bus_get_status_handle(handle, sta);
>                 if (ACPI_FAILURE(status))
> @@ -1919,6 +1958,8 @@ static int acpi_bus_scan_fixed(void)
>  int __init acpi_scan_init(void)
>  {
>         int result;
> +       acpi_status status;
> +       struct acpi_table_stao *stao_ptr;
>
>         acpi_pci_root_init();
>         acpi_pci_link_init();
> @@ -1934,6 +1975,28 @@ int __init acpi_scan_init(void)
>
>         acpi_scan_add_handler(&generic_device_handler);
>
> +       /*
> +        * 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)) {
> +               if (stao_ptr->header.length > sizeof(struct acpi_table_stao))
> +                       printk(KERN_INFO PREFIX "STAO Name List not yet supported.");
> +
> +               if (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 PREFIX "STAO table present, but SPCR is missing\n");
> +               }
> +       }

I'd put the above part into a separate function and call that from
here.  You'd be able to reduce the indentation level then slightly
without using gotos.

Apart from this minor point the patch is fine by me.

> +
>         mutex_lock(&acpi_scan_lock);
>         /*
>          * Enumerate devices in the ACPI namespace.
> --

Thanks,
Rafael

[toc] | [prev] | [next] | [standalone]


#1359701 — [PATCH v6 08/17] Xen: public/hvm: sync changes of HVM_PARAM_CALLBACK_VIA ABI from Xen

FromShannon Zhao <zhaoshenglong@huawei.com>
Date2016-03-17 11:10 +0100
Subject[PATCH v6 08/17] Xen: public/hvm: sync changes of HVM_PARAM_CALLBACK_VIA ABI from Xen
Message-ID<rdD2s-626-37@gated-at.bofh.it>
In reply to#1359694
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

[toc] | [prev] | [next] | [standalone]


#1364112

FromStefano Stabellini <stefano.stabellini@eu.citrix.com>
Date2016-03-24 13:30 +0100
Message-ID<rgcyK-2B9-3@gated-at.bofh.it>
In reply to#1359694
On Thu, 17 Mar 2016, Shannon Zhao wrote:
> 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.

I have no further comments on this series. Please address the minor
point by Rafael, and resubmit.


> Thanks,
> Shannon
> 
> [1] http://lists.xen.org/archives/html/xen-devel/2015-11/msg00488.html
> 
> Changes since v5:
> * rebase on linux master
> * use acpi_dev_resource_memory to parse the device memory info(patch 1)
> * sync with Xen (patch 9)
> 
> Changes since v4:
> * rebase on linux master
> * move the check acpi_device_should_be_hidden into
>   acpi_bus_type_and_status (patch 1)
> * use existing function fdt_subnode_offset (patch 16)
> 
> Changes since v3:
> * rebase on linux master
> * print a warning when there is no SPCR table
> * rephase the commit message of PATCH 3
> * rephase the words of PATCH 13
> * use strcmp and factor the function in PATCH 16
> * Add several ACKs and RBs, thanks a lot
> 
> 
> 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 the subnode by given name
>   Xen: EFI: Parse DT parameters for Xen specific UEFI
> 
>  Documentation/devicetree/bindings/arm/xen.txt |  33 +++++
>  arch/arm/include/asm/xen/xen-ops.h            |   6 +
>  arch/arm/xen/Makefile                         |   1 +
>  arch/arm/xen/efi.c                            |  40 ++++++
>  arch/arm/xen/enlighten.c                      | 109 +++++++++++----
>  arch/arm64/include/asm/xen/xen-ops.h          |   6 +
>  arch/arm64/kernel/acpi.c                      |  12 +-
>  arch/arm64/kernel/setup.c                     |   2 +-
>  arch/arm64/xen/Makefile                       |   1 +
>  arch/x86/xen/efi.c                            | 112 ++++++++++++++++
>  arch/x86/xen/grant-table.c                    |  57 +-------
>  drivers/acpi/scan.c                           |  63 +++++++++
>  drivers/firmware/efi/arm-runtime.c            |  17 ++-
>  drivers/firmware/efi/efi.c                    |  45 ++++++-
>  drivers/of/fdt.c                              |  13 ++
>  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            |  40 +++++-
>  include/xen/interface/memory.h                |   1 +
>  include/xen/xen-ops.h                         |  32 +++--
>  24 files changed, 773 insertions(+), 247 deletions(-)
>  create mode 100644 arch/arm/include/asm/xen/xen-ops.h
>  create mode 100644 arch/arm/xen/efi.c
>  create mode 100644 arch/arm64/include/asm/xen/xen-ops.h
>  create mode 100644 drivers/xen/arm-device.c
> 
> -- 
> 2.0.4
> 
> 

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web