Skip to content
This repository has been archived by the owner on Jan 28, 2023. It is now read-only.

Fix incorrect VMX_ENTRY_CONTROLS loading. #225

Merged
merged 1 commit into from
Aug 16, 2019
Merged

Fix incorrect VMX_ENTRY_CONTROLS loading. #225

merged 1 commit into from
Aug 16, 2019

Conversation

coxuintel
Copy link
Contributor

There exists some issue when programming VMX_ENTRY_CONTROLS and GUEST_EFER:

  • ENTRY_CONTROL_LONG_MODE_GUEST has no chance to clear.
  • vmwrite_efer() called by vmwrite_cr() will check vmx field before
    vmx field gets updated, and itself will also program VMX_ENTRY_CONTROLS,
    which may cause incorrect VMX_ENTRY_CONTROLS programmed.
  • vmx filed entry_ctls_base and entry_ctls are loaded from vmcs in:
    vcpu_create()->vcpu_prepare()->fill_common_vmcs()->load_vmcs_common().
    When vmwrite_cr() and vmwrite_efer() write a dirty VMX_ENTRY_CONTROLS,
    it only updates vmx field entry_ctls, but it compares with value of
    entry_ctls_base for dirty check, which may cause reduntant or miss
    programming to VMX_ENTRY_CONTROLS.

Below changes are made:

  • Add the missing clear of ENTRY_CONTROL_LONG_MODE_GUEST.
  • Move vmwrite_efer() to last of vmwrite_cr() after VMX_ENTRY_CONTROLS
    programmed.
  • Remove unnecessary entry_ctls_base in vmx field.

Signed-off-by: Colin Xu [email protected]

@HaxmCI HaxmCI added CI:Build Pass CI:Build Pass CI:Mac Test Pass CI:Mac Test Pass labels Aug 7, 2019
core/vcpu.c Outdated
@@ -2015,18 +2015,11 @@ static void vmwrite_cr(struct vcpu_t *vcpu)
}

if ((state->_cr4 & CR4_PAE) && (state->_cr0 & CR0_PG) &&
(state->_cr0 & CR0_PE)) {
(state->_cr0 & CR0_PE))
Copy link
Contributor

Choose a reason for hiding this comment

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

According to the coding style, conditional or loop statements with complex conditions or statements may be more readable with curly braces. Some projects require that an if must always have an accompanying brace.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I'll keep the curly braces.

There exists some issue when programming VMX_ENTRY_CONTROLS and GUEST_EFER:
- ENTRY_CONTROL_LONG_MODE_GUEST has no chance to clear.
- vmwrite_efer() called by vmwrite_cr() will check vmx field before
vmx field gets updated, and itself will also program VMX_ENTRY_CONTROLS,
which may cause incorrect VMX_ENTRY_CONTROLS programmed.
- vmx filed entry_ctls_base and entry_ctls are loaded from vmcs in:
vcpu_create()->vcpu_prepare()->fill_common_vmcs()->load_vmcs_common().
When vmwrite_cr() and vmwrite_efer() write a dirty VMX_ENTRY_CONTROLS,
it only updates vmx field entry_ctls, but it compares with value of
entry_ctls_base for dirty check, which may cause reduntant or miss
programming to VMX_ENTRY_CONTROLS.

Below changes are made:
- Add the missing clear of ENTRY_CONTROL_LONG_MODE_GUEST.
- Move vmwrite_efer() to last of vmwrite_cr() after VMX_ENTRY_CONTROLS
  programmed.
- Remove unnecessary entry_ctls_base in vmx field.

Signed-off-by: Colin Xu <[email protected]>
@wcwang wcwang merged commit 0335f37 into intel:master Aug 16, 2019
@coxuintel coxuintel deleted the vmx_entry branch December 30, 2019 01:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CI:Build Pass CI:Build Pass CI:Mac Test Pass CI:Mac Test Pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants