QEMU 中关于CPU初始化的重要函数调用栈

QEMU的版本是v2.4.0.1之后的

 

 

Breakpoint 1, x86_cpu_realizefn (dev=0x55c743a33e70, errp=0x7ffef5886bb0) at /home/mce/workspace/git/qemu/qemu/target-i386/cpu.c:2821
2821    {
(gdb) bt
#0  x86_cpu_realizefn (dev=0x55c743a33e70, errp=0x7ffef5886bb0) at /home/mce/workspace/git/qemu/qemu/target-i386/cpu.c:2821
#1  0x000055c74234e8e1 in device_set_realized (obj=0x55c743a33e70, value=true, errp=0x7ffef5886d68) at hw/core/qdev.c:1055
#2  0x000055c7424bf771 in property_set_bool (obj=0x55c743a33e70, v=0x55c743a4eb30, opaque=0x55c743a24720, name=0x55c7425ac510 "realized", errp=0x7ffef5886d68) at qom/object.c:1708
#3  0x000055c7424bdda8 in object_property_set (obj=0x55c743a33e70, v=0x55c743a4eb30, name=0x55c7425ac510 "realized", errp=0x7ffef5886d68) at qom/object.c:965
#4  0x000055c7424c063f in object_property_set_qobject (obj=0x55c743a33e70, value=0x55c743a23bc0, name=0x55c7425ac510 "realized", errp=0x7ffef5886d68) at qom/qom-qobject.c:24
#5  0x000055c7424be03e in object_property_set_bool (obj=0x55c743a33e70, value=true, name=0x55c7425ac510 "realized", errp=0x7ffef5886d68) at qom/object.c:1034
#6  0x000055c742223ef3 in pc_new_cpu (cpu_model=0x55c7425ac5c5 "qemu64", apic_id=0, errp=0x7ffef5886dc0) at /home/mce/workspace/git/qemu/qemu/hw/i386/pc.c:1069
#7  0x000055c7422241b0 in pc_cpus_init (cpu_model=0x55c7425ac5c5 "qemu64") at /home/mce/workspace/git/qemu/qemu/hw/i386/pc.c:1145
#8  0x000055c742226c21 in pc_init1 (machine=0x55c7439d2ad0, host_type=0x55c7425ad217 "i440FX-pcihost", pci_type=0x55c7425ad210 "i440FX")
    at /home/mce/workspace/git/qemu/qemu/hw/i386/pc_piix.c:142
#9  0x000055c74222786f in pc_init_v2_5 (machine=0x55c7439d2ad0) at /home/mce/workspace/git/qemu/qemu/hw/i386/pc_piix.c:474
#10 0x000055c7422c9bdf in main (argc=17, argv=0x7ffef5887348, envp=0x7ffef58873d8) at vl.c:4474
(gdb) c
Continuing.
[Thread 0x7fdbdc40b700 (LWP 37527) exited]
[New Thread 0x7fdbdc40b700 (LWP 37538)]
[New Thread 0x7fdbd99ff700 (LWP 37540)]
实例化一个VCPU

Breakpoint 2, kvm_cpu_synchronize_post_init (cpu=0x55c743a33e70) at /home/mce/workspace/git/qemu/qemu/kvm-all.c:1804
1804        run_on_cpu(cpu, do_kvm_cpu_synchronize_post_init, cpu);
(gdb) bt
#0  kvm_cpu_synchronize_post_init (cpu=0x55c743a33e70) at /home/mce/workspace/git/qemu/qemu/kvm-all.c:1804
#1  0x000055c7421a6efd in cpu_synchronize_post_init (cpu=0x55c743a33e70) at /home/mce/workspace/git/qemu/qemu/include/sysemu/kvm.h:430
#2  0x000055c7421a8132 in cpu_synchronize_all_post_init () at /home/mce/workspace/git/qemu/qemu/cpus.c:693
#3  0x000055c7422c9bee in main (argc=17, argv=0x7ffef5887348, envp=0x7ffef58873d8) at vl.c:4480
(gdb) c
Continuing.
[Thread 0x7fdbd99ff700 (LWP 37540) exited]
[Switching to Thread 0x7fdbdc40b700 (LWP 37538)]
主线程停止,等待CPU创建完成的同步信号

Breakpoint 3, do_kvm_cpu_synchronize_post_init (arg=0x55c743a33e70) at /home/mce/workspace/git/qemu/qemu/kvm-all.c:1796
1796        CPUState *cpu = arg;
(gdb) bt
#0  do_kvm_cpu_synchronize_post_init (arg=0x55c743a33e70) at /home/mce/workspace/git/qemu/qemu/kvm-all.c:1796
#1  0x000055c7421a898d in flush_queued_work (cpu=0x55c743a33e70) at /home/mce/workspace/git/qemu/qemu/cpus.c:962
#2  0x000055c7421a8a47 in qemu_wait_io_event_common (cpu=0x55c743a33e70) at /home/mce/workspace/git/qemu/qemu/cpus.c:981
#3  0x000055c7421a8b32 in qemu_kvm_wait_io_event (cpu=0x55c743a33e70) at /home/mce/workspace/git/qemu/qemu/cpus.c:1010
#4  0x000055c7421a8c7c in qemu_kvm_cpu_thread_fn (arg=0x55c743a33e70) at /home/mce/workspace/git/qemu/qemu/cpus.c:1050
#5  0x00007fdbe57dadf5 in start_thread () from /lib64/libpthread.so.0
#6  0x00007fdbe173c1ad in clone () from /lib64/libc.so.6
(gdb) c
Continuing.
VCPU线程创建完毕,发送同步信号给主线程

Breakpoint 4, kvm_put_msr_feature_control (cpu=0x55c743a33e70) at /home/mce/workspace/git/qemu/qemu/target-i386/kvm.c:1311
1311    {
(gdb) c
Continuing.
[New Thread 0x7fdbd99ff700 (LWP 37549)]
设定VCPU的MSR

Breakpoint 4, kvm_put_msr_feature_control (cpu=0x55c743a33e70) at /home/mce/workspace/git/qemu/qemu/target-i386/kvm.c:1311
1311    {
Missing separate debuginfos, use: debuginfo-install cyrus-sasl-md5-2.1.26-17.el7.x86_64 cyrus-sasl-plain-2.1.26-17.el7.x86_64 cyrus-sasl-scram-2.1.26-17.el7.x86_64 libdb-5.3.21-17.el7_0.1.x86_64
(gdb) 
设定VCPU的MSR

(gdb) bt
#0  cpu_common_reset (cpu=0x5570a6b79e70) at qom/cpu.c:239
#1  0x00005570a4ef53ea in x86_cpu_reset (s=0x5570a6b79e70) at /home/mce/workspace/git/qemu/qemu/target-i386/cpu.c:2613
#2  0x00005570a51004e1 in cpu_reset (cpu=0x5570a6b79e70) at qom/cpu.c:233
#3  0x00005570a4ef5ff5 in x86_cpu_realizefn (dev=0x5570a6b79e70, errp=0x7ffe22d45750) at /home/mce/workspace/git/qemu/qemu/target-i386/cpu.c:2919
#4  0x00005570a4fd2921 in device_set_realized (obj=0x5570a6b79e70, value=true, errp=0x7ffe22d45908) at hw/core/qdev.c:1055
#5  0x00005570a51437c9 in property_set_bool (obj=0x5570a6b79e70, v=0x5570a6b94b30, opaque=0x5570a6b6a720, name=0x5570a5230570 "realized", errp=0x7ffe22d45908) at qom/object.c:1708
#6  0x00005570a5141e00 in object_property_set (obj=0x5570a6b79e70, v=0x5570a6b94b30, name=0x5570a5230570 "realized", errp=0x7ffe22d45908) at qom/object.c:965
#7  0x00005570a5144697 in object_property_set_qobject (obj=0x5570a6b79e70, value=0x5570a6b69bc0, name=0x5570a5230570 "realized", errp=0x7ffe22d45908) at qom/qom-qobject.c:24
#8  0x00005570a5142096 in object_property_set_bool (obj=0x5570a6b79e70, value=true, name=0x5570a5230570 "realized", errp=0x7ffe22d45908) at qom/object.c:1034
#9  0x00005570a4ea7ef3 in pc_new_cpu (cpu_model=0x5570a5230625 "qemu64", apic_id=0, errp=0x7ffe22d45960) at /home/mce/workspace/git/qemu/qemu/hw/i386/pc.c:1069
#10 0x00005570a4ea81b0 in pc_cpus_init (cpu_model=0x5570a5230625 "qemu64") at /home/mce/workspace/git/qemu/qemu/hw/i386/pc.c:1145
#11 0x00005570a4eaac21 in pc_init1 (machine=0x5570a6b18ad0, host_type=0x5570a5231277 "i440FX-pcihost", pci_type=0x5570a5231270 "i440FX")
    at /home/mce/workspace/git/qemu/qemu/hw/i386/pc_piix.c:142
#12 0x00005570a4eab86f in pc_init_v2_5 (machine=0x5570a6b18ad0) at /home/mce/workspace/git/qemu/qemu/hw/i386/pc_piix.c:474
#13 0x00005570a4f4dc1f in main (argc=17, argv=0x7ffe22d45ee8, envp=0x7ffe22d45f78) at vl.c:4474
出啊时候创建主板,安装VCPU


x86_64
(gdb) bt
#0  x86_cpu_reset (s=0x55c470acfe70) at /home/mce/workspace/git/qemu/qemu/target-i386/cpu.c:2608
#1  0x000055c46f811471 in cpu_reset (cpu=0x55c470acfe70) at qom/cpu.c:232
#2  0x000055c46f606797 in x86_cpu_machine_reset_cb (opaque=0x55c470acfe70) at /home/mce/workspace/git/qemu/qemu/target-i386/cpu.c:2717
#3  0x000055c46f656ae1 in qemu_devices_reset () at vl.c:1698
#4  0x000055c46f5bb695 in pc_machine_reset () at /home/mce/workspace/git/qemu/qemu/hw/i386/pc.c:1927
#5  0x000055c46f656b66 in  (report=false) at vl.c:1709
#6  0x000055c46f65ee4f in main (argc=17, argv=0x7fff5ea92208, envp=0x7fff5ea92298) at vl.c:4584
(gdb) 
安装好的虚拟机重启,CPU 重置 ,CPU_reset重置各种寄存器等

 

 

 

 

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值