diff options
author | Avi Kivity <avi@redhat.com> | 2009-12-08 05:14:42 -0500 |
---|---|---|
committer | Marcelo Tosatti <mtosatti@redhat.com> | 2010-03-01 10:35:40 -0500 |
commit | bc23008b610dda1b0e69cd473b31c1391d6873f2 (patch) | |
tree | fe6619ed00237fdeb600fe14a44d5147e5910756 /arch/x86/kvm/vmx.c | |
parent | ce03e4f21a33b97c5d20ce597f64c361bb247904 (diff) |
KVM: VMX: Fold ept_update_paging_mode_cr4() into its caller
ept_update_paging_mode_cr4() accesses vcpu->arch.cr4 directly, which usually
needs to be accessed via kvm_read_cr4(). In this case, we can't, since cr4
is in the process of being updated. Instead of adding inane comments, fold
the function into its caller (vmx_set_cr4), so it can use the not-yet-committed
cr4 directly.
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm/vmx.c')
-rw-r--r-- | arch/x86/kvm/vmx.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index a7ebaa5f2b65..694baed9bc8f 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c | |||
@@ -1680,16 +1680,6 @@ static void ept_update_paging_mode_cr0(unsigned long *hw_cr0, | |||
1680 | *hw_cr0 &= ~X86_CR0_WP; | 1680 | *hw_cr0 &= ~X86_CR0_WP; |
1681 | } | 1681 | } |
1682 | 1682 | ||
1683 | static void ept_update_paging_mode_cr4(unsigned long *hw_cr4, | ||
1684 | struct kvm_vcpu *vcpu) | ||
1685 | { | ||
1686 | if (!is_paging(vcpu)) { | ||
1687 | *hw_cr4 &= ~X86_CR4_PAE; | ||
1688 | *hw_cr4 |= X86_CR4_PSE; | ||
1689 | } else if (!(vcpu->arch.cr4 & X86_CR4_PAE)) | ||
1690 | *hw_cr4 &= ~X86_CR4_PAE; | ||
1691 | } | ||
1692 | |||
1693 | static void vmx_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0) | 1683 | static void vmx_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0) |
1694 | { | 1684 | { |
1695 | struct vcpu_vmx *vmx = to_vmx(vcpu); | 1685 | struct vcpu_vmx *vmx = to_vmx(vcpu); |
@@ -1767,8 +1757,14 @@ static void vmx_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4) | |||
1767 | KVM_RMODE_VM_CR4_ALWAYS_ON : KVM_PMODE_VM_CR4_ALWAYS_ON); | 1757 | KVM_RMODE_VM_CR4_ALWAYS_ON : KVM_PMODE_VM_CR4_ALWAYS_ON); |
1768 | 1758 | ||
1769 | vcpu->arch.cr4 = cr4; | 1759 | vcpu->arch.cr4 = cr4; |
1770 | if (enable_ept) | 1760 | if (enable_ept) { |
1771 | ept_update_paging_mode_cr4(&hw_cr4, vcpu); | 1761 | if (!is_paging(vcpu)) { |
1762 | hw_cr4 &= ~X86_CR4_PAE; | ||
1763 | hw_cr4 |= X86_CR4_PSE; | ||
1764 | } else if (!(cr4 & X86_CR4_PAE)) { | ||
1765 | hw_cr4 &= ~X86_CR4_PAE; | ||
1766 | } | ||
1767 | } | ||
1772 | 1768 | ||
1773 | vmcs_writel(CR4_READ_SHADOW, cr4); | 1769 | vmcs_writel(CR4_READ_SHADOW, cr4); |
1774 | vmcs_writel(GUEST_CR4, hw_cr4); | 1770 | vmcs_writel(GUEST_CR4, hw_cr4); |