[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [PATCH 05/40] arm64: fix the wrong mask for to_virt/to_phys



In the arm64, the mask 0xffffffff will truncate the value, and
to_virt/to_phys will get wrong results.

By add a new macro, this patch fixes it.

Change-Id: Icbd1d3ddd0d3f850e1a4944d67237f2c14e6a701
Jira: ENTOS-247
Signed-off-by: Huang Shijie <shijie.huang@xxxxxxx>
---
 include/arm/arch_mm.h | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/include/arm/arch_mm.h b/include/arm/arch_mm.h
index 7ce8dd8..6dfa61e 100644
--- a/include/arm/arch_mm.h
+++ b/include/arm/arch_mm.h
@@ -16,8 +16,14 @@ extern paddr_t physical_address_offset;
 
 #define L1_PROT          0
 
-#define to_phys(x)                 (((paddr_t)(x)+physical_address_offset) & 
0xffffffff)
-#define to_virt(x)                 ((void *)(((x)-physical_address_offset) & 
0xffffffff))
+#if defined(__aarch64__)
+#define ADDR_MASK         0xffffffffffffffff
+#else
+#define ADDR_MASK         0xffffffff
+#endif
+
+#define to_phys(x)                 (((paddr_t)(x)-physical_address_offset) & 
ADDR_MASK)
+#define to_virt(x)                 ((void *)(((x)+physical_address_offset) & 
ADDR_MASK))
 
 #define PFN_UP(x)                  (unsigned long)(((x) + PAGE_SIZE-1) >> 
PAGE_SHIFT)
 #define PFN_DOWN(x)                (unsigned long)((x) >> PAGE_SHIFT)
-- 
2.7.4


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/cgi-bin/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.