Messages in this thread | | | Subject | Re: [PATCH 1/7] KVM: x86: add SPEC_CTRL and IBPB_SUPPORT accessors | From | Paolo Bonzini <> | Date | Tue, 9 Jan 2018 11:32:31 +0100 |
| |
On 08/01/2018 20:09, Liran Alon wrote: >> >> +static inline bool cpu_has_spec_ctrl(void) >> +{ >> + u32 eax, ebx, ecx, edx; >> + cpuid_count(7, 0, &eax, &ebx, &ecx, &edx); >> + >> + return edx & bit(KVM_CPUID_BIT_SPEC_CTRL); > > Why not just "return cpuid_edx(7) & bit(KVM_CPUID_BIT_SPEC_CTRL);"? > This is also consistent with how cpu_has_ibpb_support() is written.
Leaf 7 explicitly requires you to clear ECX (there could be a leaf for EAX=7,ECX=1 in the future). Even though cpuid_edx does do that, it's not clear from the function that cpuid_edx(7) would work.
Paolo
| |