aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/svm.c
diff options
context:
space:
mode:
authorJoerg Roedel <joerg.roedel@amd.com>2009-08-07 05:49:39 -0400
committerAvi Kivity <avi@redhat.com>2009-09-10 03:45:43 -0400
commit3d62d9aa9868865217ce3a1b70d6039a98b50820 (patch)
tree5270dbea731c7a011028b7df3ef83b330022787d /arch/x86/kvm/svm.c
parent34f80cfad59ee587e374cbaf5f2a31d9f5015404 (diff)
KVM: SVM: clean up nested_svm_exit_handled_msr
This patch changes nested svm to call nested_svm_exit_handled_msr directly and not through nested_svm_do. [alex: fix oops due to nested kmap_atomics] Signed-off-by: Joerg Roedel <joerg.roedel@amd.com> Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm/svm.c')
-rw-r--r--arch/x86/kvm/svm.c38
1 files changed, 21 insertions, 17 deletions
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 5e55a1bdd13d..e85d79142ffc 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -1483,18 +1483,21 @@ static int nested_svm_do(struct vcpu_svm *svm,
1483 return retval; 1483 return retval;
1484} 1484}
1485 1485
1486static int nested_svm_exit_handled_msr(struct vcpu_svm *svm, 1486static bool nested_svm_exit_handled_msr(struct vcpu_svm *svm)
1487 void *arg1, void *arg2,
1488 void *opaque)
1489{ 1487{
1490 struct vmcb *nested_vmcb = (struct vmcb *)arg1;
1491 u8 *msrpm = (u8 *)arg2;
1492 u32 t0, t1;
1493 u32 msr = svm->vcpu.arch.regs[VCPU_REGS_RCX];
1494 u32 param = svm->vmcb->control.exit_info_1 & 1; 1488 u32 param = svm->vmcb->control.exit_info_1 & 1;
1489 u32 msr = svm->vcpu.arch.regs[VCPU_REGS_RCX];
1490 bool ret = false;
1491 u32 t0, t1;
1492 u8 *msrpm;
1495 1493
1496 if (!(nested_vmcb->control.intercept & (1ULL << INTERCEPT_MSR_PROT))) 1494 if (!(svm->nested.intercept & (1ULL << INTERCEPT_MSR_PROT)))
1497 return 0; 1495 return false;
1496
1497 msrpm = nested_svm_map(svm, svm->nested.vmcb_msrpm, KM_USER0);
1498
1499 if (!msrpm)
1500 goto out;
1498 1501
1499 switch (msr) { 1502 switch (msr) {
1500 case 0 ... 0x1fff: 1503 case 0 ... 0x1fff:
@@ -1512,13 +1515,16 @@ static int nested_svm_exit_handled_msr(struct vcpu_svm *svm,
1512 t0 %= 8; 1515 t0 %= 8;
1513 break; 1516 break;
1514 default: 1517 default:
1515 return 1; 1518 ret = true;
1516 break; 1519 goto out;
1517 } 1520 }
1518 if (msrpm[t1] & ((1 << param) << t0))
1519 return 1;
1520 1521
1521 return 0; 1522 ret = msrpm[t1] & ((1 << param) << t0);
1523
1524out:
1525 nested_svm_unmap(msrpm, KM_USER0);
1526
1527 return ret;
1522} 1528}
1523 1529
1524static int nested_svm_exit_handled(struct vcpu_svm *svm, bool kvm_override) 1530static int nested_svm_exit_handled(struct vcpu_svm *svm, bool kvm_override)
@@ -1548,9 +1554,7 @@ static int nested_svm_exit_handled(struct vcpu_svm *svm, bool kvm_override)
1548 1554
1549 switch (exit_code) { 1555 switch (exit_code) {
1550 case SVM_EXIT_MSR: 1556 case SVM_EXIT_MSR:
1551 if (nested_svm_do(svm, svm->nested.vmcb, svm->nested.vmcb_msrpm, 1557 vmexit = nested_svm_exit_handled_msr(svm);
1552 NULL, nested_svm_exit_handled_msr))
1553 vmexit = true;
1554 break; 1558 break;
1555 case SVM_EXIT_READ_CR0 ... SVM_EXIT_READ_CR8: { 1559 case SVM_EXIT_READ_CR0 ... SVM_EXIT_READ_CR8: {
1556 u32 cr_bits = 1 << (exit_code - SVM_EXIT_READ_CR0); 1560 u32 cr_bits = 1 << (exit_code - SVM_EXIT_READ_CR0);