All of lore.kernel.org
 help / color / mirror / Atom feed
* qemu questions about x86
@ 2022-04-23  3:25 项晨东
  2022-04-27  3:49 ` Wei Li
  0 siblings, 1 reply; 2+ messages in thread
From: 项晨东 @ 2022-04-23  3:25 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1793 bytes --]

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.
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.
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

[-- Attachment #2: Type: text/html, Size: 2735 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: qemu questions about x86
  2022-04-23  3:25 qemu questions about x86 项晨东
@ 2022-04-27  3:49 ` Wei Li
  0 siblings, 0 replies; 2+ messages in thread
From: Wei Li @ 2022-04-27  3:49 UTC (permalink / raw)
  To: 项晨东; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 3312 bytes --]

Dear 项晨东

On Sat, Apr 23, 2022 at 3:57 PM 项晨东 <xcd19@mails.tsinghua.edu.cn> 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
> <https://www.intel.com/content/dam/develop/external/us/en/documents/architecture-instruction-set-extensions-programming-reference.pdf>
> .
> 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 <https://github.com/Xiang-cd/qemu>, the correspond linux kernel
> version could find here <https://github.com/intel/uintr-linux-kernel>.
> 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

[-- Attachment #2: Type: text/html, Size: 5044 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-04-27  3:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-23  3:25 qemu questions about x86 项晨东
2022-04-27  3:49 ` Wei Li

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.