From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: [PATCH 4/7] KVM: x86 emulator: tighen up ->read_std() and ->write_std() error checks Date: Mon, 22 Nov 2010 17:53:24 +0200 Message-ID: <1290441207-4250-5-git-send-email-avi@redhat.com> References: <1290441207-4250-1-git-send-email-avi@redhat.com> To: Marcelo Tosatti , kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:9517 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754609Ab0KVPxn (ORCPT ); Mon, 22 Nov 2010 10:53:43 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oAMFrgUS021856 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 22 Nov 2010 10:53:43 -0500 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oAMFrddo022101 for ; Mon, 22 Nov 2010 10:53:41 -0500 In-Reply-To: <1290441207-4250-1-git-send-email-avi@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Instead of checking for X86EMUL_PROPAGATE_FAULT, check for any error, making the callers more reliable. Signed-off-by: Avi Kivity --- arch/x86/kvm/emulate.c | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index b39df7b..4b8f58b 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -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, &ctxt->exception); - if (ret == X86EMUL_PROPAGATE_FAULT) + if (ret != X86EMUL_CONTINUE) /* FIXME: need to provide precise fault address */ return ret; @@ -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, &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; @@ -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; } @@ -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, &ctxt->exception); - if (ret == X86EMUL_PROPAGATE_FAULT) + if (ret != X86EMUL_CONTINUE) /* FIXME: need to provide precise fault address */ return ret; @@ -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, &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; @@ -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; } -- 1.7.1