aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2008-04-04 16:25:52 +0100
committerKeir Fraser <keir.fraser@citrix.com>2008-04-04 16:25:52 +0100
commit86559edc28f0b0f4fb9d09649193b0aab41b0165 (patch)
tree2046adac3c4440cfdda71fdace2a93e45074535c
parent1a86889a32bce735d66f530129912bbc2b73c042 (diff)
downloadxen-86559edc28f0b0f4fb9d09649193b0aab41b0165.tar.gz
xen-86559edc28f0b0f4fb9d09649193b0aab41b0165.tar.bz2
xen-86559edc28f0b0f4fb9d09649193b0aab41b0165.zip
x86: Avoid use of domain_crash_synchronous() in C code.
We continue to use it in asm where it is a greater convenience and where also it is much more clearly correct. Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
-rw-r--r--xen/arch/x86/hvm/emulate.c9
-rw-r--r--xen/arch/x86/hvm/hvm.c8
-rw-r--r--xen/arch/x86/hvm/intercept.c72
-rw-r--r--xen/arch/x86/hvm/io.c23
-rw-r--r--xen/arch/x86/hvm/vmx/realmode.c2
-rw-r--r--xen/arch/x86/hvm/vmx/vmcs.c4
-rw-r--r--xen/arch/x86/hvm/vmx/x86_32/exits.S2
-rw-r--r--xen/arch/x86/hvm/vmx/x86_64/exits.S2
8 files changed, 58 insertions, 64 deletions
diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c
index 57065f7625..46aebf951b 100644
--- a/xen/arch/x86/hvm/emulate.c
+++ b/xen/arch/x86/hvm/emulate.c
@@ -41,12 +41,15 @@ static int hvmemul_do_io(
return X86EMUL_UNHANDLEABLE;
}
- curr->arch.hvm_vcpu.io_state =
- (val == NULL) ? HVMIO_dispatched : HVMIO_awaiting_completion;
-
if ( p->state != STATE_IOREQ_NONE )
+ {
gdprintk(XENLOG_WARNING, "WARNING: io already pending (%d)?\n",
p->state);
+ return X86EMUL_UNHANDLEABLE;
+ }
+
+ curr->arch.hvm_vcpu.io_state =
+ (val == NULL) ? HVMIO_dispatched : HVMIO_awaiting_completion;
p->dir = dir;
p->data_is_ptr = value_is_ptr;
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 961bfbf354..c3766bb318 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -181,7 +181,8 @@ void hvm_do_resume(struct vcpu *v)
break;
default:
gdprintk(XENLOG_ERR, "Weird HVM iorequest state %d.\n", p->state);
- domain_crash_synchronous();
+ domain_crash(v->domain);
+ return; /* bail */
}
}
}
@@ -742,9 +743,10 @@ void hvm_send_assist_req(struct vcpu *v)
p = &get_ioreq(v)->vp_ioreq;
if ( unlikely(p->state != STATE_IOREQ_NONE) )
{
- /* This indicates a bug in the device model. Crash the domain. */
+ /* This indicates a bug in the device model. Crash the domain. */
gdprintk(XENLOG_ERR, "Device model set bad IO state %d.\n", p->state);
- domain_crash_synchronous();
+ domain_crash(v->domain);
+ return;
}
prepare_wait_on_xen_event_channel(v->arch.hvm_vcpu.xen_port);
diff --git a/xen/arch/x86/hvm/intercept.c b/xen/arch/x86/hvm/intercept.c
index 04c5da7b6f..8084214d1f 100644
--- a/xen/arch/x86/hvm/intercept.c
+++ b/xen/arch/x86/hvm/intercept.c
@@ -52,45 +52,45 @@ static inline void hvm_mmio_access(struct vcpu *v,
{
unsigned long data;
- switch ( p->type )
+ if ( !p->data_is_ptr )
{
- case IOREQ_TYPE_COPY:
- if ( !p->data_is_ptr ) {
- if ( p->dir == IOREQ_READ )
- p->data = read_handler(v, p->addr, p->size);
- else /* p->dir == IOREQ_WRITE */
- write_handler(v, p->addr, p->size, p->data);
- } else { /* p->data_is_ptr */
- int i, sign = (p->df) ? -1 : 1;
-
- if ( p->dir == IOREQ_READ ) {
- for ( i = 0; i < p->count; i++ ) {
- data = read_handler(v,
- p->addr + (sign * i * p->size),
- p->size);
- (void)hvm_copy_to_guest_phys(
- p->data + (sign * i * p->size),
- &data,
- p->size);
- }
- } else {/* p->dir == IOREQ_WRITE */
- for ( i = 0; i < p->count; i++ ) {
- (void)hvm_copy_from_guest_phys(
- &data,
- p->data + (sign * i * p->size),
- p->size);
- write_handler(v,
- p->addr + (sign * i * p->size),
- p->size, data);
- }
+ if ( p->dir == IOREQ_READ )
+ p->data = read_handler(v, p->addr, p->size);
+ else /* p->dir == IOREQ_WRITE */
+ write_handler(v, p->addr, p->size, p->data);
+ }
+ else
+ {
+ int i, sign = (p->df) ? -1 : 1;
+
+ if ( p->dir == IOREQ_READ )
+ {
+ for ( i = 0; i < p->count; i++ )
+ {
+ data = read_handler(
+ v,
+ p->addr + (sign * i * p->size),
+ p->size);
+ (void)hvm_copy_to_guest_phys(
+ p->data + (sign * i * p->size),
+ &data,
+ p->size);
+ }
+ }
+ else
+ {
+ for ( i = 0; i < p->count; i++ )
+ {
+ (void)hvm_copy_from_guest_phys(
+ &data,
+ p->data + (sign * i * p->size),
+ p->size);
+ write_handler(
+ v,
+ p->addr + (sign * i * p->size),
+ p->size, data);
}
}
- break;
-
- default:
- printk("hvm_mmio_access: error ioreq type %x\n", p->type);
- domain_crash_synchronous();
- break;
}
}
diff --git a/xen/arch/x86/hvm/io.c b/xen/arch/x86/hvm/io.c
index ac1e62782a..9ff2958ca7 100644
--- a/xen/arch/x86/hvm/io.c
+++ b/xen/arch/x86/hvm/io.c
@@ -148,20 +148,19 @@ void send_timeoffset_req(unsigned long timeoff)
void send_invalidate_req(void)
{
struct vcpu *v = current;
- vcpu_iodata_t *vio;
+ vcpu_iodata_t *vio = get_ioreq(v);
ioreq_t *p;
- vio = get_ioreq(v);
- if ( vio == NULL )
- {
- printk("bad shared page: %lx\n", (unsigned long) vio);
- domain_crash_synchronous();
- }
+ BUG_ON(vio == NULL);
p = &vio->vp_ioreq;
if ( p->state != STATE_IOREQ_NONE )
- printk("WARNING: send invalidate req with something "
- "already pending (%d)?\n", p->state);
+ {
+ gdprintk(XENLOG_ERR, "WARNING: send invalidate req with something "
+ "already pending (%d)?\n", p->state);
+ domain_crash(v->domain);
+ return;
+ }
p->type = IOREQ_TYPE_INVALIDATE;
p->size = 4;
@@ -225,12 +224,6 @@ void hvm_io_assist(void)
ioreq_t *p = &get_ioreq(curr)->vp_ioreq;
enum hvm_io_state io_state;
- if ( p->state != STATE_IORESP_READY )
- {
- gdprintk(XENLOG_ERR, "Unexpected HVM iorequest state %d.\n", p->state);
- domain_crash_synchronous();
- }
-
rmb(); /* see IORESP_READY /then/ read contents of ioreq */
p->state = STATE_IOREQ_NONE;
diff --git a/xen/arch/x86/hvm/vmx/realmode.c b/xen/arch/x86/hvm/vmx/realmode.c
index c00e8b1e42..5d13f4e60b 100644
--- a/xen/arch/x86/hvm/vmx/realmode.c
+++ b/xen/arch/x86/hvm/vmx/realmode.c
@@ -172,7 +172,7 @@ static void realmode_emulate_one(struct hvm_emulate_ctxt *hvmemul_ctxt)
hvmemul_ctxt->insn_buf[0], hvmemul_ctxt->insn_buf[1],
hvmemul_ctxt->insn_buf[2], hvmemul_ctxt->insn_buf[3],
hvmemul_ctxt->insn_buf[4], hvmemul_ctxt->insn_buf[5]);
- domain_crash_synchronous();
+ domain_crash(curr->domain);
}
void vmx_realmode(struct cpu_user_regs *regs)
diff --git a/xen/arch/x86/hvm/vmx/vmcs.c b/xen/arch/x86/hvm/vmx/vmcs.c
index bee9eb1deb..725ae79c21 100644
--- a/xen/arch/x86/hvm/vmx/vmcs.c
+++ b/xen/arch/x86/hvm/vmx/vmcs.c
@@ -729,14 +729,14 @@ void vmx_destroy_vmcs(struct vcpu *v)
arch_vmx->vmcs = NULL;
}
-void vm_launch_fail(unsigned long eflags)
+void vm_launch_fail(void)
{
unsigned long error = __vmread(VM_INSTRUCTION_ERROR);
printk("<vm_launch_fail> error code %lx\n", error);
domain_crash_synchronous();
}
-void vm_resume_fail(unsigned long eflags)
+void vm_resume_fail(void)
{
unsigned long error = __vmread(VM_INSTRUCTION_ERROR);
printk("<vm_resume_fail> error code %lx\n", error);
diff --git a/xen/arch/x86/hvm/vmx/x86_32/exits.S b/xen/arch/x86/hvm/vmx/x86_32/exits.S
index 11db8cfc21..eff089a112 100644
--- a/xen/arch/x86/hvm/vmx/x86_32/exits.S
+++ b/xen/arch/x86/hvm/vmx/x86_32/exits.S
@@ -129,7 +129,6 @@ ENTRY(vmx_asm_do_vmentry)
/*vmx_resume:*/
HVM_RESTORE_ALL_NOSEGREGS
VMRESUME
- pushf
call vm_resume_fail
ud2
@@ -137,7 +136,6 @@ vmx_launch:
movb $1,VCPU_vmx_launched(%ebx)
HVM_RESTORE_ALL_NOSEGREGS
VMLAUNCH
- pushf
call vm_launch_fail
ud2
diff --git a/xen/arch/x86/hvm/vmx/x86_64/exits.S b/xen/arch/x86/hvm/vmx/x86_64/exits.S
index 48da4869bd..56fdb8ad54 100644
--- a/xen/arch/x86/hvm/vmx/x86_64/exits.S
+++ b/xen/arch/x86/hvm/vmx/x86_64/exits.S
@@ -148,7 +148,6 @@ ENTRY(vmx_asm_do_vmentry)
/*vmx_resume:*/
HVM_RESTORE_ALL_NOSEGREGS
VMRESUME
- pushfq
call vm_resume_fail
ud2
@@ -156,7 +155,6 @@ vmx_launch:
movb $1,VCPU_vmx_launched(%rbx)
HVM_RESTORE_ALL_NOSEGREGS
VMLAUNCH
- pushfq
call vm_launch_fail
ud2