Skip to content

KVM: x86: Fix unpermitted XTILE CPUID reporting

Sean Christopherson kvm lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v4 Latest6 patches 3 repliesIn review

Changes in v4 from the cover letter

- Apply the massaging _only to the XTILE case.
- Add a build-time assertion to trigger a failure if a new dynamic XFeature comes along without updating kvm_get_filtered_xcr0().

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6KVM: x86: Add a helper to handle filtering of unpermitted XCR0 featuresarch/x86/kvm/cpuid.c arch/x86/kvm/x86.c arch/x86/kvm/x86.h+15 -40 replies
2/6KVM: x86: Filter out XTILE_CFG if XTILE_DATA isn't permittedarch/x86/kvm/x86.h+17 -10 replies
3/6KVM: selftests: Move XGETBV and XSETBV helpers to common codetools/testing/selftests/kvm/include/x86_64/processor.h tools/testing/selftests/kvm/x86_64/amx_test.c+21 -210 replies
4/6KVM: selftests: Rework dynamic XFeature helper to take mask, not bittools/testing/selftests/kvm/include/x86_64/processor.h tools/testing/selftests/kvm/lib/x86_64/processor.c tools/testing/selftests/kvm/x86_64/amx_test.c+14 -110 replies
5/6KVM: selftests: Add all known XFEATURE masks to common codetools/testing/selftests/kvm/include/x86_64/processor.h tools/testing/selftests/kvm/x86_64/amx_test.c+33 -300 replies
6/6KVM: selftests: Add test to verify KVM's supported XCR0tools/testing/selftests/kvm/Makefile tools/testing/selftests/kvm/include/x86_64/processor.h tools/testing/selftests/kvm/x86_64/xcr0_cpuid_test.c+153 -00 replies

Reviews trailers per patch

2 of 6 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchMingwei ZhangJim MattsonAaron Lewis
SeriesR-b T-b
1/6R-b
2/6
3/6R-b R-b
4/6
5/6
6/6

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v4 thread

Cover letter [PATCH v4 0/6] KVM: x86: Fix unpermitted XTILE CPUID reporting

This is v4 of Aaron's "Clean up the supported xfeatures" series.

Fix a bug where KVM treats/reports XTILE_CFG as supported without XTILE_DATA being supported if userspace queries the supported CPUID but doesn't request access to AMX, a.k.a. XTILE_DATA. If userspace reflects that CPUID info back into KVM, the resulting VM may use it verbatim and attempt to shove bad data into XCR0: XTILE_CFG and XTILE_DATA must be set/cleared as a pair in XCR0, despite being enumerated separately.

This is effectively compile-tested only on my end.

v4:
- Apply the massaging _only to the XTILE case.
- Add a build-time assertion to trigger a failure if a new dynamic XFeature comes along without updating kvm_get_filtered_xcr0().

v3: https://lore.kernel.org/all/[email protected]

Aaron Lewis (4):
KVM: x86: Add a helper to handle filtering of unpermitted XCR0
features
KVM: selftests: Move XGETBV and XSETBV helpers to common code
KVM: selftests: Add all known XFEATURE masks to common code
KVM: selftests: Add test to verify KVM's supported XCR0

Sean Christopherson (2):
KVM: x86: Filter out XTILE_CFG if XTILE_DATA isn't permitted
KVM: selftests: Rework dynamic XFeature helper to take mask, not bit

 arch/x86/kvm/cpuid.c                          |   2 +-
 arch/x86/kvm/x86.c                            |   4 +-
 arch/x86/kvm/x86.h                            |  29 ++++
 tools/testing/selftests/kvm/Makefile          |   1 +
 .../selftests/kvm/include/x86_64/processor.h  |  69 +++++++--
 .../selftests/kvm/lib/x86_64/processor.c      |  17 ++-
 tools/testing/selftests/kvm/x86_64/amx_test.c |  62 +++-----
 .../selftests/kvm/x86_64/xcr0_cpuid_test.c    | 132 ++++++++++++++++++
 8 files changed, 251 insertions(+), 65 deletions(-)
 create mode 100644 tools/testing/selftests/kvm/x86_64/xcr0_cpuid_test.c

base-commit: 27d6845d258b67f4eb3debe062b7dacc67e0c393

Signature · 1 line
2.40.0.348.gf938b09366-goog