Skip to content
This repository was archived by the owner on Mar 24, 2022. It is now read-only.

Check extended CPU features only when necessary as querying flags fail on some AMD CPUs.#426

Merged
iximeow merged 1 commit intobytecodealliance:masterfrom
PLSysSec:extended_cpu_check
Feb 18, 2020
Merged

Check extended CPU features only when necessary as querying flags fail on some AMD CPUs.#426
iximeow merged 1 commit intobytecodealliance:masterfrom
PLSysSec:extended_cpu_check

Conversation

@shravanrn
Copy link
Copy Markdown
Contributor

Some AMD CPUs fail on querying CPUID extended flags. See https://bugzilla.mozilla.org/show_bug.cgi?id=1615786. Performing this check only when actually required, allows wasm modules that don't rely on extended features to be run.

…l on some AMD CPUs .

Some AMD CPUs fail on querying CPUID extended flags. See https://bugzilla.mozilla.org/show_bug.cgi?id=1615786. Performing this check only when actually required, allows wasm modules that don't rely on extended features to be run.
let info = cpuid.get_extended_feature_info().ok_or_else(|| {
Error::Unsupported("Unable to obtain host CPU extended feature info!".to_string())
})?;
if module_features.bmi1 || module_features.bmi2 {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
if module_features.bmi1 || module_features.bmi2 {
// Some AMD CPUs fail on querying CPUID extended flags. See https://bugzilla.mozilla.org/show_bug.cgi?id=1615786.
if module_features.bmi1 || module_features.bmi2 {

let info = cpuid.get_extended_function_info().ok_or_else(|| {
Error::Unsupported("Unable to obtain host CPU extended function info!".to_string())
})?;
if module_features.lzcnt {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
if module_features.lzcnt {
// Same situation - see above
if module_features.lzcnt {

@pchickey
Copy link
Copy Markdown
Contributor

I messed up the review thing - looks good, if you can approve adding those suggested comments we'll get it merged.

Copy link
Copy Markdown
Contributor

@iximeow iximeow left a comment

Choose a reason for hiding this comment

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

Looks good, this isn't actually an AMD CPU-specific issue - I think we'd hit this on processors older than ~2012 generally. For reference, the model number in the associated crash is family 16 model 10 stepping 0 which corresponds to a Phenom II X6, which shipped in 2010.

get_extended_feature_info checks CPUID leaf eax=7; I can't tell when exactly it was introduced, 2012 is an estimate. I'd originally thought it checked eax=1 (present on all processors since the 486). That's probably what is None on the reporter's machine, and causes an error. By any chance, do you get the error out of Lucet anywhere? I'd like to confirm that. Even so, I wouldn't think that's a blocking issue here since the change here has us match how feature detection is done in cranelift-native.

@iximeow
Copy link
Copy Markdown
Contributor

iximeow commented Feb 17, 2020

pt2: on account of not being AMD-specific, I'm going to squash merge and rewrite the commit message to reference the bug report and having made a stronger assumption than we should about CPUID leaf availability.

@iximeow iximeow merged commit 25eff66 into bytecodealliance:master Feb 18, 2020
@shravanrn
Copy link
Copy Markdown
Contributor Author

Ah sorry, was away all day so just saw the messages now. That makes sense. Thanks @pchickey and @iximeow!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants