aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/svm.c
diff options
context:
space:
mode:
authorJoerg Roedel <joerg.roedel@amd.com>2009-08-07 05:49:41 -0400
committerAvi Kivity <avi@redhat.com>2009-09-10 03:46:29 -0400
commit9738b2c97d19d87e5c204ae8c3f715a546bb6773 (patch)
tree5004ae3445e5d991d9b4faa60b4a56b217d22573 /arch/x86/kvm/svm.c
parent9966bf6872598362b632b738213edfb5a961315d (diff)
KVM: SVM: clean up nested vmrun path
This patch removes the usage of nested_svm_do from the vmrun emulation path. Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm/svm.c')
-rw-r--r--arch/x86/kvm/svm.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 78c0463ccdd4..68b6d4cdd153 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -1724,25 +1724,35 @@ static int nested_svm_vmexit(struct vcpu_svm *svm)
1724 return 0; 1724 return 0;
1725} 1725}
1726 1726
1727static int nested_svm_vmrun_msrpm(struct vcpu_svm *svm, void *arg1, 1727static bool nested_svm_vmrun_msrpm(struct vcpu_svm *svm)
1728 void *arg2, void *opaque)
1729{ 1728{
1729 u32 *nested_msrpm;
1730 int i; 1730 int i;
1731 u32 *nested_msrpm = (u32*)arg1; 1731
1732 nested_msrpm = nested_svm_map(svm, svm->nested.vmcb_msrpm, KM_USER0);
1733 if (!nested_msrpm)
1734 return false;
1735
1732 for (i=0; i< PAGE_SIZE * (1 << MSRPM_ALLOC_ORDER) / 4; i++) 1736 for (i=0; i< PAGE_SIZE * (1 << MSRPM_ALLOC_ORDER) / 4; i++)
1733 svm->nested.msrpm[i] = svm->msrpm[i] | nested_msrpm[i]; 1737 svm->nested.msrpm[i] = svm->msrpm[i] | nested_msrpm[i];
1738
1734 svm->vmcb->control.msrpm_base_pa = __pa(svm->nested.msrpm); 1739 svm->vmcb->control.msrpm_base_pa = __pa(svm->nested.msrpm);
1735 1740
1736 return 0; 1741 nested_svm_unmap(nested_msrpm, KM_USER0);
1742
1743 return true;
1737} 1744}
1738 1745
1739static int nested_svm_vmrun(struct vcpu_svm *svm, void *arg1, 1746static bool nested_svm_vmrun(struct vcpu_svm *svm)
1740 void *arg2, void *opaque)
1741{ 1747{
1742 struct vmcb *nested_vmcb = (struct vmcb *)arg1; 1748 struct vmcb *nested_vmcb;
1743 struct vmcb *hsave = svm->nested.hsave; 1749 struct vmcb *hsave = svm->nested.hsave;
1744 struct vmcb *vmcb = svm->vmcb; 1750 struct vmcb *vmcb = svm->vmcb;
1745 1751
1752 nested_vmcb = nested_svm_map(svm, svm->vmcb->save.rax, KM_USER0);
1753 if (!nested_vmcb)
1754 return false;
1755
1746 /* nested_vmcb is our indicator if nested SVM is activated */ 1756 /* nested_vmcb is our indicator if nested SVM is activated */
1747 svm->nested.vmcb = svm->vmcb->save.rax; 1757 svm->nested.vmcb = svm->vmcb->save.rax;
1748 1758
@@ -1858,9 +1868,11 @@ static int nested_svm_vmrun(struct vcpu_svm *svm, void *arg1,
1858 svm->vmcb->control.event_inj = nested_vmcb->control.event_inj; 1868 svm->vmcb->control.event_inj = nested_vmcb->control.event_inj;
1859 svm->vmcb->control.event_inj_err = nested_vmcb->control.event_inj_err; 1869 svm->vmcb->control.event_inj_err = nested_vmcb->control.event_inj_err;
1860 1870
1871 nested_svm_unmap(nested_vmcb, KM_USER0);
1872
1861 enable_gif(svm); 1873 enable_gif(svm);
1862 1874
1863 return 0; 1875 return true;
1864} 1876}
1865 1877
1866static void nested_svm_vmloadsave(struct vmcb *from_vmcb, struct vmcb *to_vmcb) 1878static void nested_svm_vmloadsave(struct vmcb *from_vmcb, struct vmcb *to_vmcb)
@@ -1928,12 +1940,10 @@ static int vmrun_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
1928 svm->next_rip = kvm_rip_read(&svm->vcpu) + 3; 1940 svm->next_rip = kvm_rip_read(&svm->vcpu) + 3;
1929 skip_emulated_instruction(&svm->vcpu); 1941 skip_emulated_instruction(&svm->vcpu);
1930 1942
1931 if (nested_svm_do(svm, svm->vmcb->save.rax, 0, 1943 if (!nested_svm_vmrun(svm))
1932 NULL, nested_svm_vmrun))
1933 return 1; 1944 return 1;
1934 1945
1935 if (nested_svm_do(svm, svm->nested.vmcb_msrpm, 0, 1946 if (!nested_svm_vmrun_msrpm(svm))
1936 NULL, nested_svm_vmrun_msrpm))
1937 return 1; 1947 return 1;
1938 1948
1939 return 1; 1949 return 1;