From: Jim Mattson <jmattson@google.com>
To: kvm@vger.kernel.org, pbonzini@redhat.com,
like.xu.linux@gmail.com, daviddunn@google.com,
cloudliang@tencent.com
Cc: Jim Mattson <jmattson@google.com>
Subject: [PATCH v2 2/6] selftests: kvm/x86: Parameterize the CPUID vendor string check
Date: Thu, 13 Jan 2022 17:21:05 -0800 [thread overview]
Message-ID: <20220114012109.153448-3-jmattson@google.com> (raw)
In-Reply-To: <20220114012109.153448-1-jmattson@google.com>
Refactor is_intel_cpu() to make it easier to reuse the bulk of the
code for other vendors in the future.
Signed-off-by: Jim Mattson <jmattson@google.com>
---
tools/testing/selftests/kvm/lib/x86_64/processor.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/kvm/lib/x86_64/processor.c b/tools/testing/selftests/kvm/lib/x86_64/processor.c
index eef7b34756d5..355a3f6f1970 100644
--- a/tools/testing/selftests/kvm/lib/x86_64/processor.c
+++ b/tools/testing/selftests/kvm/lib/x86_64/processor.c
@@ -1198,10 +1198,10 @@ void vcpu_load_state(struct kvm_vm *vm, uint32_t vcpuid, struct kvm_x86_state *s
}
}
-bool is_intel_cpu(void)
+static bool cpu_vendor_string_is(const char *vendor)
{
+ const uint32_t *chunk = (const uint32_t *)vendor;
int eax, ebx, ecx, edx;
- const uint32_t *chunk;
const int leaf = 0;
__asm__ __volatile__(
@@ -1210,10 +1210,14 @@ bool is_intel_cpu(void)
"=c"(ecx), "=d"(edx)
: /* input */ "0"(leaf), "2"(0));
- chunk = (const uint32_t *)("GenuineIntel");
return (ebx == chunk[0] && edx == chunk[1] && ecx == chunk[2]);
}
+bool is_intel_cpu(void)
+{
+ return cpu_vendor_string_is("GenuineIntel");
+}
+
uint32_t kvm_get_cpuid_max_basic(void)
{
return kvm_get_supported_cpuid_entry(0)->eax;
--
2.34.1.703.g22d0c6ccf7-goog
next prev parent reply other threads:[~2022-01-14 1:21 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-14 1:21 [PATCH v2 0/6] KVM: x86/pmu: Use binary search to check filtered events Jim Mattson
2022-01-14 1:21 ` [PATCH v2 1/6] " Jim Mattson
2022-01-14 1:21 ` Jim Mattson [this message]
2022-01-14 1:21 ` [PATCH v2 3/6] selftests: kvm/x86: Introduce is_amd_cpu() Jim Mattson
2022-01-14 1:21 ` [PATCH v2 4/6] selftests: kvm/x86: Export x86_family() for use outside of processor.c Jim Mattson
2022-01-14 1:21 ` [PATCH v2 5/6] selftests: kvm/x86: Introduce x86_model() Jim Mattson
2022-01-14 1:21 ` [PATCH v2 6/6] selftests: kvm/x86: Add test for KVM_SET_PMU_EVENT_FILTER Jim Mattson
2022-01-14 19:15 ` David Dunn
2022-01-15 5:01 ` Jim Mattson
2022-01-18 9:15 ` [PATCH v2 0/6] KVM: x86/pmu: Use binary search to check filtered events Paolo Bonzini
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=20220114012109.153448-3-jmattson@google.com \
--to=jmattson@google.com \
--cc=cloudliang@tencent.com \
--cc=daviddunn@google.com \
--cc=kvm@vger.kernel.org \
--cc=like.xu.linux@gmail.com \
--cc=pbonzini@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.