hw/loongarch/virt: Fix virt_to_phys_addr function
authorTianrui Zhao <zhaotianrui@loongson.cn>
Mon, 27 Mar 2023 11:23:13 +0000 (19:23 +0800)
committerSong Gao <gaosong@loongson.cn>
Tue, 4 Apr 2023 11:29:13 +0000 (19:29 +0800)
The virt addr should mask TARGET_PHYS_ADDR_SPACE_BITS to
get the phys addr, and this is used by loading kernel elf.

Signed-off-by: Tianrui Zhao <zhaotianrui@loongson.cn>
Acked-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20230327112313.3042829-1-zhaotianrui@loongson.cn>
Signed-off-by: Song Gao <gaosong@loongson.cn>
hw/loongarch/virt.c

index b702c3f51e93d1bb63199f2bcf8f352f9a2d33bf..f4bf14c1c8b79aba8ad546ffbcfa7f7204e98d5d 100644 (file)
@@ -399,7 +399,7 @@ static struct _loaderparams {
 
 static uint64_t cpu_loongarch_virt_to_phys(void *opaque, uint64_t addr)
 {
-    return addr & 0x1fffffffll;
+    return addr & MAKE_64BIT_MASK(0, TARGET_PHYS_ADDR_SPACE_BITS);
 }
 
 static int64_t load_kernel_info(void)