Commit 3d62d9aa authored by Joerg Roedel's avatar Joerg Roedel Committed by Avi Kivity

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: default avatarJoerg Roedel <joerg.roedel@amd.com>
Signed-off-by: default avatarAlexander Graf <agraf@suse.de>
Signed-off-by: default avatarAvi Kivity <avi@redhat.com>
parent 34f80cfa
...@@ -1483,18 +1483,21 @@ static int nested_svm_do(struct vcpu_svm *svm, ...@@ -1483,18 +1483,21 @@ static int nested_svm_do(struct vcpu_svm *svm,
return retval; return retval;
} }
static int nested_svm_exit_handled_msr(struct vcpu_svm *svm, static bool nested_svm_exit_handled_msr(struct vcpu_svm *svm)
void *arg1, void *arg2,
void *opaque)
{ {
struct vmcb *nested_vmcb = (struct vmcb *)arg1;
u8 *msrpm = (u8 *)arg2;
u32 t0, t1;
u32 msr = svm->vcpu.arch.regs[VCPU_REGS_RCX];
u32 param = svm->vmcb->control.exit_info_1 & 1; u32 param = svm->vmcb->control.exit_info_1 & 1;
u32 msr = svm->vcpu.arch.regs[VCPU_REGS_RCX];
bool ret = false;
u32 t0, t1;
u8 *msrpm;
if (!(nested_vmcb->control.intercept & (1ULL << INTERCEPT_MSR_PROT))) if (!(svm->nested.intercept & (1ULL << INTERCEPT_MSR_PROT)))
return 0; return false;
msrpm = nested_svm_map(svm, svm->nested.vmcb_msrpm, KM_USER0);
if (!msrpm)
goto out;
switch (msr) { switch (msr) {
case 0 ... 0x1fff: case 0 ... 0x1fff:
...@@ -1512,13 +1515,16 @@ static int nested_svm_exit_handled_msr(struct vcpu_svm *svm, ...@@ -1512,13 +1515,16 @@ static int nested_svm_exit_handled_msr(struct vcpu_svm *svm,
t0 %= 8; t0 %= 8;
break; break;
default: default:
return 1; ret = true;
break; goto out;
} }
if (msrpm[t1] & ((1 << param) << t0))
return 1;
return 0; ret = msrpm[t1] & ((1 << param) << t0);
out:
nested_svm_unmap(msrpm, KM_USER0);
return ret;
} }
static int nested_svm_exit_handled(struct vcpu_svm *svm, bool kvm_override) static 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,9 +1554,7 @@ static int nested_svm_exit_handled(struct vcpu_svm *svm, bool kvm_override)
switch (exit_code) { switch (exit_code) {
case SVM_EXIT_MSR: case SVM_EXIT_MSR:
if (nested_svm_do(svm, svm->nested.vmcb, svm->nested.vmcb_msrpm, vmexit = nested_svm_exit_handled_msr(svm);
NULL, nested_svm_exit_handled_msr))
vmexit = true;
break; break;
case SVM_EXIT_READ_CR0 ... SVM_EXIT_READ_CR8: { case SVM_EXIT_READ_CR0 ... SVM_EXIT_READ_CR8: {
u32 cr_bits = 1 << (exit_code - SVM_EXIT_READ_CR0); u32 cr_bits = 1 << (exit_code - SVM_EXIT_READ_CR0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment