From: Binbin Wu <binbin.wu@linux.intel.com>
To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: seanjc@google.com, pbonzini@redhat.com,
Binbin Wu <binbin.wu@linux.intel.com>
Subject: [PATCH] KVM: x86: Remove duplicated calls of reverse_cpuid_check()
Date: Tue, 21 Feb 2023 11:21:56 +0800 [thread overview]
Message-ID: <20230221032156.791-1-binbin.wu@linux.intel.com> (raw)
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 <binbin.wu@linux.intel.com>
---
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 = x86_feature_cpuid(leaf * 32);
struct kvm_cpuid_entry2 entry;
- reverse_cpuid_check(leaf);
-
cpuid_count(cpuid.function, cpuid.index,
&entry.eax, &entry.ebx, &entry.ecx, &entry.edx);
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 = __feature_leaf(x86_feature);
- reverse_cpuid_check(x86_leaf);
kvm_cpu_caps[x86_leaf] &= ~__feature_bit(x86_feature);
}
@@ -200,7 +199,6 @@ static __always_inline void kvm_cpu_cap_set(unsigned int x86_feature)
{
unsigned int x86_leaf = __feature_leaf(x86_feature);
- reverse_cpuid_check(x86_leaf);
kvm_cpu_caps[x86_leaf] |= __feature_bit(x86_feature);
}
@@ -208,7 +206,6 @@ static __always_inline u32 kvm_cpu_cap_get(unsigned int x86_feature)
{
unsigned int x86_leaf = __feature_leaf(x86_feature);
- reverse_cpuid_check(x86_leaf);
return kvm_cpu_caps[x86_leaf] & __feature_bit(x86_feature);
}
base-commit: e73ba25fdc241c06ab48a1f708a30305d6036e66
--
2.25.1
next reply other threads:[~2023-02-21 3:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-21 3:21 Binbin Wu [this message]
2023-02-21 15:54 ` [PATCH] KVM: x86: Remove duplicated calls of reverse_cpuid_check() Sean Christopherson
2023-02-22 2:38 ` Binbin Wu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230221032156.791-1-binbin.wu@linux.intel.com \
--to=binbin.wu@linux.intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox