if (r == X86EMUL_IO_NEEDED)
return r;
- if (r)
+ if (r > 0)
return emulate_gp(ctxt, 0);
- return X86EMUL_CONTINUE;
+ return r < 0 ? X86EMUL_UNHANDLEABLE : X86EMUL_CONTINUE;
}
static int em_rdmsr(struct x86_emulate_ctxt *ctxt)
r = kvm_set_msr(vcpu, ecx, data);
/* MSR write failed? See if we should ask user space */
- if (r && kvm_set_msr_user_space(vcpu, ecx, data, r)) {
+ if (r && kvm_set_msr_user_space(vcpu, ecx, data, r))
/* Bounce to user space */
return 0;
- }
+
+ /* Signal all other negative errors to userspace */
+ if (r < 0)
+ return r;
/* MSR write failed? Inject a #GP */
- if (r) {
+ if (r > 0) {
trace_kvm_msr_write_ex(ecx, data);
kvm_inject_gp(vcpu, 0);
return 1;