Commit db297e3d authored by Avi Kivity's avatar Avi Kivity

KVM: x86 emulator: tighen up ->read_std() and ->write_std() error checks

Instead of checking for X86EMUL_PROPAGATE_FAULT, check for any error,
making the callers more reliable.
Signed-off-by: default avatarAvi Kivity <avi@redhat.com>
Signed-off-by: default avatarMarcelo Tosatti <mtosatti@redhat.com>
parent 42438e36
...@@ -1915,7 +1915,7 @@ static int task_switch_16(struct x86_emulate_ctxt *ctxt, ...@@ -1915,7 +1915,7 @@ static int task_switch_16(struct x86_emulate_ctxt *ctxt,
ret = ops->read_std(old_tss_base, &tss_seg, sizeof tss_seg, ctxt->vcpu, ret = ops->read_std(old_tss_base, &tss_seg, sizeof tss_seg, ctxt->vcpu,
&ctxt->exception); &ctxt->exception);
if (ret == X86EMUL_PROPAGATE_FAULT) if (ret != X86EMUL_CONTINUE)
/* FIXME: need to provide precise fault address */ /* FIXME: need to provide precise fault address */
return ret; return ret;
...@@ -1923,13 +1923,13 @@ static int task_switch_16(struct x86_emulate_ctxt *ctxt, ...@@ -1923,13 +1923,13 @@ static int task_switch_16(struct x86_emulate_ctxt *ctxt,
ret = ops->write_std(old_tss_base, &tss_seg, sizeof tss_seg, ctxt->vcpu, ret = ops->write_std(old_tss_base, &tss_seg, sizeof tss_seg, ctxt->vcpu,
&ctxt->exception); &ctxt->exception);
if (ret == X86EMUL_PROPAGATE_FAULT) if (ret != X86EMUL_CONTINUE)
/* FIXME: need to provide precise fault address */ /* FIXME: need to provide precise fault address */
return ret; return ret;
ret = ops->read_std(new_tss_base, &tss_seg, sizeof tss_seg, ctxt->vcpu, ret = ops->read_std(new_tss_base, &tss_seg, sizeof tss_seg, ctxt->vcpu,
&ctxt->exception); &ctxt->exception);
if (ret == X86EMUL_PROPAGATE_FAULT) if (ret != X86EMUL_CONTINUE)
/* FIXME: need to provide precise fault address */ /* FIXME: need to provide precise fault address */
return ret; return ret;
...@@ -1940,7 +1940,7 @@ static int task_switch_16(struct x86_emulate_ctxt *ctxt, ...@@ -1940,7 +1940,7 @@ static int task_switch_16(struct x86_emulate_ctxt *ctxt,
&tss_seg.prev_task_link, &tss_seg.prev_task_link,
sizeof tss_seg.prev_task_link, sizeof tss_seg.prev_task_link,
ctxt->vcpu, &ctxt->exception); ctxt->vcpu, &ctxt->exception);
if (ret == X86EMUL_PROPAGATE_FAULT) if (ret != X86EMUL_CONTINUE)
/* FIXME: need to provide precise fault address */ /* FIXME: need to provide precise fault address */
return ret; return ret;
} }
...@@ -2049,7 +2049,7 @@ static int task_switch_32(struct x86_emulate_ctxt *ctxt, ...@@ -2049,7 +2049,7 @@ static int task_switch_32(struct x86_emulate_ctxt *ctxt,
ret = ops->read_std(old_tss_base, &tss_seg, sizeof tss_seg, ctxt->vcpu, ret = ops->read_std(old_tss_base, &tss_seg, sizeof tss_seg, ctxt->vcpu,
&ctxt->exception); &ctxt->exception);
if (ret == X86EMUL_PROPAGATE_FAULT) if (ret != X86EMUL_CONTINUE)
/* FIXME: need to provide precise fault address */ /* FIXME: need to provide precise fault address */
return ret; return ret;
...@@ -2057,13 +2057,13 @@ static int task_switch_32(struct x86_emulate_ctxt *ctxt, ...@@ -2057,13 +2057,13 @@ static int task_switch_32(struct x86_emulate_ctxt *ctxt,
ret = ops->write_std(old_tss_base, &tss_seg, sizeof tss_seg, ctxt->vcpu, ret = ops->write_std(old_tss_base, &tss_seg, sizeof tss_seg, ctxt->vcpu,
&ctxt->exception); &ctxt->exception);
if (ret == X86EMUL_PROPAGATE_FAULT) if (ret != X86EMUL_CONTINUE)
/* FIXME: need to provide precise fault address */ /* FIXME: need to provide precise fault address */
return ret; return ret;
ret = ops->read_std(new_tss_base, &tss_seg, sizeof tss_seg, ctxt->vcpu, ret = ops->read_std(new_tss_base, &tss_seg, sizeof tss_seg, ctxt->vcpu,
&ctxt->exception); &ctxt->exception);
if (ret == X86EMUL_PROPAGATE_FAULT) if (ret != X86EMUL_CONTINUE)
/* FIXME: need to provide precise fault address */ /* FIXME: need to provide precise fault address */
return ret; return ret;
...@@ -2074,7 +2074,7 @@ static int task_switch_32(struct x86_emulate_ctxt *ctxt, ...@@ -2074,7 +2074,7 @@ static int task_switch_32(struct x86_emulate_ctxt *ctxt,
&tss_seg.prev_task_link, &tss_seg.prev_task_link,
sizeof tss_seg.prev_task_link, sizeof tss_seg.prev_task_link,
ctxt->vcpu, &ctxt->exception); ctxt->vcpu, &ctxt->exception);
if (ret == X86EMUL_PROPAGATE_FAULT) if (ret != X86EMUL_CONTINUE)
/* FIXME: need to provide precise fault address */ /* FIXME: need to provide precise fault address */
return ret; return ret;
} }
......
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