Skip to content

Commit

Permalink
contrib/plugins/hwprofile: fix 32 bits
Browse files Browse the repository at this point in the history
Signed-off-by: Pierrick Bouvier <[email protected]>
  • Loading branch information
pbo-linaro committed Dec 16, 2024
1 parent 742c0e8 commit 78c012b
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions contrib/plugins/hwprofile.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ typedef struct {

static GMutex lock;
static GHashTable *devices;
static struct qemu_plugin_scoreboard *source_pc_scoreboard;
static qemu_plugin_u64 source_pc;

/* track the access pattern to a piece of HW */
static bool pattern;
Expand Down Expand Up @@ -224,7 +226,7 @@ static void vcpu_haddr(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo,

/* either track offsets or source of access */
if (source) {
off = (uint64_t) udata;
off = qemu_plugin_u64_get(source_pc, cpu_index);
}

if (pattern || source) {
Expand All @@ -247,10 +249,14 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)

for (i = 0; i < n; i++) {
struct qemu_plugin_insn *insn = qemu_plugin_tb_get_insn(tb, i);
gpointer udata = (gpointer) (source ? qemu_plugin_insn_vaddr(insn) : 0);
if (source) {
uint64_t pc = qemu_plugin_insn_vaddr(insn);
qemu_plugin_register_vcpu_mem_inline_per_vcpu(
insn, rw, QEMU_PLUGIN_INLINE_STORE_U64,
source_pc, pc);
}
qemu_plugin_register_vcpu_mem_cb(insn, vcpu_haddr,
QEMU_PLUGIN_CB_NO_REGS,
rw, udata);
QEMU_PLUGIN_CB_NO_REGS, rw, NULL);
}
}

Expand Down Expand Up @@ -306,10 +312,8 @@ int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info,
return -1;
}

/* Just warn about overflow */
if (info->system.smp_vcpus > 64 ||
info->system.max_vcpus > 64) {
fprintf(stderr, "hwprofile: can only track up to 64 CPUs\n");
if (source) {
source_pc_scoreboard = qemu_plugin_scoreboard_new(sizeof(uint64_t));
}

plugin_init();
Expand Down

0 comments on commit 78c012b

Please sign in to comment.