From: Ricardo Koller <ricarkol@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>,
"H. Peter Anvin" <hpa@zytor.com>,
Sean Christopherson <seanjc@google.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Wanpeng Li <wanpengli@tencent.com>,
Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
Nathan Chancellor <nathan@kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>,
linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com,
Ricardo Koller <ricarkol@google.com>
Subject: [PATCH v2 0/6] KVM: x86: Use kernel x86 cpuid utilities in KVM selftests
Date: Wed, 28 Apr 2021 12:37:50 -0700 [thread overview]
Message-ID: <20210428193756.2110517-1-ricarkol@google.com> (raw)
The kernel has a set of utilities and definitions to deal with x86 cpu
features. The x86 KVM selftests don't use them, and instead have
evolved to use differing and ad-hoc methods for checking features. The
advantage of the kernel feature definitions is that they use a format
that embeds the info needed to extract them from cpuid (function, index,
and register to use).
Patches 1 and 2 add a script for checking that kernel headers don't
drift from their original copies. Patches 3 and 4 massage the related
cpuid header files in the kernel side, then copy them into tools/ so
they can be included by selftests. The last 2 patches replace the tests
checking for cpu features to use the definitions and utilities
introduced from the kernel.
Tested the arch/x86 patches by building these combinations:
ARCH=i386 allmodconfig
ARCH=i386 allyesconfig
ARCH=x86_64 allyesconfig
ARCH=x86_64 allmodconfig
ARCH=um alldefconfig
ARCH=i386 alldefconfig
and the selftest changes on both x86 and arm64.
Thanks,
Ricardo
v2:
- Add script to check for kernel headers drift in tools
- Sync header that is currently failing the check
- Move header copies under tools/testing/selftests/kvm/include/x86
instead of tools/arch/x86/include
v1: https://lore.kernel.org/kvm/20210422005626.564163-1-ricarkol@google.com
Ricardo Koller (6):
KVM: selftests: Add kernel headers sync check
tools headers x86: Update bitsperlong.h in tools
x86/cpu: Expose CPUID regs, leaf and index definitions to tools
tools headers x86: Copy cpuid helpers from the kernel
KVM: selftests: Introduce utilities for checking x86 features
KVM: selftests: Use kernel x86 cpuid features format
arch/x86/events/intel/pt.c | 1 +
arch/x86/include/asm/cpufeature.h | 23 +-
arch/x86/include/asm/processor.h | 11 -
arch/x86/kernel/cpu/scattered.c | 2 +-
arch/x86/kernel/cpuid.c | 2 +-
tools/arch/x86/include/asm/cpufeatures.h | 3 +
tools/include/uapi/asm-generic/bitsperlong.h | 1 +
tools/testing/selftests/kvm/Makefile | 2 +
tools/testing/selftests/kvm/check-headers.sh | 64 +++++
.../kvm/include/x86_64/asm/cpufeature.h | 257 ++++++++++++++++++
.../selftests/kvm/include/x86_64/cpuid.h | 61 +++++
.../selftests/kvm/include/x86_64/processor.h | 16 --
.../kvm/include/x86_64/reverse_cpuid.h | 185 +++++++++++++
.../selftests/kvm/include/x86_64/svm_util.h | 11 +-
tools/testing/selftests/kvm/lib/x86_64/svm.c | 6 +-
tools/testing/selftests/kvm/lib/x86_64/vmx.c | 5 +-
tools/testing/selftests/kvm/steal_time.c | 5 +-
.../kvm/x86_64/cr4_cpuid_sync_test.c | 23 +-
.../selftests/kvm/x86_64/set_sregs_test.c | 25 +-
.../selftests/kvm/x86_64/vmx_pmu_msrs_test.c | 8 +-
.../kvm/x86_64/vmx_set_nested_state_test.c | 5 +-
.../selftests/kvm/x86_64/xss_msr_test.c | 10 +-
22 files changed, 630 insertions(+), 96 deletions(-)
create mode 100755 tools/testing/selftests/kvm/check-headers.sh
create mode 100644 tools/testing/selftests/kvm/include/x86_64/asm/cpufeature.h
create mode 100644 tools/testing/selftests/kvm/include/x86_64/cpuid.h
create mode 100644 tools/testing/selftests/kvm/include/x86_64/reverse_cpuid.h
--
2.31.1.498.g6c1eba8ee3d-goog
next reply other threads:[~2021-04-28 19:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-28 19:37 Ricardo Koller [this message]
2021-04-28 19:37 ` [PATCH v2 1/6] KVM: selftests: Add kernel headers sync check Ricardo Koller
2021-04-28 19:37 ` [PATCH v2 2/6] tools headers x86: Update bitsperlong.h in tools Ricardo Koller
2021-04-28 19:37 ` [PATCH v2 3/6] x86/cpu: Expose CPUID regs, leaf and index definitions to tools Ricardo Koller
2021-04-28 19:37 ` [PATCH v2 4/6] tools headers x86: Copy cpuid helpers from the kernel Ricardo Koller
2021-04-28 19:37 ` [PATCH v2 5/6] KVM: selftests: Introduce utilities for checking x86 features Ricardo Koller
2021-04-28 19:37 ` [PATCH v2 6/6] KVM: selftests: Use kernel x86 cpuid features format Ricardo Koller
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=20210428193756.2110517-1-ricarkol@google.com \
--to=ricarkol@google.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=clang-built-linux@googlegroups.com \
--cc=hpa@zytor.com \
--cc=jmattson@google.com \
--cc=jolsa@redhat.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=seanjc@google.com \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.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
all inboxes | Powered by JetHome®