ShiningLea
ShiningLea

Reputation: 162

How do I get every supported CPU flags as QEMU CPU flags?

In my QEMU virtual machine, I need to use a specific CPU model, but with the maximum CPU flags enabled (for performance).

To do that I wanted to use /proc/cpuinfo and use grep and cut to get the flags, but the problem is that QEMU uses different names (for example sse4_2 is going to be sse4.2).

So how would I go about getting the CPU flags, then translating them into valid QEMU CPU flags?

Upvotes: 4

Views: 16905

Answers (3)

Purgoufr
Purgoufr

Reputation: 972

You can use the following command to list the avaliable CPU models;

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

target option can be arm, aarch64, avr, i386 etc.

Upvotes: 1

Peter
Peter

Reputation: 3407

To list all the flags:

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

And to test whether something works (hit ctrl+c to end it):

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

The "check" arg is supposed to say some output if it's not supported (but seems not to change anything for me) eg.

-cpu Nehalem,check

And then you can get some errors in output...

And I don't know if this makes any sense...but here's an attempt to add every flag to 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

And the output on my 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]

Upvotes: 4

nevilad
nevilad

Reputation: 985

I assume you are running qemu with -cpu option with an old cpu model, for example Nehalem. All code examples are form qemu 5.0 sources. I assume you are familiar with the cpuid instruction. In target\i386\cpu.c file you can find

static X86CPUDefinition builtin_x86_defs[] = {

array with the available cpu models. There is an entry for Nehalem:

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

For example, FEAT_1_EDX describes the values returned for cpuid 1 execution in edx register for this cpu model. You can see also all other emulated codes.

When running qemu with kvm acceleration, it will send this data to kvm in target\i386\kvm.c in kvm_arch_init_vcpu function. This function initializes cpuid_data and calls kvm_vcpu_ioctl(cs, KVM_SET_CPUID2, &cpuid_data);.

The idea is to execute cpuid instruction for the codes you want to adjust and add the available bits to according cpuid_data entries just before sending them to kvm.

For example adjusting of cpuid 1 edx and ecx can be done so:

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

where cpuid1_ecx and cpuid1_edx are values returned in ecx and edx on cpuid 1 execution on your host. Since the feature bits are returned in different cpuid functions, you have to manually choose which to adjust. A good starting point would be to adjust all the FEAT_xx entries found in builtin_x86_defs for your cpu.

Newer cpus can have more features entries, modelling these is difficult, but possible.

Upvotes: 2

Related Questions