From nobody Wed Sep 10 02:37:28 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8183C636D6 for ; Tue, 21 Feb 2023 03:22:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233408AbjBUDWK (ORCPT ); Mon, 20 Feb 2023 22:22:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232873AbjBUDWI (ORCPT ); Mon, 20 Feb 2023 22:22:08 -0500 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B483C23D90; Mon, 20 Feb 2023 19:22:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676949727; x=1708485727; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=nCueLugKj6AS1tNo11nKqAVGoXrrBxgB0PinJrUQ9SE=; b=d6ZCXofXA8xGVPsO5PNdyezs9v/B+jfugLaeHaKc1lNd29uoNcWaEXpO pOcLgSlKApT4h94x+T2DsKNafNDfn95u7G7tA9v2wbYDUgotIHtHcdbmZ tzIFGSw4fc0HfZYXfCTNYBYgZAi89KgfDoskHCmmnjRXU6aj9XRAJLdo8 qN72+WYt8DrsdWxlvcEx8Lp+OIecJwpiHF0S3a2izCjdVPUqkFwexNb9I LNZoFMX3UI/Lw3DXCxga0lvcxfFLSuxlC7G1/+PQPc9i+vSSfRUpUsQGp +C9dyBB8mOE0WhQDmdLmpSs8ARROz5mxUyz/EJPbozEgpRTmNPX+rKrT7 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10627"; a="395012922" X-IronPort-AV: E=Sophos;i="5.97,314,1669104000"; d="scan'208";a="395012922" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2023 19:22:07 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10627"; a="780841410" X-IronPort-AV: E=Sophos;i="5.97,314,1669104000"; d="scan'208";a="780841410" Received: from binbinwu-mobl.ccr.corp.intel.com ([10.238.10.94]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2023 19:22:05 -0800 From: Binbin Wu To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: seanjc@google.com, pbonzini@redhat.com, Binbin Wu Subject: [PATCH] KVM: x86: Remove duplicated calls of reverse_cpuid_check() Date: Tue, 21 Feb 2023 11:21:56 +0800 Message-Id: <20230221032156.791-1-binbin.wu@linux.intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Remove duplicated calls of reverse_cpuid_check() in __kvm_cpu_cap_mask() and kvm_cpu_cap_{clear, set, get}(). reverse_cpuid_check() is directly called by: - feature_bit() / __feature_bit() - x86_feature_cpuid() - kvm_cpu_cap_{clear, set, get}() - __kvm_cpu_cap_mask() Also __kvm_cpu_cap_mask() calls x86_feature_cpuid(), and kvm_cpu_cap_{clear, set, get}() calls __feature_bit(). It makes the direct call of reverse_cpuid_check() duplicated. For functions call reverse_cpuid_check() twice indirectly (e.g. cpuid_entry= _get() calls both __feature_bit() and x86_feature_cpuid()), keep them as they are. Signed-off-by: Binbin Wu --- arch/x86/kvm/cpuid.c | 2 -- arch/x86/kvm/cpuid.h | 3 --- 2 files changed, 5 deletions(-) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index 8f8edeaf8177..f4089d7a7c4c 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -545,8 +545,6 @@ static __always_inline void __kvm_cpu_cap_mask(unsigned= int leaf) const struct cpuid_reg cpuid =3D x86_feature_cpuid(leaf * 32); struct kvm_cpuid_entry2 entry; =20 - reverse_cpuid_check(leaf); - cpuid_count(cpuid.function, cpuid.index, &entry.eax, &entry.ebx, &entry.ecx, &entry.edx); =20 diff --git a/arch/x86/kvm/cpuid.h b/arch/x86/kvm/cpuid.h index b1658c0de847..d781372a01e8 100644 --- a/arch/x86/kvm/cpuid.h +++ b/arch/x86/kvm/cpuid.h @@ -192,7 +192,6 @@ static __always_inline void kvm_cpu_cap_clear(unsigned = int x86_feature) { unsigned int x86_leaf =3D __feature_leaf(x86_feature); =20 - reverse_cpuid_check(x86_leaf); kvm_cpu_caps[x86_leaf] &=3D ~__feature_bit(x86_feature); } =20 @@ -200,7 +199,6 @@ static __always_inline void kvm_cpu_cap_set(unsigned in= t x86_feature) { unsigned int x86_leaf =3D __feature_leaf(x86_feature); =20 - reverse_cpuid_check(x86_leaf); kvm_cpu_caps[x86_leaf] |=3D __feature_bit(x86_feature); } =20 @@ -208,7 +206,6 @@ static __always_inline u32 kvm_cpu_cap_get(unsigned int= x86_feature) { unsigned int x86_leaf =3D __feature_leaf(x86_feature); =20 - reverse_cpuid_check(x86_leaf); return kvm_cpu_caps[x86_leaf] & __feature_bit(x86_feature); } =20 base-commit: e73ba25fdc241c06ab48a1f708a30305d6036e66 --=20 2.25.1