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

Re: [Minios-devel] [PATCH v3 08/43] arm64: fix the wrong mask for to_virt/to_phys



Hi,

On 16/04/18 07:31, Huang Shijie wrote:
In the arm64, the mask 0xffffffff will truncate the value, and

s/In the/On/

to_virt/to_phys will get wrong results.

This patch fixes it.

Signed-off-by: Huang Shijie <shijie.huang@xxxxxxx>
---
  include/arm/arch_mm.h | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/arm/arch_mm.h b/include/arm/arch_mm.h
index c66856c..f77a210 100644
--- a/include/arm/arch_mm.h
+++ b/include/arm/arch_mm.h
@@ -15,8 +15,8 @@ extern paddr_t physical_address_offset;
#define DEF_PAGE_PROT 0 -#define to_phys(x) (((paddr_t)(x)+physical_address_offset) & 0xffffffff)
-#define to_virt(x)                 ((void *)(((x)-physical_address_offset) & 
0xffffffff))
+#define to_phys(x)                 (((paddr_t)(x)+physical_address_offset) & 
(~0UL))

While this looks good on arm64, for arm32 unsigned long is not going to be enough. So I think you want to use ~(paddr_t)0 to cover the 32-bit case.

+#define to_virt(x)                 ((void *)(((x)-physical_address_offset) & 
(~0UL)))

For avoidance of doubt, UL here is fine.

#define PFN_UP(x) (unsigned long)(((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
  #define PFN_DOWN(x)                (unsigned long)((x) >> PAGE_SHIFT)


Cheers,

--
Julien Grall

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

 


Rackspace

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