如何获得每个支持的CPU标志作为QEMU CPU标志?



在我的QEMU虚拟机,我需要使用特定的CPU模型,但是启用了最大CPU标志(为了性能).

要做到这一点,我想使用/proc/cpuinfo并使用grepcut来获得标志,但问题是QEMU使用不同的名称(例如sse4_2将是sse4.2)。

那么我该怎么做关于获得CPU标志,然后将它们转换为有效的QEMU CPU标志?

列出所有标志:

qemu-system-x86_64 -enable-kvm -cpu help

和测试是否工作(按ctrl+c结束):

qemu-system-x86_64 -enable-kvm -cpu base,+vmx-entry-load-perf-global-ctrl -vga none -monitor stdio -vnc :999

"check"如果不支持,Arg应该说一些输出(但似乎对我来说没有改变任何东西),例如

-cpu Nehalem,check

然后你可以得到一些错误的输出…

我不知道这是否有意义…但是这里有一个尝试将每个标志添加到base:

allflags=$(qemu-system-x86_64 -cpu help | awk '/flags/ {y=1; getline}; y {print}' | tr ' ' 'n' | grep -Ev "^$" | sed -r 's|^|+|' | tr 'n' ',' | sed -r "s|,$||")
qemu-system-x86_64 -enable-kvm -cpu "base,check,${allflags}" -vga none -monitor stdio -vnc :999

我的ryzen 1700X上的输出:

