Project

General

Profile

Actions

Bug #12746

closed

x86_emulate_cpuid() should clear upper 32 bits

Added by Patrick Mooney about 2 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Category:
kernel
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
bhyve
Gerrit CR:

Description

When investigating a gcc9 gripe in the bhyve codebase, I noticed something that looked amiss:

1516                 handled = x86_emulate_cpuid(svm_sc->vm, vcpu,                    
1517                     (uint32_t *)&state->rax,                                     
1518                     (uint32_t *)&ctx->sctx_rbx,                                  
1519                     (uint32_t *)&ctx->sctx_rcx,                                  
1520                     (uint32_t *)&ctx->sctx_rdx); 

While gcc9 was complaining about the alignment on the rax-rdx stores, it looked like the upper bits in those registers wouldn't be properly cleared. Indeed the SDM notes that the upper 32-bits of those registers is zeroed by CPUID calls. A quick test under bhyve showed that garbage left in the upper bits remained there after a CPUID call.

While no guest has complained about this to date, bhyve should probably do the right thing and clear those bits. (And in the process, address gcc9's gripe.)

SmartOS issue: OS-8168
FreeBSD upstreaming CR: D24727


Related issues

Related to illumos gate - Bug #12749: gcc10 complains about vmcb_state struct packingClosedPatrick Mooney

Actions
Actions

Also available in: Atom PDF