Merge branch 'riscv/queue' into 'master'
riscv: Fix virt_to_phys
See merge request kvm-unit-tests/kvm-unit-tests!63
diff --git a/lib/asm-generic/page.h b/lib/asm-generic/page.h
index 5ed0861..2ed77f4 100644
--- a/lib/asm-generic/page.h
+++ b/lib/asm-generic/page.h
@@ -19,6 +19,8 @@
#define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE)
+#define offset_in_page(p) ((unsigned long)(p) & ~PAGE_MASK)
+
#define __va(x) ((void *)((unsigned long) (x)))
#define __pa(x) ((unsigned long) (x))
#define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT)
diff --git a/lib/riscv/mmu.c b/lib/riscv/mmu.c
index bd00688..165a703 100644
--- a/lib/riscv/mmu.c
+++ b/lib/riscv/mmu.c
@@ -194,7 +194,7 @@
paddr = virt_to_pte_phys(pgtable, (void *)address);
assert(sizeof(long) == 8 || !(paddr >> 32));
- return (unsigned long)paddr;
+ return (unsigned long)paddr | offset_in_page(address);
}
void *phys_to_virt(unsigned long address)