Skip to content

CPUID Fn8000_0021_EAX reads as 0 in the WSL2 guest on Zen 5, kernel falls back to retpolines #41827

Open

Description

@Hekzory

Windows Version

Microsoft Windows [Version 10.0.26300.9550] (Hyper-V host build 10.0.26100.9444)

WSL Version

3.0.2.0

Are you using WSL 1 or WSL 2?

WSL 2

Kernel Version

6.18.40.1-microsoft-standard-WSL2

Distro Version

Arch Linux (rolling)

Other Software

CPU: AMD Ryzen 9 9900X (Zen 5, family 0x1a model 0x44)

Repro Steps

Inside the distro:

#include <stdio.h>
#include <cpuid.h>
int main(void) {
    unsigned a, b, c, d;
    __cpuid(0x80000000, a, b, c, d);
    printf("max ext leaf 0x%08x\n", a);
    __cpuid_count(0x80000021, 0, a, b, c, d);
    printf("Fn8000_0021: EAX=%08x EBX=%08x ECX=%08x EDX=%08x\n", a, b, c, d);
    return 0;
}

gcc -o cpuid cpuid.c && ./cpuid

Expected Behavior

Fn8000_0021_EAX carries the extended feature bits the CPU has. Zen 4 and Zen 5 report AutomaticIBRS (bit 8) there, and the IBPB/SRSO bits the kernel looks for. The guest kernel should then pick AutoIBRS for Spectre v2 and stop complaining about SRSO microcode.

Actual Behavior

The leaf exists, but EAX comes back empty:

max ext leaf 0x80000021
Fn8000_0021: EAX=00000000 EBX=00000000 ECX=00000006 EDX=00000000

ECX still has a value, so the leaf is passed through. Only EAX is cleared. As a result the guest picks retpolines and prints the SRSO microcode warning on every boot:

Speculative Return Stack Overflow: IBPB-extending microcode not applied!
Spectre V2 : Mitigation: Retpolines
Speculative Return Stack Overflow: Vulnerable: No microcode
$ cat /sys/devices/system/cpu/vulnerabilities/spectre_v2
Mitigation: Retpolines; IBPB: conditional; IBRS_FW; STIBP: always-on; RSB filling; PBRSB-eIBRS: Not affected; BHI: Not affected

autoibrs, ibpb_brtype, sbpb and the other flags from this leaf are missing from /proc/cpuinfo.

I boot with spec_rstack_overflow=off in kernelCommandLine. Without it the kernel also turns on Safe RET on top of this, so the "Vulnerable: No microcode" line is with that override.

For comparison, reading the same leaf on the Windows side with PowerShell 7 ([System.Runtime.Intrinsics.X86.X86Base]::CpuId(0x80000021, 0)) gives EAX=0x00000001. So the root partition doesn't get much of the leaf either, but the guest loses even that one bit.

This may be part of what #14526 is seeing on AMD. That report shows the same "Retpolines" and "no microcode" strings and a large syscall overhead with mitigations on.

Diagnostic Logs

collect-wsl-logs.ps1 output is in the first comment.

