Skip to content

Commit

Permalink
cacheinfo: add i/d cache_linesize_log
Browse files Browse the repository at this point in the history
Signed-off-by: Emilio G. Cota <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
cota authored and bonzini committed Oct 2, 2018
1 parent 87a09cd commit 5fe2103
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/qemu/osdep.h
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,8 @@ extern uintptr_t qemu_real_host_page_size;
extern intptr_t qemu_real_host_page_mask;

extern int qemu_icache_linesize;
extern int qemu_icache_linesize_log;
extern int qemu_dcache_linesize;
extern int qemu_dcache_linesize_log;

#endif
8 changes: 8 additions & 0 deletions util/cacheinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
*/

#include "qemu/osdep.h"
#include "qemu/host-utils.h"

int qemu_icache_linesize = 0;
int qemu_icache_linesize_log;
int qemu_dcache_linesize = 0;
int qemu_dcache_linesize_log;

/*
* Operating system specific detection mechanisms.
Expand Down Expand Up @@ -172,6 +175,11 @@ static void __attribute__((constructor)) init_cache_info(void)
arch_cache_info(&isize, &dsize);
fallback_cache_info(&isize, &dsize);

assert((isize & (isize - 1)) == 0);
assert((dsize & (dsize - 1)) == 0);

qemu_icache_linesize = isize;
qemu_icache_linesize_log = ctz32(isize);
qemu_dcache_linesize = dsize;
qemu_dcache_linesize_log = ctz32(dsize);
}

0 comments on commit 5fe2103

Please sign in to comment.