aboutsummaryrefslogtreecommitdiff
path: root/softmmu
diff options
context:
space:
mode:
authorJuan Quintela <quintela@redhat.com>2023-05-11 16:12:04 +0200
committerJuan Quintela <quintela@redhat.com>2023-05-15 10:33:03 +0200
commit62c5e181eef9482c081bed2cdcc61c1091a7739c (patch)
tree6cfc308d4c2f35942726bfddbb0f6b705c6f30d6 /softmmu
parent00a3f9c60ab0e5c8fd7bfbc300323f012cdd2fa6 (diff)
downloadqemu-62c5e181eef9482c081bed2cdcc61c1091a7739c.zip
qemu-62c5e181eef9482c081bed2cdcc61c1091a7739c.tar.gz
qemu-62c5e181eef9482c081bed2cdcc61c1091a7739c.tar.bz2
softmmu: Create qemu_target_pages_to_MiB()
Function that convert a number of target_pages into its size in MiB. Suggested-by: Richard Henderson <richard.henderson@linaro.org> Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Juan Quintela <quintela@redhat.com> Message-Id: <20230511141208.17779-2-quintela@redhat.com>
Diffstat (limited to 'softmmu')
-rw-r--r--softmmu/physmem.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/softmmu/physmem.c b/softmmu/physmem.c
index 0e0182d..efaed36 100644
--- a/softmmu/physmem.c
+++ b/softmmu/physmem.c
@@ -3357,6 +3357,17 @@ int qemu_target_page_bits_min(void)
return TARGET_PAGE_BITS_MIN;
}
+/* Convert target pages to MiB (2**20). */
+size_t qemu_target_pages_to_MiB(size_t pages)
+{
+ int page_bits = TARGET_PAGE_BITS;
+
+ /* So far, the largest (non-huge) page size is 64k, i.e. 16 bits. */
+ g_assert(page_bits < 20);
+
+ return pages >> (20 - page_bits);
+}
+
bool cpu_physical_memory_is_io(hwaddr phys_addr)
{
MemoryRegion*mr;