Activity

  1. github-actions commented on Oct 7, 2026

    @github-actions
    Contributor

    Logs are required for review from WSL team

    If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'.
    Otherwise, please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.

    How to collect WSL logs

    Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:

    Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
    Set-ExecutionPolicy Bypass -Scope Process -Force
    .\collect-wsl-logs.ps1
    

    The script will output the path of the log file once done.

    If this is a networking issue, please use .\collect-wsl-logs.ps1 -LogProfile networking instead, following the instructions in Collect WSL logs for networking issues

    Once completed please upload the output files to this GitHub issue.

    See Collect WSL logs (recommended method).

    If you choose to email these logs instead of attaching them to the bug, please send them to wsl-gh-logs@microsoft.com with the GitHub issue number in the subject, and include a link to your GitHub issue comment in the message body, and reply with '/emailed-logs'.

  2. Hekzory commented on Oct 7, 2026

    @Hekzory
    ContributorAuthor
  3. github-actions commented on Oct 7, 2026

    @github-actions
    Contributor
    Diagnostic information
    .wslconfig found
    	Custom kernel command line found: 'spec_rstack_overflow=off swiotlb=262144,force'
    Detected appx version: 3.0.2.0
    
  4. tonymet commented on Nov 23, 2026

    @tonymet

    Oleg Tsvetkov (@Hekzory) thank you for opening this. I'm still concerned about the odd performance with kernel mitigations = off. I appreciate having more detail like this, since I'm less familiar with guest expectations for instruction sets

  5. tonymet commented on Nov 23, 2026

    @tonymet

    my results of your test case:

    uname -a
    Linux xxx 6.18.58.1-microsoft-standard-WSL2 #1 SMP PREEMPT_DYNAMIC Tue Oct 27 00:24:11 UTC 2026 x86_64 GNU/Linux
    
    cat /proc/cpuinfo|grep model |head -n 2
    model           : 68
    model name      : AMD Ryzen 7 7735HS with Radeon Graphics
    
     ./cpuid
    max ext leaf 0x80000021
    Fn8000_0021: EAX=00000000 EBX=00000000 ECX=00000080 EDX=00000000
    
  6. tonymet commented on Nov 23, 2026

    @tonymet

    I confirmed OP's results with testing on Ryzen 7735HS . spec_rstack_overflow=off alone improves pipe throughput by ~17% . mitigations=off is nearly identical.

    Variant (kernelCommandLine) Throughput (ops/sec) Latency (usecs/op) Total Time (sec) Throughput Delta
    spec_rstack_overflow=on (default mitigations) 38,793 25.78 2.577 Baseline (0.0%)
    spec_rstack_overflow=off 45,357 22.05 2.204 +16.92%
    mitigations=off 45,072 22.19 2.218 +16.19%

    full results:

    https://gist.github.com/tonymet/cb281a9da7746949189c3e65434a10ec#file-test-results-txt

  7. tonymet commented on Nov 23, 2026

    @tonymet

    I ran a broader register test of the ryzen7735 to see what other features were masked. These 4 were revealed as masked (same results as above)

    Full Test results: https://gist.github.com/tonymet/cb281a9da7746949189c3e65434a10ec#file-ryzen_7735hs_full_results-txt

    Windows OS Build: 26320.10022
    
    =========================================================================================
    CPU Vendor : AuthenticAMD | Family: 0x19 | Model: 0x44 | Hypervisor Bit: 1 | Max Ext: 0x80000021
    Target CPU : AMD Ryzen 7 7735HS (Zen 3+ / Rembrandt-R, Family 0x19, Model 0x44)
    =========================================================================================
    
    Feature         | Leaf       | Reg  | Actual | Expected | Status | Notes
    -----------------------------------------------------------------------------------------
    [truncated]
    NO_NESTED_DB    | 0x80000021 | EAX  | 0      | 1        | FAIL   | No nested data breakpoints
    LFENCE_RDTSC    | 0x80000021 | EAX  | 0      | 1        | FAIL   | LFENCE is always dispatch-serializing
    SBPB            | 0x80000021 | EAX  | 0      | 1        | FAIL   | Selective Branch Prediction Barrier (Zen 3+ ucode)
    IBPB_BRTYPE     | 0x80000021 | EAX  | 0      | 1        | FAIL   | IBPB flushes branch type predictions (SRSO fix)
    -----------------------------------------------------------------------------------------
    Summary: 16 / 20 checks matched bare-metal Ryzen 7 7735HS expectations.
    Raw CPUID Fn8000_0021_EAX = 0x00000000
    NOTE: Hypervisor detected and Fn8000_0021_EAX == 0 (Hyper-V CPUID masking active).
          Failures on NO_NESTED_DB, LFENCE_RDTSC, SBPB, and IBPB_BRTYPE are expected under WSL2.
    
  8. Hekzory commented on Nov 23, 2026

    @Hekzory
    ContributorAuthor

    Thanks for testing this on the 7735HS. I reran the CPUID test on the same Ryzen 9 9900X with Windows 10.0.26300.10075, WSL 3.0.5.0, and kernel 6.18.58.1-microsoft-standard-WSL2.

    CPUID.80000021H:EAX is now 0x00000020 on all 24 WSL vCPUs, up from 0x00000000 in the original report. The Windows root partition returns 0x00000021. AUTOIBRS and IBPB_BRTYPE are clear in both. The guest still reports Mitigation: Retpolines for Spectre v2 and Vulnerable: No microcode for SRSO with my existing spec_rstack_overflow=off setting.

    Is this the expected CPUID exposure for Zen 5 under Hyper-V, and is there a plan to expose AUTOIBRS and the relevant SRSO capabilities to WSL2 guests?

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions