kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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 v3 5/6] selftests: kvm/x86: Introduce x86_model()
Date: Fri, 14 Jan 2022 21:24:30 -0800	[thread overview]
Message-ID: <20220115052431.447232-6-jmattson@google.com> (raw)
In-Reply-To: <20220115052431.447232-1-jmattson@google.com>

Extract the x86 model number from CPUID.01H:EAX.

Signed-off-by: Jim Mattson <jmattson@google.com>
---
 tools/testing/selftests/kvm/include/x86_64/processor.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tools/testing/selftests/kvm/include/x86_64/processor.h b/tools/testing/selftests/kvm/include/x86_64/processor.h
index c5306e29edd4..b723163ca9ba 100644
--- a/tools/testing/selftests/kvm/include/x86_64/processor.h
+++ b/tools/testing/selftests/kvm/include/x86_64/processor.h
@@ -361,6 +361,11 @@ static inline unsigned int x86_family(unsigned int eax)
         return x86;
 }
 
+static inline unsigned int x86_model(unsigned int eax)
+{
+	return ((eax >> 12) & 0xf0) | ((eax >> 4) & 0x0f);
+}
+
 struct kvm_x86_state;
 struct kvm_x86_state *vcpu_save_state(struct kvm_vm *vm, uint32_t vcpuid);
 void vcpu_load_state(struct kvm_vm *vm, uint32_t vcpuid,
-- 
2.34.1.703.g22d0c6ccf7-goog


  parent reply	other threads:[~2022-01-15  5:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-15  5:24 [PATCH v3 0/6] KVM: x86/pmu: Use binary search to check filtered events Jim Mattson
2022-01-15  5:24 ` [PATCH v3 1/6] " Jim Mattson
2022-01-15  5:24 ` [PATCH v3 2/6] selftests: kvm/x86: Parameterize the CPUID vendor string check Jim Mattson
2022-01-15  5:24 ` [PATCH v3 3/6] selftests: kvm/x86: Introduce is_amd_cpu() Jim Mattson
2022-01-15  5:24 ` [PATCH v3 4/6] selftests: kvm/x86: Export x86_family() for use outside of processor.c Jim Mattson
2022-01-15  5:24 ` Jim Mattson [this message]
2022-01-15  5:24 ` [PATCH v3 6/6] selftests: kvm/x86: Add test for KVM_SET_PMU_EVENT_FILTER Jim Mattson

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=20220115052431.447232-6-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).