From: Shannon Zhao <redacted>
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_V4
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 specified name subnode
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/bus.c | 38 +++++-
drivers/firmware/efi/arm-runtime.c | 17 ++-
drivers/firmware/efi/efi.c | 45 ++++++-
drivers/of/fdt.c | 25 ++++
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 +++--
24 files changed, 755 insertions(+), 248 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
From: Shannon Zhao <redacted>
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 <redacted>
Reviewed-by: Stefano Stabellini <redacted>
---
drivers/xen/xlate_mmu.c | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
From: Shannon Zhao <redacted>
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 <redacted>
Reviewed-by: Stefano Stabellini <redacted>
---
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(-)
@@ -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>-staticint__initxlated_setup_gnttab_pages(void)-{-structpage**pages;-xen_pfn_t*pfns;-void*vaddr;-intrc;-unsignedinti;-unsignedlongnr_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);-returnrc;-}-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;--return0;-}-+#include<xen/xen-ops.h>staticint__initxen_pvh_gnttab_setup(void){if(!xen_pvh_domain())return-ENODEV;-returnxlated_setup_gnttab_pages();+xen_auto_xlat_grant_frames.count=gnttab_max_grant_frames();++returnxen_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_framesfirst.*/
From: Shannon Zhao <redacted>
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 <redacted>
Acked-by: Stefano Stabellini <redacted>
---
include/xen/interface/hvm/params.h | 9 +++++++++
1 file changed, 9 insertions(+)
@@ -0,0 +1,40 @@+/*+*Copyright(c)2015,LinaroLimited,ShannonZhao+*+*Thisprogramisfreesoftware;youcanredistributeitand/ormodify+*itunderthetermsoftheGNUGeneralPublicLicenseaspublishedby+*theFreeSoftwareFoundation;eitherversion2oftheLicense,or+*(atyouroption)anylaterversion.+*+*Thisprogramisdistributedinthehopethatitwillbeuseful,+*butWITHOUTANYWARRANTY;withouteventheimpliedwarrantyof+*MERCHANTABILITYorFITNESSFORAPARTICULARPURPOSE.Seethe+*GNUGeneralPublicLicenseformoredetails.+*+*YoushouldhavereceivedacopyoftheGNUGeneralPublicLicensealong+*withthisprogram.Ifnot,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 fields of struct efi,+*e.g.efi.systab,willbesetlikenormalEFI.+*/+void__initxen_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);
From: Shannon Zhao <redacted>
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 <redacted>
Reviewed-by: Stefano Stabellini <redacted>
---
arch/x86/xen/efi.c | 112 ++++++++++++++++++++++++++++++++
drivers/xen/efi.c | 174 ++++++++++----------------------------------------
include/xen/xen-ops.h | 30 ++++++---
3 files changed, 168 insertions(+), 148 deletions(-)
@@ -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>++staticefi_char16_tvendor[100]__initdata;++staticefi_system_table_tefi_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. */+};++staticconststructefiefi_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. */+};++staticefi_system_table_t__init*xen_efi_probe(void)+{+structxen_platform_opop={+.cmd=XENPF_firmware_info,+.u.firmware_info={+.type=XEN_FW_EFI_INFO,+.index=XEN_FW_EFI_CONFIG_TABLE+}+};+unionxenpf_efi_info*info=&op.u.firmware_info.u.efi_info;++if(!xen_initial_domain()||HYPERVISOR_platform_op(&op)<0)+returnNULL;++/* 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__initxen_efi_init(void){
@@ -260,112 +262,4 @@ static efi_status_t xen_efi_query_capsule_caps(efi_capsule_header_t **capsules,returnefi_data(op).status;}--staticefi_char16_tvendor[100]__initdata;--staticefi_system_table_tefi_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. */-};--staticconststructefiefi_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)-{-structxen_platform_opop={-.cmd=XENPF_firmware_info,-.u.firmware_info={-.type=XEN_FW_EFI_INFO,-.index=XEN_FW_EFI_CONFIG_TABLE-}-};-unionxenpf_efi_info*info=&op.u.firmware_info.u.efi_info;--if(!xen_initial_domain()||HYPERVISOR_platform_op(&op)<0)-returnNULL;--/* 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);
From: Shannon Zhao <redacted>
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 <redacted>
Reviewed-by: Matt Fleming <redacted>
Reviewed-by: Stefano Stabellini <redacted>
---
CC: Matt Fleming <redacted>
---
arch/arm/xen/enlighten.c | 6 +++++
drivers/firmware/efi/arm-runtime.c | 17 +++++++++-----
drivers/firmware/efi/efi.c | 45 ++++++++++++++++++++++++++++++++------
3 files changed, 56 insertions(+), 12 deletions(-)
@@ -107,13 +108,19 @@ static int __init arm_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;
From: Shannon Zhao <redacted>
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 <redacted>
---
CC: Rob Herring <robh@kernel.org>
---
drivers/of/fdt.c | 25 +++++++++++++++++++++++++
include/linux/of_fdt.h | 2 ++
2 files changed, 27 insertions(+)
@@ -645,6 +645,31 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node,}/**+*of_get_flat_dt_subnode_by_name-getsubnodeofspecifiednodebyname+*+*@node:theparentnode+*@uname:thenameofsubnode+*@returnoffsetofthesubnode,or-FDT_ERR_NOTFOUNDifthereisnone+*/++intof_get_flat_dt_subnode_by_name(unsignedlongnode,constchar*uname)+{+constvoid*blob=initial_boot_params;+intoffset;+constchar*pathp;++for(offset=fdt_first_subnode(blob,node);+offset>=0;+offset=fdt_next_subnode(blob,offset)){+pathp=fdt_get_name(blob,offset,NULL);+if(strcmp(pathp,uname)==0)+returnoffset;+}++return-FDT_ERR_NOTFOUND;+}++/***of_get_flat_dt_root-findtherootnodeintheflatblob*/unsignedlong__initof_get_flat_dt_root(void)
From: Shannon Zhao <redacted>
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 <redacted>
@@ -645,6 +645,31 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node,}/**+*of_get_flat_dt_subnode_by_name-getsubnodeofspecifiednodebyname+*+*@node:theparentnode+*@uname:thenameofsubnode+*@returnoffsetofthesubnode,or-FDT_ERR_NOTFOUNDifthereisnone+*/++intof_get_flat_dt_subnode_by_name(unsignedlongnode,constchar*uname)+{+constvoid*blob=initial_boot_params;+intoffset;+constchar*pathp;++for(offset=fdt_first_subnode(blob,node);+offset>=0;+offset=fdt_next_subnode(blob,offset)){+pathp=fdt_get_name(blob,offset,NULL);+if(strcmp(pathp,uname)==0)+returnoffset;+}++return-FDT_ERR_NOTFOUND;+}++/***of_get_flat_dt_root-findtherootnodeintheflatblob*/unsignedlong__initof_get_flat_dt_root(void)
@@ -645,6 +645,31 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node,}/**+*of_get_flat_dt_subnode_by_name-getsubnodeofspecifiednodebyname+*+*@node:theparentnode+*@uname:thenameofsubnode+*@returnoffsetofthesubnode,or-FDT_ERR_NOTFOUNDifthereisnone+*/++intof_get_flat_dt_subnode_by_name(unsignedlongnode,constchar*uname)+{+constvoid*blob=initial_boot_params;+intoffset;+constchar*pathp;++for(offset=fdt_first_subnode(blob,node);+offset>=0;+offset=fdt_next_subnode(blob,offset)){+pathp=fdt_get_name(blob,offset,NULL);+if(strcmp(pathp,uname)==0)+returnoffset;+}++return-FDT_ERR_NOTFOUND;+}++/***of_get_flat_dt_root-findtherootnodeintheflatblob*/unsignedlong__initof_get_flat_dt_root(void)
2.0.4
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
On Thu, Feb 4, 2016 at 9:05 PM, Shannon Zhao [off-list ref] wrote:
quoted
From: Shannon Zhao <redacted>
Sometimes it needs to check if there is a node in FDT by full path.
I'm confused. Are you searching by full path or...
quoted
Introduce this helper to get the specified name subnode if it exists.
name of sub node?
get the offset of sub node by specified name.
Either way, fdt_subnode_offset or fdt_path_offset doesn't work?
Ah?right?both of them should work. Does it need to add a wrapper in
drivers/of/fdt.c for them or directly use them with the parameter
initial_boot_params?
Thanks,
@@ -645,6 +645,31 @@ int __init of_scan_flat_dt(int (*it)(unsigned long node,}/**+*of_get_flat_dt_subnode_by_name-getsubnodeofspecifiednodebyname+*+*@node:theparentnode+*@uname:thenameofsubnode+*@returnoffsetofthesubnode,or-FDT_ERR_NOTFOUNDifthereisnone+*/++intof_get_flat_dt_subnode_by_name(unsignedlongnode,constchar*uname)+{+constvoid*blob=initial_boot_params;+intoffset;+constchar*pathp;++for(offset=fdt_first_subnode(blob,node);+offset>=0;+offset=fdt_next_subnode(blob,offset)){+pathp=fdt_get_name(blob,offset,NULL);+if(strcmp(pathp,uname)==0)+returnoffset;+}++return-FDT_ERR_NOTFOUND;+}++/***of_get_flat_dt_root-findtherootnodeintheflatblob*/unsignedlong__initof_get_flat_dt_root(void)
2.0.4
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Rob Herring <robh@kernel.org> Date: 2016-02-24 14:54:16
On Tue, Feb 23, 2016 at 5:13 AM, Shannon Zhao [off-list ref] wrote:
On 2016/2/9 13:04, Rob Herring wrote:
quoted
On Thu, Feb 4, 2016 at 9:05 PM, Shannon Zhao [off-list ref] wrote:
quoted
From: Shannon Zhao <redacted>
Sometimes it needs to check if there is a node in FDT by full path.
I'm confused. Are you searching by full path or...
quoted
Introduce this helper to get the specified name subnode if it exists.
name of sub node?
get the offset of sub node by specified name.
quoted
Either way, fdt_subnode_offset or fdt_path_offset doesn't work?
Ah?right?both of them should work. Does it need to add a wrapper in
drivers/of/fdt.c for them or directly use them with the parameter
initial_boot_params?
From: Shannon Zhao <redacted>
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 <redacted>
Reviewed-by: Stefano Stabellini <redacted>
Acked-by: Hanjun Guo <redacted>
---
CC: Hanjun Guo <redacted>
---
arch/arm64/kernel/acpi.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
@@ -67,10 +67,13 @@ static int __init dt_scan_depth1_nodes(unsigned long node,{/**Return1assoonasweencounteranodeatdepth1thatis-*notthe/chosennode.+*notthe/chosennode,or/hypervisornodewhenrunningonXen.*/-if(depth==1&&(strcmp(uname,"chosen")!=0))-return1;+if(depth==1&&(strcmp(uname,"chosen")!=0)){+if(!xen_initial_domain()||(strcmp(uname,"hypervisor")!=0))+return1;+}+return0;}
@@ -245,26 +271,18 @@ static irqreturn_t xen_arm_callback(int irq, void *arg)#define GRANT_TABLE_PHYSADDR 0void__initxen_early_init(void){-intlen;-constchar*s=NULL;-constchar*version=NULL;-constchar*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;
@@ -305,6 +323,14 @@ static void __init xen_acpi_guest_init(void)staticvoid__initxen_dt_guest_init(void){+structdevice_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);}
From: Shannon Zhao <redacted>
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 <redacted>
Acked-by: Rob Herring <robh@kernel.org>
---
CC: Rob Herring <robh@kernel.org>
---
Documentation/devicetree/bindings/arm/xen.txt | 33 +++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
@@ -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,17 @@ hypervisor { compatible = "xen,xen-4.3", "xen,xen"; reg = <0 0xb0000000 0 0x20000>; interrupts = <1 15 0xf08>;+ uefi {+ xen,uefi-system-table = <0xXXXXXXXX>;+ xen,uefi-mmap-start = <0xXXXXXXXX>;+ xen,uefi-mmap-size = <0xXXXXXXXX>;+ xen,uefi-mmap-desc-size = <0xXXXXXXXX>;+ xen,uefi-mmap-desc-ver = <0xXXXXXXXX>;+ }; };++The format and meaning of the "xen,uefi-*" parameters are similar to those in+Documentation/arm/uefi.txt, which are provided by the regular UEFI stub. However+they differ because they are provided by the Xen hypervisor, together with a set+of UEFI runtime services implemented via hypercalls, see+http://xenbits.xen.org/docs/unstable/hypercall/x86_64/include,public,platform.h.html.
From: Shannon Zhao <redacted>
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 <redacted>
Acked-by: Rob Herring <robh@kernel.org>
@@ -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,17 @@ hypervisor { compatible = "xen,xen-4.3", "xen,xen"; reg = <0 0xb0000000 0 0x20000>; interrupts = <1 15 0xf08>;+ uefi {+ xen,uefi-system-table = <0xXXXXXXXX>;+ xen,uefi-mmap-start = <0xXXXXXXXX>;+ xen,uefi-mmap-size = <0xXXXXXXXX>;+ xen,uefi-mmap-desc-size = <0xXXXXXXXX>;+ xen,uefi-mmap-desc-ver = <0xXXXXXXXX>;+ }; };++The format and meaning of the "xen,uefi-*" parameters are similar to those in+Documentation/arm/uefi.txt, which are provided by the regular UEFI stub. However+they differ because they are provided by the Xen hypervisor, together with a set+of UEFI runtime services implemented via hypercalls, see+http://xenbits.xen.org/docs/unstable/hypercall/x86_64/include,public,platform.h.html.
From: Shannon Zhao <redacted>
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 <redacted>
Reviewed-by: Stefano Stabellini <redacted>
---
CC: "Rafael J. Wysocki" <redacted> (supporter:ACPI)
CC: Len Brown <lenb@kernel.org> (supporter:ACPI)
CC: linux-acpi at vger.kernel.org (open list:ACPI)
---
drivers/acpi/bus.c | 38 +++++++++++++++++++++++++++++++++++++-
1 file changed, 37 insertions(+), 1 deletion(-)
@@ -105,6 +106,22 @@ acpi_status acpi_bus_get_status_handle(acpi_handle handle,returnstatus;}+staticboolacpi_check_device_is_ignored(acpi_handlehandle)+{+acpi_statusstatus;+u64addr;++/* 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)+returntrue;+}++returnfalse;+}+intacpi_bus_get_status(structacpi_device*device){acpi_statusstatus;
@@ -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]: "
@@ -1082,6 +1102,22 @@ static int __init acpi_init(void)acpi_kobj=NULL;}+/* If there is STAO table, check whether it needs to ignore the UART+*deviceinSPCRtable.+*/+status=acpi_get_table(ACPI_SIG_STAO,0,+(structacpi_table_header**)&stao_ptr);+if(ACPI_SUCCESS(status)&&stao_ptr->ignore_uart){+structacpi_table_spcr*spcr_ptr;++status=acpi_get_table(ACPI_SIG_SPCR,0,+(structacpi_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");+}+init_acpi_device_notify();result=acpi_bus_init();if(result){
From: "Rafael J. Wysocki" <rafael@kernel.org> Date: 2016-02-06 10:23:15
On Fri, Feb 5, 2016 at 4:05 AM, Shannon Zhao [off-list ref] wrote:
From: Shannon Zhao <redacted>
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 <redacted>
Reviewed-by: Stefano Stabellini <redacted>
Well, this doesn't look right to me.
We need to find a nicer way to achieve what you want.
Thanks,
Rafael
On Fri, Feb 5, 2016 at 4:05 AM, Shannon Zhao [off-list ref] wrote:
quoted
From: Shannon Zhao <redacted>
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 <redacted>
Reviewed-by: Stefano Stabellini <redacted>
Well, this doesn't look right to me.
We need to find a nicer way to achieve what you want.
I take that you are talking about how to honor the STAO table in Linux.
Do you have any concrete suggestions?
From: Rafael J. Wysocki <hidden> Date: 2016-02-08 22:24:30
On Monday, February 08, 2016 10:57:01 AM Stefano Stabellini wrote:
On Sat, 6 Feb 2016, Rafael J. Wysocki wrote:
quoted
On Fri, Feb 5, 2016 at 4:05 AM, Shannon Zhao [off-list ref] wrote:
quoted
From: Shannon Zhao <redacted>
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 <redacted>
Reviewed-by: Stefano Stabellini <redacted>
Well, this doesn't look right to me.
We need to find a nicer way to achieve what you want.
I take that you are talking about how to honor the STAO table in Linux.
Do you have any concrete suggestions?
I do.
The last hunk of the patch is likely what it needs to be, although I'm
not sure if the place it is added to is the right one. That's a minor thing,
though.
The other part is problematic. Not that as it doesn't work, but because of
how it works. With these changes the device will be visible to the OS (in
fact to user space even), but will never be "present". I'm not sure if
that's what you want?
It might be better to add a check to acpi_bus_type_and_status() that will
evaluate the "should ignore?" thing and return -ENODEV if this is true. This
way the device won't be visible at all.
Thanks,
Rafael
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
On Monday, February 08, 2016 10:57:01 AM Stefano Stabellini wrote:
quoted
On Sat, 6 Feb 2016, Rafael J. Wysocki wrote:
quoted
On Fri, Feb 5, 2016 at 4:05 AM, Shannon Zhao [off-list ref] wrote:
quoted
From: Shannon Zhao <redacted>
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 <redacted>
Reviewed-by: Stefano Stabellini <redacted>
Well, this doesn't look right to me.
We need to find a nicer way to achieve what you want.
I take that you are talking about how to honor the STAO table in Linux.
Do you have any concrete suggestions?
I do.
The last hunk of the patch is likely what it needs to be, although I'm
not sure if the place it is added to is the right one. That's a minor thing,
though.
The other part is problematic. Not that as it doesn't work, but because of
how it works. With these changes the device will be visible to the OS (in
fact to user space even), but will never be "present". I'm not sure if
that's what you want?
It might be better to add a check to acpi_bus_type_and_status() that will
evaluate the "should ignore?" thing and return -ENODEV if this is true. This
way the device won't be visible at all.
Something like below? Actually your suggestion is better, thank you!
@@ -1455,6 +1455,9 @@ static int acpi_bus_type_and_status(acpi_handle handle, int *type,if(ACPI_FAILURE(status))return-ENODEV;+if(acpi_check_device_is_ignored(handle))+return-ENODEV;+switch(acpi_type){caseACPI_TYPE_ANY:/* for ACPI_ROOT_OBJECT */caseACPI_TYPE_DEVICE:
From: Rafael J. Wysocki <hidden> Date: 2016-02-10 22:28:22
On Tuesday, February 09, 2016 11:19:02 AM Stefano Stabellini wrote:
quoted hunk
On Mon, 8 Feb 2016, Rafael J. Wysocki wrote:
quoted
On Monday, February 08, 2016 10:57:01 AM Stefano Stabellini wrote:
quoted
On Sat, 6 Feb 2016, Rafael J. Wysocki wrote:
quoted
On Fri, Feb 5, 2016 at 4:05 AM, Shannon Zhao [off-list ref] wrote:
quoted
From: Shannon Zhao <redacted>
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 <redacted>
Reviewed-by: Stefano Stabellini <redacted>
Well, this doesn't look right to me.
We need to find a nicer way to achieve what you want.
I take that you are talking about how to honor the STAO table in Linux.
Do you have any concrete suggestions?
I do.
The last hunk of the patch is likely what it needs to be, although I'm
not sure if the place it is added to is the right one. That's a minor thing,
though.
The other part is problematic. Not that as it doesn't work, but because of
how it works. With these changes the device will be visible to the OS (in
fact to user space even), but will never be "present". I'm not sure if
that's what you want?
It might be better to add a check to acpi_bus_type_and_status() that will
evaluate the "should ignore?" thing and return -ENODEV if this is true. This
way the device won't be visible at all.
Something like below? Actually your suggestion is better, thank you!
@@ -1455,6 +1455,9 @@ static int acpi_bus_type_and_status(acpi_handle handle, int *type,if(ACPI_FAILURE(status))return-ENODEV;+if(acpi_check_device_is_ignored(handle))+return-ENODEV;+switch(acpi_type){caseACPI_TYPE_ANY:/* for ACPI_ROOT_OBJECT */caseACPI_TYPE_DEVICE:
I thought about doing that under ACPI_TYPE_DEVICE, because it shouldn't be
applicable to the other types. But generally, yes.
Plus I'd move the table checks to acpi_scan_init(), so the UART address can
be a static variable in scan.c.
Also maybe rename acpi_check_device_is_ignored() to something like
acpi_device_should_be_hidden().
Thanks,
Rafael
On Tuesday, February 09, 2016 11:19:02 AM Stefano Stabellini wrote:
quoted
On Mon, 8 Feb 2016, Rafael J. Wysocki wrote:
quoted
On Monday, February 08, 2016 10:57:01 AM Stefano Stabellini wrote:
quoted
On Sat, 6 Feb 2016, Rafael J. Wysocki wrote:
quoted
On Fri, Feb 5, 2016 at 4:05 AM, Shannon Zhao [off-list ref] wrote:
quoted
From: Shannon Zhao <redacted>
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 <redacted>
Reviewed-by: Stefano Stabellini <redacted>
Well, this doesn't look right to me.
We need to find a nicer way to achieve what you want.
I take that you are talking about how to honor the STAO table in Linux.
Do you have any concrete suggestions?
I do.
The last hunk of the patch is likely what it needs to be, although I'm
not sure if the place it is added to is the right one. That's a minor thing,
though.
The other part is problematic. Not that as it doesn't work, but because of
how it works. With these changes the device will be visible to the OS (in
fact to user space even), but will never be "present". I'm not sure if
that's what you want?
It might be better to add a check to acpi_bus_type_and_status() that will
evaluate the "should ignore?" thing and return -ENODEV if this is true. This
way the device won't be visible at all.
Something like below? Actually your suggestion is better, thank you!
@@ -1455,6 +1455,9 @@ static int acpi_bus_type_and_status(acpi_handle handle, int *type,if(ACPI_FAILURE(status))return-ENODEV;+if(acpi_check_device_is_ignored(handle))+return-ENODEV;+switch(acpi_type){caseACPI_TYPE_ANY:/* for ACPI_ROOT_OBJECT */caseACPI_TYPE_DEVICE:
I thought about doing that under ACPI_TYPE_DEVICE, because it shouldn't be
applicable to the other types. But generally, yes.
I was pondering about it myself. Maybe an ACPI_TYPE_PROCESSOR object
could theoretically be hidden with the STAO? I added the check before
the switch because I thought that there would be no harm in being
caution about it.
Plus I'd move the table checks to acpi_scan_init(), so the UART address can
be a static variable in scan.c.
Also maybe rename acpi_check_device_is_ignored() to something like
acpi_device_should_be_hidden().
Both make sense. Shannon, are you happy to make these changes?
From: Rafael J. Wysocki <hidden> Date: 2016-02-11 22:21:18
On Thursday, February 11, 2016 04:04:14 PM Stefano Stabellini wrote:
On Wed, 10 Feb 2016, Rafael J. Wysocki wrote:
quoted
On Tuesday, February 09, 2016 11:19:02 AM Stefano Stabellini wrote:
quoted
On Mon, 8 Feb 2016, Rafael J. Wysocki wrote:
quoted
On Monday, February 08, 2016 10:57:01 AM Stefano Stabellini wrote:
quoted
On Sat, 6 Feb 2016, Rafael J. Wysocki wrote:
quoted
On Fri, Feb 5, 2016 at 4:05 AM, Shannon Zhao [off-list ref] wrote:
quoted
From: Shannon Zhao <redacted>
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 <redacted>
Reviewed-by: Stefano Stabellini <redacted>
Well, this doesn't look right to me.
We need to find a nicer way to achieve what you want.
I take that you are talking about how to honor the STAO table in Linux.
Do you have any concrete suggestions?
I do.
The last hunk of the patch is likely what it needs to be, although I'm
not sure if the place it is added to is the right one. That's a minor thing,
though.
The other part is problematic. Not that as it doesn't work, but because of
how it works. With these changes the device will be visible to the OS (in
fact to user space even), but will never be "present". I'm not sure if
that's what you want?
It might be better to add a check to acpi_bus_type_and_status() that will
evaluate the "should ignore?" thing and return -ENODEV if this is true. This
way the device won't be visible at all.
Something like below? Actually your suggestion is better, thank you!
@@ -1455,6 +1455,9 @@ static int acpi_bus_type_and_status(acpi_handle handle, int *type,if(ACPI_FAILURE(status))return-ENODEV;+if(acpi_check_device_is_ignored(handle))+return-ENODEV;+switch(acpi_type){caseACPI_TYPE_ANY:/* for ACPI_ROOT_OBJECT */caseACPI_TYPE_DEVICE:
I thought about doing that under ACPI_TYPE_DEVICE, because it shouldn't be
applicable to the other types. But generally, yes.
I was pondering about it myself. Maybe an ACPI_TYPE_PROCESSOR object
could theoretically be hidden with the STAO?
But this patch won't check for it anyway, will it?
It seems to be only checking against the UART address or have I missed
anything?
I added the check before
the switch because I thought that there would be no harm in being
caution about it.
quoted
Plus I'd move the table checks to acpi_scan_init(), so the UART address can
be a static variable in scan.c.
Also maybe rename acpi_check_device_is_ignored() to something like
acpi_device_should_be_hidden().
Both make sense. Shannon, are you happy to make these changes?
Plus maybe make acpi_device_should_be_hidden() print a (KERN_INFO) message
when it decides to hide something?
Thanks,
Rafael
On Thursday, February 11, 2016 04:04:14 PM Stefano Stabellini wrote:
quoted
On Wed, 10 Feb 2016, Rafael J. Wysocki wrote:
quoted
On Tuesday, February 09, 2016 11:19:02 AM Stefano Stabellini wrote:
quoted
On Mon, 8 Feb 2016, Rafael J. Wysocki wrote:
quoted
On Monday, February 08, 2016 10:57:01 AM Stefano Stabellini wrote:
quoted
On Sat, 6 Feb 2016, Rafael J. Wysocki wrote:
quoted
On Fri, Feb 5, 2016 at 4:05 AM, Shannon Zhao [off-list ref] wrote:
quoted
From: Shannon Zhao <redacted>
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 <redacted>
Reviewed-by: Stefano Stabellini <redacted>
Well, this doesn't look right to me.
We need to find a nicer way to achieve what you want.
I take that you are talking about how to honor the STAO table in Linux.
Do you have any concrete suggestions?
I do.
The last hunk of the patch is likely what it needs to be, although I'm
not sure if the place it is added to is the right one. That's a minor thing,
though.
The other part is problematic. Not that as it doesn't work, but because of
how it works. With these changes the device will be visible to the OS (in
fact to user space even), but will never be "present". I'm not sure if
that's what you want?
It might be better to add a check to acpi_bus_type_and_status() that will
evaluate the "should ignore?" thing and return -ENODEV if this is true. This
way the device won't be visible at all.
Something like below? Actually your suggestion is better, thank you!
@@ -1455,6 +1455,9 @@ static int acpi_bus_type_and_status(acpi_handle handle, int *type,if(ACPI_FAILURE(status))return-ENODEV;+if(acpi_check_device_is_ignored(handle))+return-ENODEV;+switch(acpi_type){caseACPI_TYPE_ANY:/* for ACPI_ROOT_OBJECT */caseACPI_TYPE_DEVICE:
I thought about doing that under ACPI_TYPE_DEVICE, because it shouldn't be
applicable to the other types. But generally, yes.
I was pondering about it myself. Maybe an ACPI_TYPE_PROCESSOR object
could theoretically be hidden with the STAO?
But this patch won't check for it anyway, will it?
It seems to be only checking against the UART address or have I missed
anything?
You are right, this patch only checks for the UART address, which is
critical.
However the STAO also has a "Name List" field with a list of paths in
ACPI namespace to hide. If not implementing proper "Name List" support,
at least, as part of this patch, it would be nice to check for the
presence of the Name List field in the table, and print a warning such
as "STAO Name List not yet supported" when the field is present.
From: "Rafael J. Wysocki" <rafael@kernel.org> Date: 2016-02-12 12:57:50
On Fri, Feb 12, 2016 at 12:50 PM, Stefano Stabellini
[off-list ref] wrote:
On Thu, 11 Feb 2016, Rafael J. Wysocki wrote:
quoted
On Thursday, February 11, 2016 04:04:14 PM Stefano Stabellini wrote:
quoted
On Wed, 10 Feb 2016, Rafael J. Wysocki wrote:
quoted
On Tuesday, February 09, 2016 11:19:02 AM Stefano Stabellini wrote:
quoted
On Mon, 8 Feb 2016, Rafael J. Wysocki wrote:
quoted
On Monday, February 08, 2016 10:57:01 AM Stefano Stabellini wrote:
quoted
On Sat, 6 Feb 2016, Rafael J. Wysocki wrote:
quoted
On Fri, Feb 5, 2016 at 4:05 AM, Shannon Zhao [off-list ref] wrote:
quoted
From: Shannon Zhao <redacted>
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 <redacted>
Reviewed-by: Stefano Stabellini <redacted>
Well, this doesn't look right to me.
We need to find a nicer way to achieve what you want.
I take that you are talking about how to honor the STAO table in Linux.
Do you have any concrete suggestions?
I do.
The last hunk of the patch is likely what it needs to be, although I'm
not sure if the place it is added to is the right one. That's a minor thing,
though.
The other part is problematic. Not that as it doesn't work, but because of
how it works. With these changes the device will be visible to the OS (in
fact to user space even), but will never be "present". I'm not sure if
that's what you want?
It might be better to add a check to acpi_bus_type_and_status() that will
evaluate the "should ignore?" thing and return -ENODEV if this is true. This
way the device won't be visible at all.
Something like below? Actually your suggestion is better, thank you!
@@ -1455,6 +1455,9 @@ static int acpi_bus_type_and_status(acpi_handle handle, int *type,if(ACPI_FAILURE(status))return-ENODEV;+if(acpi_check_device_is_ignored(handle))+return-ENODEV;+switch(acpi_type){caseACPI_TYPE_ANY:/* for ACPI_ROOT_OBJECT */caseACPI_TYPE_DEVICE:
I thought about doing that under ACPI_TYPE_DEVICE, because it shouldn't be
applicable to the other types. But generally, yes.
I was pondering about it myself. Maybe an ACPI_TYPE_PROCESSOR object
could theoretically be hidden with the STAO?
But this patch won't check for it anyway, will it?
It seems to be only checking against the UART address or have I missed
anything?
You are right, this patch only checks for the UART address, which is
critical.
However the STAO also has a "Name List" field with a list of paths in
ACPI namespace to hide. If not implementing proper "Name List" support,
at least, as part of this patch, it would be nice to check for the
presence of the Name List field in the table, and print a warning such
as "STAO Name List not yet supported" when the field is present.
That would be fine, but anyway it belongs to the table parsing part IMO.
And the check can be moved when adding proper support for the name list part.
Thanks,
Rafael
On Thursday, February 11, 2016 04:04:14 PM Stefano Stabellini wrote:
quoted
quoted
On Wed, 10 Feb 2016, Rafael J. Wysocki wrote:
quoted
quoted
On Tuesday, February 09, 2016 11:19:02 AM Stefano Stabellini wrote:
quoted
quoted
On Mon, 8 Feb 2016, Rafael J. Wysocki wrote:
quoted
quoted
On Monday, February 08, 2016 10:57:01 AM Stefano Stabellini wrote:
quoted
quoted
On Sat, 6 Feb 2016, Rafael J. Wysocki wrote:
quoted
quoted
On Fri, Feb 5, 2016 at 4:05 AM, Shannon Zhao [off-list ref] wrote:
quoted
quoted
From: Shannon Zhao <redacted>
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 <redacted>
Reviewed-by: Stefano Stabellini <redacted>
Well, this doesn't look right to me.
We need to find a nicer way to achieve what you want.
I take that you are talking about how to honor the STAO table in Linux.
Do you have any concrete suggestions?
I do.
The last hunk of the patch is likely what it needs to be, although I'm
not sure if the place it is added to is the right one. That's a minor thing,
though.
The other part is problematic. Not that as it doesn't work, but because of
how it works. With these changes the device will be visible to the OS (in
fact to user space even), but will never be "present". I'm not sure if
that's what you want?
It might be better to add a check to acpi_bus_type_and_status() that will
evaluate the "should ignore?" thing and return -ENODEV if this is true. This
way the device won't be visible at all.
Something like below? Actually your suggestion is better, thank you!
@@ -1455,6 +1455,9 @@ static int acpi_bus_type_and_status(acpi_handle handle, int *type,if(ACPI_FAILURE(status))return-ENODEV;+if(acpi_check_device_is_ignored(handle))+return-ENODEV;+switch(acpi_type){caseACPI_TYPE_ANY:/* for ACPI_ROOT_OBJECT */caseACPI_TYPE_DEVICE:
I thought about doing that under ACPI_TYPE_DEVICE, because it shouldn't be
applicable to the other types. But generally, yes.
I was pondering about it myself. Maybe an ACPI_TYPE_PROCESSOR object
could theoretically be hidden with the STAO?
But this patch won't check for it anyway, will it?
It seems to be only checking against the UART address or have I missed
anything?
quoted
quoted
I added the check before
the switch because I thought that there would be no harm in being
caution about it.
quoted
quoted
Plus I'd move the table checks to acpi_scan_init(), so the UART address can
be a static variable in scan.c.
Also maybe rename acpi_check_device_is_ignored() to something like
acpi_device_should_be_hidden().
Both make sense. Shannon, are you happy to make these changes?
Plus maybe make acpi_device_should_be_hidden() print a (KERN_INFO) message
when it decides to hide something?
Ok, will update this patch. Thanks a lot!
--
Shannon
From: Shannon Zhao <redacted>
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 <redacted>
Acked-by: Stefano Stabellini <redacted>
---
drivers/xen/Makefile | 1 +
drivers/xen/arm-device.c | 141 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 142 insertions(+)
create mode 100644 drivers/xen/arm-device.c
From: Shannon Zhao <redacted>
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 <redacted>
Reviewed-by: Stefano Stabellini <redacted>
---
drivers/xen/arm-device.c | 43 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
From: Shannon Zhao <redacted>
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 <redacted>
Acked-by: Stefano Stabellini <redacted>
---
arch/arm/xen/enlighten.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
@@ -282,18 +282,10 @@ static int __init xen_guest_init(void){structxen_add_to_physmapxatp;structshared_info*shared_info_page=NULL;-structresourceres;-phys_addr_tgrant_frames;if(!xen_domain())return0;-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");
@@ -328,7 +320,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;}
From: Shannon Zhao <redacted>
Add a new type of Xen map space for Dom0 to map device's MMIO region.
Signed-off-by: Shannon Zhao <redacted>
---
include/xen/interface/memory.h | 1 +
1 file changed, 1 insertion(+)
From: Shannon Zhao <redacted>
Add a new type of Xen map space for Dom0 to map device's MMIO region.
Signed-off-by: Shannon Zhao <redacted>
---
include/xen/interface/memory.h | 1 +
1 file changed, 1 insertion(+)
@@ -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_rangeonly.*/+#define XENMAPSPACE_dev_mmio 5 /* device mmio region *//**SetstheGPFNatwhichaparticularpageappearsinthespecifiedguest's
This patch needs to wait at least until the corresponding Xen patch
(the one which introduces XENMAPSPACE_dev_mmio on the Xen side) is
Acked by one of the Xen maintainers.