搭建QEMU环境的可以参考:

QEMU+GDB调试Linux内核总结(全)

https://blog.csdn.net/weixin_37867857/article/details/88205130?spm=1001.2014.3001.5506#t0

这里要说的是指定CPU 型号,因为qemu可以模拟很多cpu,但不同cpu的特性不同,AMD 和Intel的有一些区别,所以需要先看一下支援哪些CPU:

henry@ZX:~$ qemu-system-x86_64 -cpu help
Available CPUs:
x86 486                   (alias configured by machine type)              
x86 486-v1                                                                
x86 Broadwell             (alias configured by machine type)              
x86 Broadwell-IBRS        (alias of Broadwell-v3)                         
x86 Broadwell-noTSX       (alias of Broadwell-v2)                         
x86 Broadwell-noTSX-IBRS  (alias of Broadwell-v4)                         
x86 Broadwell-v1          Intel Core Processor (Broadwell)                
x86 Broadwell-v2          Intel Core Processor (Broadwell, no TSX)        
x86 Broadwell-v3          Intel Core Processor (Broadwell, IBRS)          
x86 Broadwell-v4          Intel Core Processor (Broadwell, no TSX, IBRS)  
x86 Cascadelake-Server    (alias configured by machine type)              
x86 Cascadelake-Server-noTSX  (alias of Cascadelake-Server-v3)                
x86 Cascadelake-Server-v1  Intel Xeon Processor (Cascadelake)              
x86 Cascadelake-Server-v2  Intel Xeon Processor (Cascadelake)              
x86 Cascadelake-Server-v3  Intel Xeon Processor (Cascadelake)              
x86 Conroe                (alias configured by machine type)              
x86 Conroe-v1             Intel Celeron_4x0 (Conroe/Merom Class Core 2)   
x86 Cooperlake            (alias configured by machine type)              
x86 Cooperlake-v1         Intel Xeon Processor (Cooperlake)               
x86 Denverton             (alias configured by machine type)              
x86 Denverton-v1          Intel Atom Processor (Denverton)                
x86 Dhyana                (alias configured by machine type)              
x86 Dhyana-v1             Hygon Dhyana Processor                          
x86 EPYC                  (alias configured by machine type)           
。。。。。。。。。。。。。。。。。。。。   

列表很长,我这里没有列完

然后就算启动,我这里加了-S和-s指令:

qemu-system-x86_64 -kernel linux-5.11.8/arch/x86_64/boot/bzImage -initrd ./my_initramfs.img -append "nokaslr console=ttyS0"  -cpu Broadwell -S -s -nographic  -m 2G

从qemu中就可以看到CPU 型号信息了:

GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:2 个月前 )
186a802e added ecosystem file for PM2 4 年前
5def40a3 Add host customization support for the NodeJS version 4 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