Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Juan Quintela committed May 15, 2023
1 parent 00a3f9c commit 62c5e18
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/exec/target_page.h
Expand Up @@ -18,4 +18,5 @@ size_t qemu_target_page_size(void);
int qemu_target_page_bits(void);
int qemu_target_page_bits_min(void);

size_t qemu_target_pages_to_MiB(size_t pages);
#endif
11 changes: 11 additions & 0 deletions softmmu/physmem.c
Expand Up @@ -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;
Expand Down

0 comments on commit 62c5e18

Please sign in to comment.