QEMU 6.0.0 monitor - type 'help' for more information
(qemu) qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:EDX.pn [bit 18]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:EDX.ds [bit 21]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:EDX.acpi [bit 22]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:EDX.ss [bit 27]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:EDX.ht [bit 28]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:EDX.tm [bit 29]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:EDX.ia64 [bit 30]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:EDX.pbe [bit 31]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.dtes64 [bit 2]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.monitor [bit 3]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.ds-cpl [bit 4]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.vmx [bit 5]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.smx [bit 6]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.est [bit 7]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.tm2 [bit 8]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.cid [bit 10]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.xtpr [bit 14]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.pdcm [bit 15]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.pcid [bit 17]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.01H:ECX.dca [bit 18]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EBX.hle [bit 4]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EBX.erms [bit 9]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EBX.invpcid [bit 10]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EBX.rtm [bit 11]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EBX.mpx [bit 14]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EBX.avx512f [bit 16]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EBX.avx512dq [bit 17]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EBX.avx512ifma [bit 21]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EBX.pcommit [bit 22]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EBX.clwb [bit 24]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EBX.intel-pt [bit 25]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EBX.avx512pf [bit 26]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EBX.avx512er [bit 27]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EBX.avx512cd [bit 28]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EBX.avx512bw [bit 30]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EBX.avx512vl [bit 31]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:ECX.avx512vbmi [bit 1]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:ECX.umip [bit 2]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:ECX.pku [bit 3]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:ECX.waitpkg [bit 5]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:ECX.avx512vbmi2 [bit 6]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:ECX.gfni [bit 8]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:ECX.vaes [bit 9]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:ECX.vpclmulqdq [bit 10]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:ECX.avx512vnni [bit 11]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:ECX.avx512bitalg [bit 12]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:ECX.avx512-vpopcntdq [bit 14]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:ECX.la57 [bit 16]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:ECX.rdpid [bit 22]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:ECX.bus-lock-detect [bit 24]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:ECX.cldemote [bit 25]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:ECX.movdiri [bit 27]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:ECX.movdir64b [bit 28]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:ECX.pks [bit 31]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EDX.avx512-4vnniw [bit 2]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EDX.avx512-4fmaps [bit 3]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EDX.fsrm [bit 4]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EDX.avx512-vp2intersect [bit 8]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EDX.md-clear [bit 10]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EDX.serialize [bit 14]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EDX.tsx-ldtrk [bit 16]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EDX.avx512-fp16 [bit 23]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EDX.spec-ctrl [bit 26]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EDX.stibp [bit 27]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EDX.core-capability [bit 30]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EDX.ssbd [bit 31]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.07H:EAX.avx512-bf16 [bit 5]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.80000001H:EDX.3dnowext [bit 30]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.80000001H:EDX.3dnow [bit 31]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.80000001H:ECX.extapic [bit 3]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.80000001H:ECX.ibs [bit 10]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.80000001H:ECX.xop [bit 11]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.80000001H:ECX.skinit [bit 12]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.80000001H:ECX.wdt [bit 13]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.80000001H:ECX.lwp [bit 15]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.80000001H:ECX.fma4 [bit 16]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.80000001H:ECX.tce [bit 17]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.80000001H:ECX.nodeid-msr [bit 19]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.80000001H:ECX.tbm [bit 21]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.80000001H:ECX.perfctr-nb [bit 24]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.80000008H:EBX.wbnoinvd [bit 9]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.80000008H:EBX.ibpb [bit 12]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.80000008H:EBX.ibrs [bit 14]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.80000008H:EBX.amd-stibp [bit 15]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.80000008H:EBX.amd-ssbd [bit 24]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.80000008H:EBX.amd-no-ssb [bit 26]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.C0000001H:EDX.xstore [bit 2]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.C0000001H:EDX.xstore-en [bit 3]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.C0000001H:EDX.xcrypt [bit 6]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.C0000001H:EDX.xcrypt-en [bit 7]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.C0000001H:EDX.ace2 [bit 8]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.C0000001H:EDX.ace2-en [bit 9]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.C0000001H:EDX.phe [bit 10]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.C0000001H:EDX.phe-en [bit 11]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.C0000001H:EDX.pmm [bit 12]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.C0000001H:EDX.pmm-en [bit 13]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.40000001H:EAX.kvm-mmu [bit 2]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.40000001H:EAX.kvm-msi-ext-dest-id [bit 15]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.8000000AH:EDX.lbrv [bit 1]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.8000000AH:EDX.svm-lock [bit 2]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.8000000AH:EDX.tsc-scale [bit 4]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.8000000AH:EDX.vmcb-clean [bit 5]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.8000000AH:EDX.flushbyasid [bit 6]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.8000000AH:EDX.decodeassists [bit 7]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.8000000AH:EDX.pause-filter [bit 10]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.8000000AH:EDX.pfthreshold [bit 12]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.8000000AH:EDX.avic [bit 13]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.8000000AH:EDX.v-vmsave-vmload [bit 15]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.8000000AH:EDX.vgif [bit 16]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.8000000AH:EDX.svme-addr-chk [bit 28]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.0DH:EAX [bit 3]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.0DH:EAX [bit 4]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.0DH:EAX [bit 5]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.0DH:EAX [bit 6]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.0DH:EAX [bit 7]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.0DH:EAX [bit 9]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(10AH).ibrs-all [bit 1]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(10AH).rsba [bit 2]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(10AH).ssb-no [bit 4]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(10AH).tsx-ctrl [bit 7]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(10AH).taa-no [bit 8]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(CFH).split-lock-detect [bit 5]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(345H).full-width-write [bit 13]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48EH).vmx-vintr-pending [bit 2]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48EH).vmx-tsc-offset [bit 3]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48EH).vmx-hlt-exit [bit 7]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48EH).vmx-invlpg-exit [bit 9]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48EH).vmx-mwait-exit [bit 10]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48EH).vmx-rdpmc-exit [bit 11]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48EH).vmx-rdtsc-exit [bit 12]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48EH).vmx-cr3-load-noexit [bit 15]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48EH).vmx-cr3-store-noexit [bit 16]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48EH).vmx-cr8-load-exit [bit 19]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48EH).vmx-cr8-store-exit [bit 20]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48EH).vmx-flexpriority [bit 21]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48EH).vmx-vnmi-pending [bit 22]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48EH).vmx-movdr-exit [bit 23]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48EH).vmx-io-exit [bit 24]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48EH).vmx-io-bitmap [bit 25]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48EH).vmx-mtf [bit 27]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48EH).vmx-msr-bitmap [bit 28]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48EH).vmx-monitor-exit [bit 29]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48EH).vmx-pause-exit [bit 30]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48EH).vmx-secondary-ctls [bit 31]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48BH).vmx-apicv-xapic [bit 0]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48BH).vmx-ept [bit 1]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48BH).vmx-desc-exit [bit 2]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48BH).vmx-rdtscp-exit [bit 3]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48BH).vmx-apicv-x2apic [bit 4]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48BH).vmx-vpid [bit 5]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48BH).vmx-wbinvd-exit [bit 6]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48BH).vmx-unrestricted-guest [bit 7]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48BH).vmx-apicv-register [bit 8]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48BH).vmx-apicv-vid [bit 9]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48BH).vmx-ple [bit 10]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48BH).vmx-rdrand-exit [bit 11]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48BH).vmx-invpcid-exit [bit 12]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48BH).vmx-vmfunc [bit 13]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48BH).vmx-shadow-vmcs [bit 14]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48BH).vmx-encls-exit [bit 15]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48BH).vmx-rdseed-exit [bit 16]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48BH).vmx-pml [bit 17]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48BH).vmx-xsaves [bit 20]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48DH).vmx-intr-exit [bit 0]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48DH).vmx-nmi-exit [bit 3]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48DH).vmx-vnmi [bit 5]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48DH).vmx-preemption-timer [bit 6]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48DH).vmx-posted-intr [bit 7]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48FH).vmx-exit-nosave-debugctl [bit 2]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48FH).vmx-exit-load-perf-global-ctrl [bit 12]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48FH).vmx-exit-ack-intr [bit 15]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48FH).vmx-exit-save-pat [bit 18]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48FH).vmx-exit-load-pat [bit 19]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48FH).vmx-exit-save-efer [bit 20]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48FH).vmx-exit-load-efer [bit 21]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48FH).vmx-exit-save-preemption-timer [bit 22]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48FH).vmx-exit-clear-bndcfgs [bit 23]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48FH).vmx-exit-clear-rtit-ctl [bit 25]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48FH).vmx-exit-load-pkrs [bit 29]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(490H).vmx-entry-noload-debugctl [bit 2]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(490H).vmx-entry-ia32e-mode [bit 9]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(490H).vmx-entry-load-perf-global-ctrl [bit 13]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(490H).vmx-entry-load-pat [bit 14]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(490H).vmx-entry-load-efer [bit 15]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(490H).vmx-entry-load-bndcfgs [bit 16]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(490H).vmx-entry-load-rtit-ctl [bit 18]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(490H).vmx-entry-load-pkrs [bit 22]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(485H).vmx-store-lma [bit 5]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(485H).vmx-activity-hlt [bit 6]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(485H).vmx-activity-shutdown [bit 7]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(485H).vmx-activity-wait-sipi [bit 8]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(485H).vmx-vmwrite-vmexit-fields [bit 29]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(485H).vmx-zero-len-inject [bit 30]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48CH).vmx-ept-execonly [bit 0]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48CH).vmx-page-walk-4 [bit 6]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48CH).vmx-page-walk-5 [bit 7]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48CH) [bit 14]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48CH).vmx-ept-2mb [bit 16]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48CH).vmx-ept-1gb [bit 17]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48CH).vmx-invept [bit 20]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48CH).vmx-eptad [bit 21]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48CH).vmx-ept-advanced-exitinfo [bit 22]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48CH).vmx-invept-single-context [bit 25]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48CH).vmx-invept-all-context [bit 26]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48CH).vmx-invvpid [bit 32]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48CH).vmx-invvpid-single-addr [bit 40]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48CH).vmx-invept-single-context [bit 41]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48CH).vmx-invvpid-all-context [bit 42]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(48CH).vmx-invept-single-context-noglobals [bit 43]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(480H).vmx-ins-outs [bit 54]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(480H).vmx-true-ctls [bit 55]
qemu-system-x86_64: warning: host doesn't support requested feature: MSR(491H).vmx-eptp-switching [bit 0]
qemu-system-x86_64: warning: host doesn't support requested feature: CPUID.14H:ECX.intel-pt-lip [bit 31]

