VirtualBox

Changeset 85419 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jul 22, 2020 4:55:04 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
139458
Message:

include/iprt/x86.h,VMM/CPUMR3CpuId: Work around a bug in some Linux kernel versions causing a NULL pointer exception when trying to configure SSBD in a single vCPU VM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR3/CPUMR3CpuId.cpp

    r82968 r85419  
    46224622        if (fEnable)
    46234623            CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_SPEC_CTRL);
     4624        else
     4625        {
     4626            /*
     4627             * Set the "SSBD-not-needed" flag to work around a bug in some Linux kernels when the VIRT_SPEC_CTL
     4628             * feature is not exposed on AMD CPUs and there is only 1 vCPU configured.
     4629             * This was observed with kernel "4.15.0-29-generic #31~16.04.1-Ubuntu" but more versions are likely affected.
     4630             *
     4631             * The kernel doesn't initialize a lock and causes a NULL pointer exception later on when configuring SSBD:
     4632             *    EIP: _raw_spin_lock+0x14/0x30
     4633             *    EFLAGS: 00010046 CPU: 0
     4634             *    EAX: 00000000 EBX: 00000001 ECX: 00000004 EDX: 00000000
     4635             *    ESI: 00000000 EDI: 00000000 EBP: ee023f1c ESP: ee023f18
     4636             *    DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
     4637             *    CR0: 80050033 CR2: 00000004 CR3: 3671c180 CR4: 000006f0
     4638             *    Call Trace:
     4639             *     speculative_store_bypass_update+0x8e/0x180
     4640             *     ssb_prctl_set+0xc0/0xe0
     4641             *     arch_seccomp_spec_mitigate+0x1d/0x20
     4642             *     do_seccomp+0x3cb/0x610
     4643             *     SyS_seccomp+0x16/0x20
     4644             *     do_fast_syscall_32+0x7f/0x1d0
     4645             *     entry_SYSENTER_32+0x4e/0x7c
     4646             *
     4647             * The lock would've been initialized in process.c:speculative_store_bypass_ht_init() called from two places in smpboot.c.
     4648             * First when a secondary CPU is started and second in native_smp_prepare_cpus() which is not called in a single vCPU environment.
     4649             *
     4650             * As spectre control features are completely disabled anyway when we arrived here there is no harm done in informing the
     4651             * guest to not even try.
     4652             */
     4653            if (   pVM->cpum.s.GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_AMD
     4654                || pVM->cpum.s.GuestFeatures.enmCpuVendor == CPUMCPUVENDOR_HYGON)
     4655            {
     4656                PCPUMCPUIDLEAF pLeaf = cpumR3CpuIdGetExactLeaf(&pVM->cpum.s, UINT32_C(0x80000008), 0);
     4657                if (pLeaf)
     4658                {
     4659                    pLeaf->uEbx |= X86_CPUID_AMD_EFEID_EBX_NO_SSBD_REQUIRED;
     4660                    LogRel(("CPUM: Set SSBD not required flag for AMD to work around some buggy Linux kernels!\n"));
     4661                }
     4662            }
     4663        }
    46244664
    46254665        return VINF_SUCCESS;
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette