Dear 项晨东 On Sat, Apr 23, 2022 at 3:57 PM 项晨东 wrote: > Dear qemu developers: > hello~ I'm Xiang Chen dong, a student from Tsinghua University. recently I > am trying to accomplish new X86 feature named user-interrupts which can > view here > > . > I worked for a couple of time, reaching status that new msrs added and > access of msrs is work well, also add new CPUID infos to qemu64, also I > could catch new instructions by modify `translate.c` file. my code could > find here , the correspond linux kernel > version could find here . > but now I have some problems when trying to accomplish instructions named > SENDUIPI and UIRET. > for SENDUIPI, the main function of it is sending the user-interrupts. the > detail way is, machine access memory(address saved in new msr), then read > another address from memory, then write some content to this memory. I read > the qemu source code, find a lot of functions like tcg_gen_qemu_ld, but > when i click into it from IDE(vscode), i could not find where the function > body(maybe due to the macro). So I don't understand how the function works > and how can I wirte a new function to access guest machine memory and write > back in qemu. > tcg_frontend: gen_op_ld_v-->tcg_gen_qemu_ld_tl-->tcg_gen_qemu_ld_i64 (tcg/tcg-op.c)-->gen_ldst_i64 tcg_backend: case INDEX_op_qemu_ld_i64:-->tcg_out_qemu_ld (tcg-target.c.inc tcg/i386) You only need to focus on the frontend and learn from how to translate other instructions. another problem is that I am not quite get the idea of accomplishment of > Interrupt, i could find functions like raise_interrupt and raise_exception, > but I don't understand how it interact with apic(how the control flow > switched to other functions, i find cpu_loop_exit_restore, but can not find > the function body), either how the interrupt handled. > hardware interrupt produce pc_i8259_create-->i8259_init-->x86_allocate_cpu_irq-->pic_irq_request pic_irq_request-->cpu_interrupt(cs, CPU_INTERRUPT_HARD) -->softmmu/cpus.c/cpu_interrupt-->tcg_handle_interrupt -->cpu_reset_interrupt-->hw/core/cpu-common.c/cpu_reset_interrupt hardware interrupt handle cpu_exec-->cpu_handle_interrupt-->cc->tcg_ops->cpu_exec_interrupt-->x86_cpu_exec_interrupt -->cpu_get_pic_interrupt-->pic_read_irq -->do_interrupt_x86_hardirq-->do_interrupt_all-->do_interrupt_protected--> use siglongjmp or sigsetjmp exception handle cpu_handle_exception-->cc->tcg_ops->fake_user_interrupt-->x86_cpu_do_interrupt-->do_interrupt_all > > the problem is difficult in some ways, I discussed with my classmates and > friends, but there is no answer. > so I'm hoping to get important information from you. Is my way of reading > code right? Is there any tools for development(finding the function > body)?How can I accomplish this quickly? > thank you very very much! > best wishes! > Xiang Chen Dong > Everything here maybe have some mistakes. Hope it is useful for you. -- best wishes! Wei Li