我假设您正在运行带有-cpu选项的qemu,并且使用旧的cpu型号,例如Nehalem。所有代码示例都来自qemu 5.0源代码。我假设你熟悉cpuid指令。在targeti386cpu.c文件中可以找到

static X86CPUDefinition builtin_x86_defs[] = {

数组中可用的CPU型号。有一个Nehalem条目:

.name = "Nehalem",
.features[FEAT_1_EDX] =
CPUID_VME | CPUID_SSE2 | CPUID_SSE | CPUID_FXSR | CPUID_MMX |

例如,FEAT_1_EDX描述了该型号cpu在edx寄存器执行cpuid 1时返回的值。您还可以看到所有其他仿真代码。

当qemu运行kvm加速时,它会在kvm_arch_init_vcpu函数中将此数据发送给targeti386kvm.c中的kvm。此函数初始化cpuid_data并调用kvm_vcpu_ioctl(cs, KVM_SET_CPUID2, &cpuid_data);

这个想法是为你想要调整的代码执行cpuid指令,并在将它们发送给kvm之前根据cpuid_data条目添加可用的位。

例如调整cpuid 1 edx和ecx可以这样做:

struct kvm_cpuid_entry2 *c = cpuid_find_entry(&cpuid_data.cpuid, 1, 0);
if (c) {
c->ecx |= cpuid1_ecx;
c->edx |= cpuid1_edx;
}

其中cpuid1_ecxcpuid1_edx是在主机上执行cpuid 1时在ecx和edx中返回的值。由于特征位在不同的cpu函数中返回,您必须手动选择要调整的。一个好的起点是调整builtin_x86_defs中为您的cpu找到的所有FEAT_xx条目。

较新的cpu可以有更多的特征条目,建模这些是困难的,但可能。

您可以使用以下命令列出可用的CPU型号;

./qemu-system-<target> -cpu ?

目标选项可以是arm, aarch64, avr, i386等

最新更新