Skip to content

Commit

Permalink
Add trampolines for unused callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
jamcleod committed Oct 19, 2021
1 parent baf7d2b commit b5b6e45
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
15 changes: 15 additions & 0 deletions panda/include/panda/callbacks/cb-macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,21 @@
(*(panda_cb*)context) . ENTRY_NAME(name, EVERY_SECOND(__VA_ARGS__)); \
}

#define MAKE_CALLBACK_int(name_upper, name, ...) \
int panda_callbacks_ ## name(COMBINE_TYPES(__VA_ARGS__)) { \
panda_cb_list *plist; \
for (plist = panda_cbs[PANDA_CB_ ## name_upper]; \
plist != NULL; \
plist = panda_cb_list_next(plist)) { \
if (plist->enabled) \
plist->entry. ENTRY_NAME(name, plist->context, EVERY_SECOND(__VA_ARGS__)); \
} \
return 0; \
} \
int panda_cb_trampoline_ ## name(void* context, COMBINE_TYPES(__VA_ARGS__)) {\
return (*(panda_cb*)context) . ENTRY_NAME(name, EVERY_SECOND(__VA_ARGS__)); \
}

// Call all enabled & registered functions for this callback. Return
// all results together OR'd together.
// XXX: double underscore in name is intentional
Expand Down
6 changes: 3 additions & 3 deletions panda/include/panda/callbacks/cb-trampolines.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void panda_cb_trampoline_phys_mem_after_write(void* context, CPUState *env, targ

int panda_cb_trampoline_insn_exec(void* context, CPUState *env, target_ptr_t pc);
int panda_cb_trampoline_after_insn_exec(void* context, CPUState *env, target_ptr_t pc);
//int panda_cb_trampoline_monitor(void* context, Monitor *mon, const char *cmd);
int panda_cb_trampoline_monitor(void* context, Monitor *mon, const char *cmd);
//int panda_cb_trampoline_before_loadvm(void* context);
void panda_cb_trampoline_replay_hd_transfer(void* context, CPUState *env, uint32_t type, target_ptr_t src_addr, target_ptr_t dest_addr, size_t num_bytes);
void panda_cb_trampoline_after_machine_init(void* context, CPUState *env);
Expand Down Expand Up @@ -49,8 +49,8 @@ void panda_cb_trampoline_cbaddr(void* context);
/* invoked from cputlb.c */
void panda_cb_trampoline_mmio_after_read(void* context, CPUState *env, target_ptr_t physaddr, target_ptr_t vaddr, size_t size, uint64_t *val);
void panda_cb_trampoline_mmio_before_write(void* context, CPUState *env, target_ptr_t physaddr, target_ptr_t vaddr, size_t size, uint64_t *val);
//void panda_cb_trampoline_hd_read(void* context, CPUState *env);
//void panda_cb_trampoline_hd_write(void* context, CPUState *env);
void panda_cb_trampoline_hd_read(void* context, CPUState *env);
void panda_cb_trampoline_hd_write(void* context, CPUState *env);

/* invoked from exec.c */
void panda_cb_trampoline_replay_before_dma(void* context, CPUState *env, const uint8_t *buf, hwaddr addr, size_t size, bool is_write);
Expand Down
7 changes: 4 additions & 3 deletions panda/src/callbacks.c
Original file line number Diff line number Diff line change
Expand Up @@ -447,11 +447,12 @@ panda_cb_with_context panda_get_cb_trampoline(panda_cb_type type) {
CASE_CB_TRAMPOLINE(PHYS_MEM_AFTER_WRITE,phys_mem_after_write)
CASE_CB_TRAMPOLINE(MMIO_AFTER_READ,mmio_after_read)
CASE_CB_TRAMPOLINE(MMIO_BEFORE_WRITE,mmio_before_write)
//CASE_CB_TRAMPOLINE(HD_READ,hd_read)
//CASE_CB_TRAMPOLINE(HD_WRITE,hd_write)
CASE_CB_TRAMPOLINE(HD_READ,hd_read)
CASE_CB_TRAMPOLINE(HD_WRITE,hd_write)
CASE_CB_TRAMPOLINE(GUEST_HYPERCALL,guest_hypercall)
//CASE_CB_TRAMPOLINE(MONITOR,monitor)
CASE_CB_TRAMPOLINE(MONITOR,monitor)
CASE_CB_TRAMPOLINE(CPU_RESTORE_STATE,cpu_restore_state)

//CASE_CB_TRAMPOLINE(BEFORE_LOADVM,before_loadvm)
CASE_CB_TRAMPOLINE(ASID_CHANGED,asid_changed)
CASE_CB_TRAMPOLINE(REPLAY_HD_TRANSFER,replay_hd_transfer)
Expand Down
5 changes: 5 additions & 0 deletions panda/src/cb-support.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ MAKE_CALLBACK(void, START_BLOCK_EXEC, start_block_exec,
MAKE_CALLBACK(void, END_BLOCK_EXEC, end_block_exec,
CPUState*, env, TranslationBlock*, tb)

// these aren't used
MAKE_CALLBACK(void, HD_READ, hd_read, CPUState*, env);
MAKE_CALLBACK(void, HD_WRITE, hd_write, CPUState*, env);
MAKE_CALLBACK(int, MONITOR, monitor, Monitor*, mon, const char*, cmd);

// Helper - get a physical address
static inline hwaddr get_paddr(CPUState *cpu, target_ptr_t addr, void *ram_ptr) {
if (!ram_ptr) {
Expand Down

0 comments on commit b5b6e45

Please sign in to comment.