Skip to content

Commit cab85a6

Browse files
pbo-linarostsquad
authored andcommitted
contrib/plugins/hwprofile: fix 32-bit build
Reviewed-by: Richard Henderson <[email protected]> Signed-off-by: Pierrick Bouvier <[email protected]> Message-Id: <[email protected]> Signed-off-by: Alex Bennée <[email protected]> Message-Id: <[email protected]>
1 parent a5555b2 commit cab85a6

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

contrib/plugins/hwprofile.c

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ typedef struct {
4343

4444
static GMutex lock;
4545
static GHashTable *devices;
46+
static struct qemu_plugin_scoreboard *source_pc_scoreboard;
47+
static qemu_plugin_u64 source_pc;
4648

4749
/* track the access pattern to a piece of HW */
4850
static bool pattern;
@@ -159,7 +161,7 @@ static DeviceCounts *new_count(const char *name, uint64_t base)
159161
count->name = name;
160162
count->base = base;
161163
if (pattern || source) {
162-
count->detail = g_hash_table_new(NULL, NULL);
164+
count->detail = g_hash_table_new(g_int64_hash, g_int64_equal);
163165
}
164166
g_hash_table_insert(devices, (gpointer) name, count);
165167
return count;
@@ -169,7 +171,7 @@ static IOLocationCounts *new_location(GHashTable *table, uint64_t off_or_pc)
169171
{
170172
IOLocationCounts *loc = g_new0(IOLocationCounts, 1);
171173
loc->off_or_pc = off_or_pc;
172-
g_hash_table_insert(table, (gpointer) off_or_pc, loc);
174+
g_hash_table_insert(table, &loc->off_or_pc, loc);
173175
return loc;
174176
}
175177

@@ -224,12 +226,12 @@ static void vcpu_haddr(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo,
224226

225227
/* either track offsets or source of access */
226228
if (source) {
227-
off = (uint64_t) udata;
229+
off = qemu_plugin_u64_get(source_pc, cpu_index);
228230
}
229231

230232
if (pattern || source) {
231233
IOLocationCounts *io_count = g_hash_table_lookup(counts->detail,
232-
(gpointer) off);
234+
&off);
233235
if (!io_count) {
234236
io_count = new_location(counts->detail, off);
235237
}
@@ -247,10 +249,14 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb)
247249

248250
for (i = 0; i < n; i++) {
249251
struct qemu_plugin_insn *insn = qemu_plugin_tb_get_insn(tb, i);
250-
gpointer udata = (gpointer) (source ? qemu_plugin_insn_vaddr(insn) : 0);
252+
if (source) {
253+
uint64_t pc = qemu_plugin_insn_vaddr(insn);
254+
qemu_plugin_register_vcpu_mem_inline_per_vcpu(
255+
insn, rw, QEMU_PLUGIN_INLINE_STORE_U64,
256+
source_pc, pc);
257+
}
251258
qemu_plugin_register_vcpu_mem_cb(insn, vcpu_haddr,
252-
QEMU_PLUGIN_CB_NO_REGS,
253-
rw, udata);
259+
QEMU_PLUGIN_CB_NO_REGS, rw, NULL);
254260
}
255261
}
256262

@@ -306,10 +312,9 @@ int qemu_plugin_install(qemu_plugin_id_t id, const qemu_info_t *info,
306312
return -1;
307313
}
308314

309-
/* Just warn about overflow */
310-
if (info->system.smp_vcpus > 64 ||
311-
info->system.max_vcpus > 64) {
312-
fprintf(stderr, "hwprofile: can only track up to 64 CPUs\n");
315+
if (source) {
316+
source_pc_scoreboard = qemu_plugin_scoreboard_new(sizeof(uint64_t));
317+
source_pc = qemu_plugin_scoreboard_u64(source_pc_scoreboard);
313318
}
314319

315320
plugin_init();

0 commit comments

Comments
 (0)