Skip to content

[Deepin-Kernel-SIG] [linux 6.18-y] [Fromlist] KVM: x86: Advertise AVX512 Bit Matrix Multiply (BMM) to userspace#1620

Merged
opsiff merged 1 commit intodeepin-community:linux-6.18.yfrom
Avenger-285714:AVX512BMM-6.18
Apr 14, 2026
Merged

[Deepin-Kernel-SIG] [linux 6.18-y] [Fromlist] KVM: x86: Advertise AVX512 Bit Matrix Multiply (BMM) to userspace#1620
opsiff merged 1 commit intodeepin-community:linux-6.18.yfrom
Avenger-285714:AVX512BMM-6.18

Conversation

@Avenger-285714
Copy link
Copy Markdown
Member

@Avenger-285714 Avenger-285714 commented Apr 13, 2026

Advertise AVX512 Bit Matrix Multiply (BMM) and Bit Reversal instructions to userspace via CPUID leaf 0x80000021_EAX[23]. This feature enables bit matrix multiply operations and bit reversal.

While at it, reorder PREFETCHI to match the bit position order in CPUID leaf 0x80000021_EAX for better organization.

Link: kvm-x86/linux@de0bfdc7137d

Summary by Sourcery

Advertise the AVX512 Bit Matrix Multiply capability to KVM userspace via CPUID while keeping CPUID feature bit ordering aligned with the architectural specification.

New Features:

  • Expose AVX512 Bit Matrix Multiply instructions to userspace through a new CPUID feature bit.

Enhancements:

  • Reorder the PREFETCHI CPUID feature bit to match the documented bit position layout in leaf 0x80000021_EAX.

Advertise AVX512 Bit Matrix Multiply (BMM) and Bit Reversal instructions to
userspace via CPUID leaf 0x80000021_EAX[23]. This feature enables bit
matrix multiply operations and bit reversal.

While at it, reorder PREFETCHI to match the bit position order in CPUID
leaf 0x80000021_EAX for better organization.

Signed-off-by: Nikunj A Dadhania <nikunj@amd.com>
Link: kvm-x86/linux@de0bfdc7137d
Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Apr 13, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR exposes the new AVX512 Bit Matrix Multiply (BMM) feature to KVM userspace via CPUID and keeps the PREFETCHI bit aligned with the architectural CPUID bit ordering, by defining the new feature flag and wiring it into KVM’s synthetic CPUID capabilities list.

Class diagram for updated CPUID feature flags

classDiagram
    class Cpufeatures_Leaf20 {
        +int X86_FEATURE_GP_ON_USER_CPUID
        +int X86_FEATURE_PREFETCHI
        +int X86_FEATURE_AVX512_BMM
        +int X86_FEATURE_SBPB
        +int X86_FEATURE_IBPB_BRTYPE
        +int X86_FEATURE_SRSO_NO
    }

    class KVM_CpuCaps {
        +void kvm_set_cpu_caps()
    }

    KVM_CpuCaps --> Cpufeatures_Leaf20 : uses
Loading

File-Level Changes

Change Details Files
Wire AVX512 Bit Matrix Multiply into x86 feature flags and KVM CPUID capabilities, and reorder PREFETCHI to match CPUID bit positions.
  • Add X86_FEATURE_AVX512_BMM at bit position 20*32+23 with an appropriate comment describing the AVX512 Bit Matrix Multiply instructions
  • Include AVX512_BMM in KVM’s synthetic CPU capabilities list so it is advertised to userspace via CPUID leaf 0x80000021_EAX[23]
  • Move PREFETCHI entry within the KVM CPU caps list to keep it ordered according to CPUID leaf 0x80000021_EAX bit positions
arch/x86/include/asm/cpufeatures.h
arch/x86/kvm/cpuid.c

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Advertises AMD CPUID 0x80000021.EAX[23] (AVX512 Bit Matrix Multiply / Bit Reversal per PR description) to KVM userspace and tidies the feature ordering to match CPUID bit positions.

Changes:

  • Add X86_FEATURE_AVX512_BMM for CPUID 0x80000021.EAX[23].
  • Expose AVX512_BMM in KVM’s supported CPUID for leaf 0x80000021.
  • Reorder PREFETCHI in KVM CPU cap initialization for better bit-order alignment.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
arch/x86/kvm/cpuid.c Adds AVX512_BMM to KVM’s advertised caps for CPUID 0x80000021.EAX and reorders PREFETCHI for readability/alignment.
arch/x86/include/asm/cpufeatures.h Introduces X86_FEATURE_AVX512_BMM at word 20, bit 23.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

#define X86_FEATURE_GP_ON_USER_CPUID (20*32+17) /* User CPUID faulting */

#define X86_FEATURE_PREFETCHI (20*32+20) /* Prefetch Data/Instruction to Cache Level */
#define X86_FEATURE_AVX512_BMM (20*32+23) /* AVX512 Bit Matrix Multiply instructions */
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

X86_FEATURE_AVX512_BMM is missing a quoted feature name (e.g. "avx512_bmm") at the start of the comment. mkcapflags.sh only emits entries for x86_cap_flags when the trailing /* ... */ begins with a quoted string; without it, the feature won't appear in /proc/cpuinfo flags and can’t be referenced by name via setcpuid=/clearcpuid=. Consider aligning with other ISA feature definitions (e.g. X86_FEATURE_AVX512_FP16 in this file) by adding the quoted name.

Suggested change
#define X86_FEATURE_AVX512_BMM (20*32+23) /* AVX512 Bit Matrix Multiply instructions */
#define X86_FEATURE_AVX512_BMM (20*32+23) /* "avx512_bmm" AVX512 Bit Matrix Multiply instructions */

Copilot uses AI. Check for mistakes.
#define X86_FEATURE_GP_ON_USER_CPUID (20*32+17) /* User CPUID faulting */

#define X86_FEATURE_PREFETCHI (20*32+20) /* Prefetch Data/Instruction to Cache Level */
#define X86_FEATURE_AVX512_BMM (20*32+23) /* AVX512 Bit Matrix Multiply instructions */
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR description says CPUID 0x80000021.EAX[23] advertises both AVX512 BMM and Bit Reversal instructions, but the new X86_FEATURE_AVX512_BMM comment mentions only bit matrix multiply. Please update either the PR description or the in-code comment so they match (and mention Bit Reversal too if it’s covered by the same CPUID bit).

Copilot uses AI. Check for mistakes.
@opsiff opsiff merged commit 47bfd14 into deepin-community:linux-6.18.y Apr 14, 2026
14 of 16 checks passed
@deepin-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: opsiff

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants