VirtualBox

Changeset 49784 in vbox for trunk/src/VBox/HostDrivers


Ignore:
Timestamp:
Dec 5, 2013 10:30:06 AM (11 years ago)
Author:
vboxsync
Message:

HostDrivers: Fix SUPR0QueryVTCaps() to be preemption safe.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/Support/SUPDrv.c

    r49728 r49784  
    33983398SUPR0DECL(int) SUPR0QueryVTCaps(PSUPDRVSESSION pSession, uint32_t *pfCaps)
    33993399{
     3400    int rc = VERR_UNSUPPORTED_CPU;
     3401    RTTHREADPREEMPTSTATE PreemptState = RTTHREADPREEMPTSTATE_INITIALIZER;
     3402
    34003403    /*
    34013404     * Input validation.
     
    34053408
    34063409    *pfCaps = 0;
    3407 
    3408     /** @todo r=ramshankar: Although we're only reading CPUIDs/MSRs here which
    3409      *        should be identical on all CPUs on the system, it's probably
    3410      *        cleaner to prevent migration nonetheless? */
     3410    /* We may modify MSRs and re-read them, disable preemption so we make sure we don't migrate CPUs. */
     3411    RTThreadPreemptDisable(&PreemptState);
    34113412    if (ASMHasCpuId())
    34123413    {
     
    34853486                            *pfCaps |= SUPVTCAPS_NESTED_PAGING;
    34863487                    }
    3487                     return VINF_SUCCESS;
    34883488                }
    3489                 return rc;
    34903489            }
    3491             return VERR_VMX_NO_VMX;
    3492         }
    3493 
    3494         if (   ASMIsAmdCpuEx(uVendorEBX, uVendorECX, uVendorEDX)
    3495             && ASMIsValidStdRange(uMaxId))
     3490            else
     3491                rc = VERR_VMX_NO_VMX;
     3492        }
     3493        else if (   ASMIsAmdCpuEx(uVendorEBX, uVendorECX, uVendorEDX)
     3494                 && ASMIsValidStdRange(uMaxId))
    34963495        {
    34973496            uint32_t fExtFeaturesEcx, uExtMaxId;
     
    35173516                        *pfCaps |= SUPVTCAPS_NESTED_PAGING;
    35183517
    3519                     return VINF_SUCCESS;
     3518                    rc = VINF_SUCCESS;
    35203519                }
    3521                 return VERR_SVM_DISABLED;
     3520                else
     3521                    rc = VERR_SVM_DISABLED;
    35223522            }
    3523             return VERR_SVM_NO_SVM;
    3524         }
    3525     }
    3526 
    3527     return VERR_UNSUPPORTED_CPU;
     3523            else
     3524                rc = VERR_SVM_NO_SVM;
     3525        }
     3526    }
     3527
     3528    RTThreadPreemptRestore(&PreemptState);
     3529    return rc;
    35283530}
    35293531
Note: See TracChangeset for help on using the changeset viewer.

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