From nobody Mon May 6 03:00:31 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1579600259; cv=none; d=zohomail.com; s=zohoarc; b=b61phpiyQR4i6ekK+T0w4HjLnVo65nXNw6nuk6dDKZuV+R5i6AJcriB3nZlR7xhnULVSvxEsVfwOTeyMAR/1yl0zfeGDEK2cTtJmH4fMw8nCPLFwAzpg6bOWP009oJku5tGtObeAsmYopiR5qo2RgSlmNj71v7FL4nPHnYh/oak= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579600259; h=Content-Type:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=Fnds1HXsH1wC+c1j6yT5e0P8qkt7aW+Z/YGol7SHDt8=; b=UD+zVWbl9Cb8PUqqtjJF9hRjYXwAU7vgTkH6FfZUeEBi4zh9UaIfnu4gQLDyd3hK7PcW/n5i/ttTch8tKA3qC2xAkmGkuhI2/BRkC2hGP3va0h98fYq7DLCWBlDeLf5lvIxbrRfmmNnzp5wsUgDDDo03bjcbk8fPKrQ+dvIraJY= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) 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 1579600259074707.99574848853; Tue, 21 Jan 2020 01:50:59 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1itqAh-0002ZE-3a; Tue, 21 Jan 2020 09:50:07 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1itqAf-0002Pq-KH for xen-devel@lists.xenproject.org; Tue, 21 Jan 2020 09:50:05 +0000 Received: from huawei.com (unknown [45.249.212.35]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 5f0c5336-3c33-11ea-9fd7-bc764e2007e4; Tue, 21 Jan 2020 09:49:53 +0000 (UTC) Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 76F659D12634EFFEEB6F; Tue, 21 Jan 2020 17:49:51 +0800 (CST) Received: from [127.0.0.1] (10.57.101.250) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.439.0; Tue, 21 Jan 2020 17:49:42 +0800 X-Inumbo-ID: 5f0c5336-3c33-11ea-9fd7-bc764e2007e4 To: From: Wei Xu Message-ID: <5E26C935.9080107@hisilicon.com> Date: Tue, 21 Jan 2020 17:49:41 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 X-Originating-IP: [10.57.101.250] X-CFilter-Loop: Reflected Subject: [Xen-devel] [PATCH] arm/acpi: Add __acpi_unmap_table function for ARM X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Julien Grall , "Zengtao \(B\)" , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Linuxarm , Shameerali Kolothum Thodi , xuwei5@hisilicon.com, Jan Beulich , Volodymyr_Babchuk@epam.com Content-Type: multipart/mixed; boundary="===============8822540550065934821==" Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" --===============8822540550065934821== Content-Type: multipart/alternative; boundary="------------030604060806010707090406" --------------030604060806010707090406 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Add __acpi_unmap_table function for ARM and invoke it at acpi_os_unmap_memory to make sure the related fixmap has been cleared before using it for a different mapping. Signed-off-by: Wei Xu --- xen/arch/arm/acpi/lib.c | 25 +++++++++++++++++++++++++ xen/drivers/acpi/osl.c | 2 ++ xen/include/xen/acpi.h | 1 + 3 files changed, 28 insertions(+) diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c index 4fc6e17..69e87ec 100644 --- a/xen/arch/arm/acpi/lib.c +++ b/xen/arch/arm/acpi/lib.c @@ -49,6 +49,31 @@ char *__acpi_map_table(paddr_t phys, unsigned long size) return ((char *) base + offset); } +void __acpi_unmap_table(void __iomem * virt, unsigned long size) +{ + unsigned long base, end; + int idx; + + base = FIXMAP_ADDR(FIXMAP_ACPI_BEGIN); + end = FIXMAP_ADDR(FIXMAP_ACPI_END); + + if ( (unsigned long)virt < base || (unsigned long)virt > end ) + { + return; + } + + idx = FIXMAP_ACPI_BEGIN + ((unsigned long)virt - base) / PAGE_SIZE; + clear_fixmap(idx); + + while ( size > PAGE_SIZE ) + { + if ( ++idx > FIXMAP_ACPI_END ) + return; + clear_fixmap(idx); + size -= PAGE_SIZE; + } +} + /* True to indicate PSCI 0.2+ is implemented */ bool __init acpi_psci_present(void) { diff --git a/xen/drivers/acpi/osl.c b/xen/drivers/acpi/osl.c index 4c8bb78..18666c7 100644 --- a/xen/drivers/acpi/osl.c +++ b/xen/drivers/acpi/osl.c @@ -114,6 +114,8 @@ void acpi_os_unmap_memory(void __iomem * virt, acpi_size size) return; } + __acpi_unmap_table(virt, size); + if (system_state >= 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 5cfa060..acb00a2 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_subtable_header *header, co unsigned int acpi_get_processor_id (unsigned int cpu); char * __acpi_map_table (paddr_t phys_addr, unsigned long size); +void __acpi_unmap_table(void __iomem * virt, unsigned long size); int acpi_boot_init (void); int acpi_boot_table_init (void); int acpi_numa_init (void); -- 2.8.1 . --------------030604060806010707090406 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: 7bit
Add __acpi_unmap_table function for ARM and invoke it at acpi_os_unmap_memory
to make sure the related fixmap has been cleared before using it for a
different mapping.

Signed-off-by: Wei Xu <xuwei5@hisilicon.com>
---
 xen/arch/arm/acpi/lib.c | 25 +++++++++++++++++++++++++
 xen/drivers/acpi/osl.c  |  2 ++
 xen/include/xen/acpi.h  |  1 +
 3 files changed, 28 insertions(+)

diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c
index 4fc6e17..69e87ec 100644
--- a/xen/arch/arm/acpi/lib.c
+++ b/xen/arch/arm/acpi/lib.c
@@ -49,6 +49,31 @@ char *__acpi_map_table(paddr_t phys, unsigned long size)
     return ((char *) base + offset);
 }
 
+void __acpi_unmap_table(void __iomem * virt, unsigned long size)
+{
+    unsigned long base, end;
+    int idx;
+
+    base = FIXMAP_ADDR(FIXMAP_ACPI_BEGIN);
+    end = FIXMAP_ADDR(FIXMAP_ACPI_END);
+
+    if ( (unsigned long)virt < base || (unsigned long)virt > end )
+    {
+        return;
+    }
+
+    idx = FIXMAP_ACPI_BEGIN + ((unsigned long)virt - base) / PAGE_SIZE;
+    clear_fixmap(idx);
+
+    while ( size > PAGE_SIZE )
+    {
+        if ( ++idx > FIXMAP_ACPI_END )
+            return;
+        clear_fixmap(idx);
+        size -= PAGE_SIZE;
+    }
+}
+
 /* True to indicate PSCI 0.2+ is implemented */
 bool __init acpi_psci_present(void)
 {
diff --git a/xen/drivers/acpi/osl.c b/xen/drivers/acpi/osl.c
index 4c8bb78..18666c7 100644
--- a/xen/drivers/acpi/osl.c
+++ b/xen/drivers/acpi/osl.c
@@ -114,6 +114,8 @@ void acpi_os_unmap_memory(void __iomem * virt, acpi_size size)
 		return;
 	}
 
+	__acpi_unmap_table(virt, size);
+
 	if (system_state >= 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 5cfa060..acb00a2 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_subtable_header *header, co
 
 unsigned int acpi_get_processor_id (unsigned int cpu);
 char * __acpi_map_table (paddr_t phys_addr, unsigned long size);
+void __acpi_unmap_table(void __iomem * virt, unsigned long size);
 int acpi_boot_init (void);
 int acpi_boot_table_init (void);
 int acpi_numa_init (void);
-- 2.8.1 .
--------------030604060806010707090406-- --===============8822540550065934821== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KWGVuLWRldmVs IG1haWxpbmcgbGlzdApYZW4tZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmcKaHR0cHM6Ly9saXN0 cy54ZW5wcm9qZWN0Lm9yZy9tYWlsbWFuL2xpc3RpbmZvL3hlbi1kZXZlbA== --===============8822540550065934821==--