From nobody Sat May 4 18:03:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1601153799; cv=none; d=zohomail.com; s=zohoarc; b=RMQ9ODzX21vnM7Gyy3y4xw62lL7bKSEMSd2Jb0UniEOViwEP84Kb/BDRUVmBIyf8huCLshIW6ctrx2yKfiE9LeCdqKE6Q1cRGMA48zohvTjmcoLxeoptNUp7ecJwwIiGTCJFc+J10DhXlV6gxOuI2wVUGluw3nA+KV5XVnFYQ84= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601153799; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=S0f3H7Kr0VFazdDtn3XQopoMT6Wxzv8cwTZpkhLH01s=; b=WrJIUBOGUQmhdEuyUq8RZO/woxUDxNn3C6izUxu755c36qzVYm5pmOmImrCwT0NorUXCh6ngNLJlzcLXyb+DS7N41gVIoaZpXVRDbtXTaYb33DKhK8Je/9fgzDF/pY2fE7dDtz1/bZgW/NCLqwUqroYuugDub/SX0UyRSfgpDQU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1601153799778429.7077873706894; Sat, 26 Sep 2020 13:56:39 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kMHEo-0003jR-EJ; Sat, 26 Sep 2020 20:56:10 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kMHEn-0003jG-5e for xen-devel@lists.xenproject.org; Sat, 26 Sep 2020 20:56:09 +0000 Received: from mail.xenproject.org (unknown [104.130.215.37]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id a572bbae-642c-42be-939e-db8ad5fc746d; Sat, 26 Sep 2020 20:56:06 +0000 (UTC) Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kMHEh-0000CM-UN; Sat, 26 Sep 2020 20:56:03 +0000 Received: from 54-240-197-235.amazon.com ([54.240.197.235] helo=ufe34d9ed68d054.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kMHEh-0004I0-KG; Sat, 26 Sep 2020 20:56:03 +0000 X-Inumbo-ID: a572bbae-642c-42be-939e-db8ad5fc746d DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=S0f3H7Kr0VFazdDtn3XQopoMT6Wxzv8cwTZpkhLH01s=; b=XTTLL9o0O0cvFJ73FdrDf4e1M ZFZztPr/r8XcTorUAANyFE/SWHQ1H3p6QPQ87JiBzRTksYOTgDa7XDhwWS3HSXMYnKNPYy0EDtcHZ m8DKN6gzTcGDYWuzi5IXgnoF6YnABQDpRppTWDCgEKqmweINpebF2A0ezRegiKewr7/EQ=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: alex.bennee@linaro.org, masami.hiramatsu@linaro.org, ehem+xen@m5p.com, bertrand.marquis@arm.com, andre.przywara@arm.com, Julien Grall , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Andrew Cooper , George Dunlap , Ian Jackson , Jan Beulich , Wei Liu , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 1/4] xen/acpi: Rework acpi_os_map_memory() and acpi_os_unmap_memory() Date: Sat, 26 Sep 2020 21:55:39 +0100 Message-Id: <20200926205542.9261-2-julien@xen.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200926205542.9261-1-julien@xen.org> References: <20200926205542.9261-1-julien@xen.org> X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: pass (identity @xen.org) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Julien Grall The functions acpi_os_{un,}map_memory() are meant to be arch-agnostic while the __acpi_os_{un,}map_memory() are meant to be arch-specific. Currently, the former are still containing x86 specific code. To avoid this rather strange split, the generic helpers are reworked so they are arch-agnostic. This requires the introduction of a new helper __acpi_os_unmap_memory() that will undo any mapping done by __acpi_os_map_memory(). Currently, the arch-helper for unmap is basically a no-op so it only returns whether the mapping was arch specific. But this will change in the future. Note that the x86 version of acpi_os_map_memory() was already able to able the 1MB region. Hence why there is no addition of new code. Signed-off-by: Julien Grall Reviewed-by: Rahul Singh Tested-by: Elliott Mitchell Tested-by: Rahul Singh --- xen/arch/arm/acpi/lib.c | 10 ++++++++++ xen/arch/x86/acpi/lib.c | 18 ++++++++++++++++++ xen/drivers/acpi/osl.c | 34 ++++++++++++++++++---------------- xen/include/xen/acpi.h | 1 + 4 files changed, 47 insertions(+), 16 deletions(-) diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c index 4fc6e17322c1..2192a5519171 100644 --- a/xen/arch/arm/acpi/lib.c +++ b/xen/arch/arm/acpi/lib.c @@ -30,6 +30,10 @@ char *__acpi_map_table(paddr_t phys, unsigned long size) unsigned long base, offset, mapped_size; int idx; =20 + /* No arch specific implementation after early boot */ + if ( system_state >=3D SYS_STATE_boot ) + return NULL; + offset =3D phys & (PAGE_SIZE - 1); mapped_size =3D PAGE_SIZE - offset; set_fixmap(FIXMAP_ACPI_BEGIN, maddr_to_mfn(phys), PAGE_HYPERVISOR); @@ -49,6 +53,12 @@ char *__acpi_map_table(paddr_t phys, unsigned long size) return ((char *) base + offset); } =20 +bool __acpi_unmap_table(void *ptr, unsigned long size) +{ + return ( vaddr >=3D FIXMAP_ADDR(FIXMAP_ACPI_BEGIN) && + vaddr < (FIXMAP_ADDR(FIXMAP_ACPI_END) + PAGE_SIZE) ); +} + /* True to indicate PSCI 0.2+ is implemented */ bool __init acpi_psci_present(void) { diff --git a/xen/arch/x86/acpi/lib.c b/xen/arch/x86/acpi/lib.c index 265b9ad81905..77803f4d4c63 100644 --- a/xen/arch/x86/acpi/lib.c +++ b/xen/arch/x86/acpi/lib.c @@ -46,6 +46,10 @@ char *__acpi_map_table(paddr_t phys, unsigned long size) if ((phys + size) <=3D (1 * 1024 * 1024)) return __va(phys); =20 + /* No arch specific implementation after early boot */ + if (system_state >=3D SYS_STATE_boot) + return NULL; + offset =3D phys & (PAGE_SIZE - 1); mapped_size =3D PAGE_SIZE - offset; set_fixmap(FIX_ACPI_END, phys); @@ -66,6 +70,20 @@ char *__acpi_map_table(paddr_t phys, unsigned long size) return ((char *) base + offset); } =20 +bool __acpi_unmap_table(void *ptr, unsigned long size) +{ + unsigned long vaddr =3D (unsigned long)ptr; + + if (vaddr >=3D DIRECTMAP_VIRT_START && + vaddr < DIRECTMAP_VIRT_END) { + ASSERT(!((__pa(ptr) + size - 1) >> 20)); + return true; + } + + return (vaddr >=3D __fix_to_virt(FIX_ACPI_END)) && + (vaddr < (__fix_to_virt(FIX_ACPI_BEGIN) + PAGE_SIZE)); +} + unsigned int acpi_get_processor_id(unsigned int cpu) { unsigned int acpiid, apicid; diff --git a/xen/drivers/acpi/osl.c b/xen/drivers/acpi/osl.c index 4c8bb7839eda..100eee72def2 100644 --- a/xen/drivers/acpi/osl.c +++ b/xen/drivers/acpi/osl.c @@ -92,27 +92,29 @@ acpi_physical_address __init acpi_os_get_root_pointer(v= oid) void __iomem * acpi_os_map_memory(acpi_physical_address phys, acpi_size size) { - if (system_state >=3D SYS_STATE_boot) { - mfn_t mfn =3D _mfn(PFN_DOWN(phys)); - unsigned int offs =3D phys & (PAGE_SIZE - 1); - - /* The low first Mb is always mapped on x86. */ - if (IS_ENABLED(CONFIG_X86) && !((phys + size - 1) >> 20)) - return __va(phys); - return __vmap(&mfn, PFN_UP(offs + size), 1, 1, - ACPI_MAP_MEM_ATTR, VMAP_DEFAULT) + offs; - } - return __acpi_map_table(phys, size); + void *ptr; + mfn_t mfn =3D _mfn(PFN_DOWN(phys)); + unsigned int offs =3D phys & (PAGE_SIZE - 1); + + /* Try the arch specific implementation first */ + ptr =3D __acpi_map_table(phys, size); + if (ptr) + return ptr; + + /* No common implementation for early boot map */ + if (unlikely(system_state < SYS_STATE_boot)) + return NULL; + + ptr =3D __vmap(&mfn, PFN_UP(offs + size), 1, 1, + ACPI_MAP_MEM_ATTR, VMAP_DEFAULT); + + return !ptr ? NULL : (ptr + offs); } =20 void acpi_os_unmap_memory(void __iomem * virt, acpi_size size) { - if (IS_ENABLED(CONFIG_X86) && - (unsigned long)virt >=3D DIRECTMAP_VIRT_START && - (unsigned long)virt < DIRECTMAP_VIRT_END) { - ASSERT(!((__pa(virt) + size - 1) >> 20)); + if (__acpi_unmap_table(virt, size)) return; - } =20 if (system_state >=3D SYS_STATE_boot) vunmap((void *)((unsigned long)virt & PAGE_MASK)); diff --git a/xen/include/xen/acpi.h b/xen/include/xen/acpi.h index c945ab05c864..5a84a4bf54e0 100644 --- a/xen/include/xen/acpi.h +++ b/xen/include/xen/acpi.h @@ -68,6 +68,7 @@ typedef int (*acpi_table_entry_handler) (struct acpi_subt= able_header *header, co =20 unsigned int acpi_get_processor_id (unsigned int cpu); char * __acpi_map_table (paddr_t phys_addr, unsigned long size); +bool __acpi_unmap_table(void *ptr, unsigned long size); int acpi_boot_init (void); int acpi_boot_table_init (void); int acpi_numa_init (void); --=20 2.17.1 From nobody Sat May 4 18:03:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1601153799; cv=none; d=zohomail.com; s=zohoarc; b=Xm2ntjYd8pxT/QIEl9QQMS+fnRgROuKnSjkOIt6nVS1+WUSU9C/n/BAnNKKIFTnUpHSWPEika3BVaKrDmx/S3fmKM4mIBu397bnz45NmeC/JCRobpIS6RV5N9MOjbpikNif3aZSw3wxa4WWX7gYJPG/HOI+ABoCJpt0nzqih7LU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601153799; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=NUzIF6jd0VTOPVLuT+sNzYSm2gJRa4g7nKnovFDCX/4=; b=Xx8fAMgDTj8rvfn+e1a/sFPgwpAZw/fZSnjzWt9qOAfeyreeTSrfWNLZu8m7ONaMkhNln6HgwEaJsGPjxbhLDkvDlHV52bcQcQNenZ1M+njS4ORmpacNZqDGRTJ7/Ie/jYzmO4ZxVp7zKwoyC0y4QdVyGSlcK7nZfg5oN5bYvYI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1601153799268692.0056845939805; Sat, 26 Sep 2020 13:56:39 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kMHEy-0003ky-8D; Sat, 26 Sep 2020 20:56:20 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kMHEx-0003jG-1M for xen-devel@lists.xenproject.org; Sat, 26 Sep 2020 20:56:19 +0000 Received: from mail.xenproject.org (unknown [104.130.215.37]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id ef8786d4-b800-44f6-b276-ef25a066fe34; Sat, 26 Sep 2020 20:56:09 +0000 (UTC) Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kMHEj-0000CR-M8; Sat, 26 Sep 2020 20:56:05 +0000 Received: from 54-240-197-235.amazon.com ([54.240.197.235] helo=ufe34d9ed68d054.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kMHEj-0004I0-Cz; Sat, 26 Sep 2020 20:56:05 +0000 X-Inumbo-ID: ef8786d4-b800-44f6-b276-ef25a066fe34 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=NUzIF6jd0VTOPVLuT+sNzYSm2gJRa4g7nKnovFDCX/4=; b=LTV2p20sIv7akePa3vPAhyBsX 6m1ks6BSd9/ovS4zKP1LFTtQEVcidvgjUs6GPfnq/4ugmsbWZEAR6JM5+bhyZwu3bDry6kMJtc5yt T9Zlm87OqBIeeZpqXwIUfTSzm1ZglFmh4YKYTsxrJ9yrt7J4Vi7UotexGCPPFRZkw8jgM=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: alex.bennee@linaro.org, masami.hiramatsu@linaro.org, ehem+xen@m5p.com, bertrand.marquis@arm.com, andre.przywara@arm.com, Julien Grall , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Wei Xu Subject: [PATCH 2/4] xen/arm: acpi: The fixmap area should always be cleared during failure/unmap Date: Sat, 26 Sep 2020 21:55:40 +0100 Message-Id: <20200926205542.9261-3-julien@xen.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200926205542.9261-1-julien@xen.org> References: <20200926205542.9261-1-julien@xen.org> X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: pass (identity @xen.org) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Julien Grall Commit 022387ee1ad3 "xen/arm: mm: Don't open-code Xen PT update in {set, clear}_fixmap()" enforced that each set_fixmap() should be paired with a clear_fixmap(). Any failure to follow the model would result to a platform crash. Unfortunately, the use of fixmap in the ACPI code was overlooked as it is calling set_fixmap() but not clear_fixmap(). The function __acpi_os_map_table() is reworked so: - We know before the mapping whether the fixmap region is big enough for the mapping. - It will fail if the fixmap is always inuse. The function __acpi_os_unmap_table() will now call clear_fixmap(). Reported-by: Wei Xu Signed-off-by: Julien Grall Reviewed-by: Rahul Singh Tested-by: Elliott Mitchell Tested-by: Rahul Singh --- The discussion on the original thread [1] suggested to also zap it on x86. This is technically not necessary today, so it is left alone for now. I looked at making the fixmap code common but the index are inverted between Arm and x86. [1] https://lore.kernel.org/xen-devel/5E26C935.9080107@hisilicon.com/ --- xen/arch/arm/acpi/lib.c | 75 +++++++++++++++++++++++++++++++---------- 1 file changed, 58 insertions(+), 17 deletions(-) diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c index 2192a5519171..eebaca695562 100644 --- a/xen/arch/arm/acpi/lib.c +++ b/xen/arch/arm/acpi/lib.c @@ -25,38 +25,79 @@ #include #include =20 +static bool fixmap_inuse; + char *__acpi_map_table(paddr_t phys, unsigned long size) { - unsigned long base, offset, mapped_size; - int idx; + unsigned long base, offset; + mfn_t mfn; + unsigned int idx; =20 /* No arch specific implementation after early boot */ if ( system_state >=3D SYS_STATE_boot ) return NULL; =20 offset =3D phys & (PAGE_SIZE - 1); - mapped_size =3D PAGE_SIZE - offset; - set_fixmap(FIXMAP_ACPI_BEGIN, maddr_to_mfn(phys), PAGE_HYPERVISOR); - base =3D FIXMAP_ADDR(FIXMAP_ACPI_BEGIN); + base =3D FIXMAP_ADDR(FIXMAP_ACPI_BEGIN) + offset; + + /* Check the fixmap is big enough to map the region */ + if ( (FIXMAP_ADDR(FIXMAP_ACPI_END) + PAGE_SIZE - base) < size ) + return NULL; + + /* With the fixmap, we can only map one region at the time */ + if ( fixmap_inuse ) + return NULL; =20 - /* Most cases can be covered by the below. */ + fixmap_inuse =3D true; + + size +=3D offset; + mfn =3D maddr_to_mfn(phys); idx =3D FIXMAP_ACPI_BEGIN; - while ( mapped_size < size ) - { - if ( ++idx > FIXMAP_ACPI_END ) - return NULL; /* cannot handle this */ - phys +=3D PAGE_SIZE; - set_fixmap(idx, maddr_to_mfn(phys), PAGE_HYPERVISOR); - mapped_size +=3D PAGE_SIZE; - } =20 - return ((char *) base + offset); + do { + set_fixmap(idx, mfn, PAGE_HYPERVISOR); + size -=3D min(size, (unsigned long)PAGE_SIZE); + mfn =3D mfn_add(mfn, 1); + idx++; + } while ( size > 0 ); + + return (char *)base; } =20 bool __acpi_unmap_table(void *ptr, unsigned long size) { - return ( vaddr >=3D FIXMAP_ADDR(FIXMAP_ACPI_BEGIN) && - vaddr < (FIXMAP_ADDR(FIXMAP_ACPI_END) + PAGE_SIZE) ); + vaddr_t vaddr =3D (vaddr_t)ptr; + unsigned int idx; + + /* We are only handling fixmap address in the arch code */ + if ( vaddr < FIXMAP_ADDR(FIXMAP_ACPI_BEGIN) || + vaddr >=3D FIXMAP_ADDR(FIXMAP_ACPI_END) ) + return false; + + /* + * __acpi_map_table() will always return a pointer in the first page + * for the ACPI fixmap region. The caller is expected to free with + * the same address. + */ + ASSERT((vaddr & PAGE_MASK) =3D=3D FIXMAP_ADDR(FIXMAP_ACPI_BEGIN)); + + /* The region allocated fit in the ACPI fixmap region. */ + ASSERT(size < (FIXMAP_ADDR(FIXMAP_ACPI_END) + PAGE_SIZE - vaddr)); + ASSERT(fixmap_inuse); + + fixmap_inuse =3D false; + + size +=3D FIXMAP_ADDR(FIXMAP_ACPI_BEGIN) - vaddr; + idx =3D FIXMAP_ACPI_BEGIN; + + do + { + clear_fixmap(idx); + size -=3D min(size, (unsigned long)PAGE_SIZE); + idx++; + } while ( size > 0 ); + + return true; } =20 /* True to indicate PSCI 0.2+ is implemented */ --=20 2.17.1 From nobody Sat May 4 18:03:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1601153798; cv=none; d=zohomail.com; s=zohoarc; b=BPbHdCfsR0C77hA/j9xdVez+oLZNPlP3ScnZ2HfYCkum9mulXiCCqKFfcMrfT6zJpBdbRtO9/Q1E6oPVtHywq5EFLplnp9VuNQ5sJTPhQdz1N04kqsn4j4YPJPk0frJ7NfinSe4wVf2sgNy334/nG0fRVCU+rIeH8tkqUxjR6EQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601153798; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=gZXdNFgGKyJnQOeN1ZdTo8GlRhovmbEZsA8e62YRgQQ=; b=J4mGARfTvf9PT0OddEJzwPNy23KeViVQxpc9VhY+brq6z3tQuUMKjP/Ph/7goJ5nspZBzcMKM4BfsPPvLQfRUxZJmIAys05ByD1hq1FHuS0fBs4/dtEASQ2XdgMnaUd2PzLGoXCdD583VDC6gQ/KK24lN6TdJDbs4lrHNIArEkI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1601153798565558.7222779662817; Sat, 26 Sep 2020 13:56:38 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kMHEs-0003jt-MG; Sat, 26 Sep 2020 20:56:14 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kMHEq-0003jB-NI for xen-devel@lists.xenproject.org; Sat, 26 Sep 2020 20:56:12 +0000 Received: from mail.xenproject.org (unknown [104.130.215.37]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 41132070-a02a-410e-b2ba-be4694155843; Sat, 26 Sep 2020 20:56:08 +0000 (UTC) Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kMHEl-0000CX-Am; Sat, 26 Sep 2020 20:56:07 +0000 Received: from 54-240-197-235.amazon.com ([54.240.197.235] helo=ufe34d9ed68d054.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kMHEl-0004I0-1u; Sat, 26 Sep 2020 20:56:07 +0000 X-Inumbo-ID: 41132070-a02a-410e-b2ba-be4694155843 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=gZXdNFgGKyJnQOeN1ZdTo8GlRhovmbEZsA8e62YRgQQ=; b=Dt2Sofehf4XDzYmaL/oKzfYu5 RlrQ3rn3RcNX0p3fmWtRZAKPGd+UIWJ7UniZwkXBZFQmfG7nTbFk0b0vcYgeKOl9U0hbjyK+3fqcN m0SN60hsBmiEn7jZO8O0l/p34Afi2DgHLeT2TJo6ZvUp0vAsBtRnkdT1FCqVckX3kFJww=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: alex.bennee@linaro.org, masami.hiramatsu@linaro.org, ehem+xen@m5p.com, bertrand.marquis@arm.com, andre.przywara@arm.com, Julien Grall , Stefano Stabellini , Julien Grall , Volodymyr Babchuk Subject: [PATCH 3/4] xen/arm: Check if the platform is not using ACPI before initializing Dom0less Date: Sat, 26 Sep 2020 21:55:41 +0100 Message-Id: <20200926205542.9261-4-julien@xen.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200926205542.9261-1-julien@xen.org> References: <20200926205542.9261-1-julien@xen.org> X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: pass (identity @xen.org) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Julien Grall Dom0less requires a device-tree. However, since commit 6e3e77120378 "xen/arm: setup: Relocate the Device-Tree later on in the boot", the device-tree will not get unflatten when using ACPI. This will lead to a crash during boot. Given the complexity to setup dom0less with ACPI (for instance how to assign device?), we should skip any code related to Dom0less when using ACPI. Signed-off-by: Julien Grall Reviewed-by: Rahul Singh Reviewed-by: Stefano Stabellini Tested-by: Elliott Mitchell Tested-by: Rahul Singh --- xen/arch/arm/setup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index f16b33fa87a2..35e5bee04efa 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -987,7 +987,8 @@ void __init start_xen(unsigned long boot_phys_offset, =20 system_state =3D SYS_STATE_active; =20 - create_domUs(); + if ( acpi_disabled ) + create_domUs(); =20 domain_unpause_by_systemcontroller(dom0); =20 --=20 2.17.1 From nobody Sat May 4 18:03:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1601153800; cv=none; d=zohomail.com; s=zohoarc; b=mTjH9ck8WMJcprdxRjaZ7z3ROmxC/NpX9tbXd3TLlqy6ySLjGm0PzW50MV6paNPN7alJi3PTUNVme2Y8/Mza0qOKR24TtxPBe4w4vHC0wRoNtWFTsyV2/rXgjDvWxphiD0f52pho4gch9has1KTU5knRDU6iUPagjFndMzNMav8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601153800; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=jcmiVe5RuWiItP2oy4PwdbYtzFeVBgjJGWBjlKbiLh0=; b=d5UPNDHuP6iXOTN3Fb2ZFiUn8foOajgrd4V64Wzi8M8DrphaK6qekCzEuzEoJaNbdssiqebkY0yBkop99xHD9MWXNnlmgmRtltMPkUq4ZwZrhDrF6Fv3F2yqA03nVlY8P2uVVb7QpWwV0d6hjL7vD3d2eiUjWg8E4/VUSAECEIA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1601153800553883.9377376798097; Sat, 26 Sep 2020 13:56:40 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kMHEs-0003k4-W5; Sat, 26 Sep 2020 20:56:14 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kMHEs-0003jG-1J for xen-devel@lists.xenproject.org; Sat, 26 Sep 2020 20:56:14 +0000 Received: from mail.xenproject.org (unknown [104.130.215.37]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 32ccde0f-bd5f-4a94-82cc-189a6a8efc4a; Sat, 26 Sep 2020 20:56:09 +0000 (UTC) Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kMHEn-0000Ch-0e; Sat, 26 Sep 2020 20:56:09 +0000 Received: from 54-240-197-235.amazon.com ([54.240.197.235] helo=ufe34d9ed68d054.ant.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kMHEm-0004I0-N6; Sat, 26 Sep 2020 20:56:08 +0000 X-Inumbo-ID: 32ccde0f-bd5f-4a94-82cc-189a6a8efc4a DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=jcmiVe5RuWiItP2oy4PwdbYtzFeVBgjJGWBjlKbiLh0=; b=s824IM09TYDwfgSKrtSyO3Nr7 kc7/aYhHrzvf1/s8/+IN7qxGmP4G91pBfsMEAEcOyGq6c7dBpodutNnOjHErzvWj2xb6FK1wCRyJ3 nBVmZMfajRRNBvTBIMczc/Ssej3uKLUluMq5cxoJbHMvwKUufrtEFTHmHJhEUFMQtFJ5Q=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: alex.bennee@linaro.org, masami.hiramatsu@linaro.org, ehem+xen@m5p.com, bertrand.marquis@arm.com, andre.przywara@arm.com, Julien Grall , Stefano Stabellini , Julien Grall , Volodymyr Babchuk Subject: [PATCH 4/4] xen/arm: Introduce fw_unreserved_regions() and use it Date: Sat, 26 Sep 2020 21:55:42 +0100 Message-Id: <20200926205542.9261-5-julien@xen.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200926205542.9261-1-julien@xen.org> References: <20200926205542.9261-1-julien@xen.org> X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: pass (identity @xen.org) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Julien Grall Since commit 6e3e77120378 "xen/arm: setup: Relocate the Device-Tree later on in the boot", the device-tree will not be kept mapped when using ACPI. However, a few places are calling dt_unreserved_regions() which expects a valid DT. This will lead to a crash. As the DT should not be used for ACPI (other than for detecting the modules), a new function fw_unreserved_regions() is introduced. It will behave the same way on DT system. On ACPI system, it will unreserve the whole region. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini Tested-by: Elliott Mitchell --- Is there any region we should exclude on ACPI? --- xen/arch/arm/kernel.c | 2 +- xen/arch/arm/setup.c | 22 +++++++++++++++++----- xen/include/asm-arm/setup.h | 2 +- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/xen/arch/arm/kernel.c b/xen/arch/arm/kernel.c index 032923853f2c..ab78689ed2a6 100644 --- a/xen/arch/arm/kernel.c +++ b/xen/arch/arm/kernel.c @@ -307,7 +307,7 @@ static __init int kernel_decompress(struct bootmodule *= mod) * Free the original kernel, update the pointers to the * decompressed kernel */ - dt_unreserved_regions(addr, addr + size, init_domheap_pages, 0); + fw_unreserved_regions(addr, addr + size, init_domheap_pages, 0); =20 return 0; } diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 35e5bee04efa..7fcff9af2a7e 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -196,8 +196,9 @@ static void __init processor_id(void) processor_setup(); } =20 -void __init dt_unreserved_regions(paddr_t s, paddr_t e, - void (*cb)(paddr_t, paddr_t), int first) +static void __init dt_unreserved_regions(paddr_t s, paddr_t e, + void (*cb)(paddr_t, paddr_t), + int first) { int i, nr =3D fdt_num_mem_rsv(device_tree_flattened); =20 @@ -244,6 +245,17 @@ void __init dt_unreserved_regions(paddr_t s, paddr_t e, cb(s, e); } =20 +void __init fw_unreserved_regions(paddr_t s, paddr_t e, + void (*cb)(paddr_t, paddr_t), int first) +{ + if ( acpi_disabled ) + dt_unreserved_regions(s, e, cb, first); + else + cb(s, e); +} + + + struct bootmodule __init *add_boot_module(bootmodule_kind kind, paddr_t start, paddr_t size, bool domU) @@ -405,7 +417,7 @@ void __init discard_initial_modules(void) !mfn_valid(maddr_to_mfn(e)) ) continue; =20 - dt_unreserved_regions(s, e, init_domheap_pages, 0); + fw_unreserved_regions(s, e, init_domheap_pages, 0); } =20 mi->nr_mods =3D 0; @@ -712,7 +724,7 @@ static void __init setup_mm(void) n =3D mfn_to_maddr(mfn_add(xenheap_mfn_start, xenheap_page= s)); } =20 - dt_unreserved_regions(s, e, init_boot_pages, 0); + fw_unreserved_regions(s, e, init_boot_pages, 0); =20 s =3D n; } @@ -765,7 +777,7 @@ static void __init setup_mm(void) if ( e > bank_end ) e =3D bank_end; =20 - dt_unreserved_regions(s, e, init_boot_pages, 0); + fw_unreserved_regions(s, e, init_boot_pages, 0); s =3D n; } } diff --git a/xen/include/asm-arm/setup.h b/xen/include/asm-arm/setup.h index 2f8f24e286ed..34df23247b87 100644 --- a/xen/include/asm-arm/setup.h +++ b/xen/include/asm-arm/setup.h @@ -96,7 +96,7 @@ int construct_dom0(struct domain *d); void create_domUs(void); =20 void discard_initial_modules(void); -void dt_unreserved_regions(paddr_t s, paddr_t e, +void fw_unreserved_regions(paddr_t s, paddr_t e, void (*cb)(paddr_t, paddr_t), int first); =20 size_t boot_fdt_info(const void *fdt, paddr_t paddr); --=20 2.17.1