Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754452AbeAIKci (ORCPT + 1 other); Tue, 9 Jan 2018 05:32:38 -0500 Received: from mail-lf0-f48.google.com ([209.85.215.48]:43052 "EHLO mail-lf0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751389AbeAIKcf (ORCPT ); Tue, 9 Jan 2018 05:32:35 -0500 X-Google-Smtp-Source: ACJfBou0UGGXJzxWD2A1w0zS6KgKYaOvz7n4L0djAJ8TRlfqen6/bR5brfZ4mXYq2btXooHqtkaDkw== Subject: Re: [PATCH 1/7] KVM: x86: add SPEC_CTRL and IBPB_SUPPORT accessors To: Liran Alon , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: jmattson@google.com, aliguori@amazon.com, thomas.lendacky@amd.com, dwmw@amazon.co.uk, bp@alien8.de References: <1515434925-10250-1-git-send-email-pbonzini@redhat.com> <1515434925-10250-2-git-send-email-pbonzini@redhat.com> <5A53C1DA.50901@ORACLE.COM> From: Paolo Bonzini Message-ID: <91f7f729-1f45-8081-4ac6-af0c82b712e4@redhat.com> Date: Tue, 9 Jan 2018 11:32:31 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <5A53C1DA.50901@ORACLE.COM> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: 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