Skip to content

Commit

Permalink
KVM: x86 emulator: tighen up ->read_std() and ->write_std() error checks
Browse files Browse the repository at this point in the history
Instead of checking for X86EMUL_PROPAGATE_FAULT, check for any error,
making the callers more reliable.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
  • Loading branch information
Avi Kivity committed Jan 12, 2011
1 parent 42438e3 commit db297e3
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions arch/x86/kvm/emulate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1915,21 +1915,21 @@ static int task_switch_16(struct x86_emulate_ctxt *ctxt,

ret = ops->read_std(old_tss_base, &tss_seg, sizeof tss_seg, ctxt->vcpu,
&ctxt->exception);
if (ret == X86EMUL_PROPAGATE_FAULT)
if (ret != X86EMUL_CONTINUE)
/* FIXME: need to provide precise fault address */
return ret;

save_state_to_tss16(ctxt, ops, &tss_seg);

ret = ops->write_std(old_tss_base, &tss_seg, sizeof tss_seg, ctxt->vcpu,
&ctxt->exception);
if (ret == X86EMUL_PROPAGATE_FAULT)
if (ret != X86EMUL_CONTINUE)
/* FIXME: need to provide precise fault address */
return ret;

ret = ops->read_std(new_tss_base, &tss_seg, sizeof tss_seg, ctxt->vcpu,
&ctxt->exception);
if (ret == X86EMUL_PROPAGATE_FAULT)
if (ret != X86EMUL_CONTINUE)
/* FIXME: need to provide precise fault address */
return ret;

Expand All @@ -1940,7 +1940,7 @@ static int task_switch_16(struct x86_emulate_ctxt *ctxt,
&tss_seg.prev_task_link,
sizeof tss_seg.prev_task_link,
ctxt->vcpu, &ctxt->exception);
if (ret == X86EMUL_PROPAGATE_FAULT)
if (ret != X86EMUL_CONTINUE)
/* FIXME: need to provide precise fault address */
return ret;
}
Expand Down Expand Up @@ -2049,21 +2049,21 @@ static int task_switch_32(struct x86_emulate_ctxt *ctxt,

ret = ops->read_std(old_tss_base, &tss_seg, sizeof tss_seg, ctxt->vcpu,
&ctxt->exception);
if (ret == X86EMUL_PROPAGATE_FAULT)
if (ret != X86EMUL_CONTINUE)
/* FIXME: need to provide precise fault address */
return ret;

save_state_to_tss32(ctxt, ops, &tss_seg);

ret = ops->write_std(old_tss_base, &tss_seg, sizeof tss_seg, ctxt->vcpu,
&ctxt->exception);
if (ret == X86EMUL_PROPAGATE_FAULT)
if (ret != X86EMUL_CONTINUE)
/* FIXME: need to provide precise fault address */
return ret;

ret = ops->read_std(new_tss_base, &tss_seg, sizeof tss_seg, ctxt->vcpu,
&ctxt->exception);
if (ret == X86EMUL_PROPAGATE_FAULT)
if (ret != X86EMUL_CONTINUE)
/* FIXME: need to provide precise fault address */
return ret;

Expand All @@ -2074,7 +2074,7 @@ static int task_switch_32(struct x86_emulate_ctxt *ctxt,
&tss_seg.prev_task_link,
sizeof tss_seg.prev_task_link,
ctxt->vcpu, &ctxt->exception);
if (ret == X86EMUL_PROPAGATE_FAULT)
if (ret != X86EMUL_CONTINUE)
/* FIXME: need to provide precise fault address */
return ret;
}
Expand Down

0 comments on commit db297e3

Please sign in to comment.