Skip to content

Instantly share code, notes, and snippets.

@marmarek
Created June 5, 2020 12:59
Show Gist options
  • Save marmarek/da37da3722179057a6e7add4fb361e06 to your computer and use it in GitHub Desktop.
Save marmarek/da37da3722179057a6e7add4fb361e06 to your computer and use it in GitHub Desktop.
diff --git a/xen/arch/x86/hvm/dm.c b/xen/arch/x86/hvm/dm.c
index d6d0e8be89..18ee85c520 100644
--- a/xen/arch/x86/hvm/dm.c
+++ b/xen/arch/x86/hvm/dm.c
@@ -647,7 +647,38 @@ static int dm_op(const struct dmop_args *op_args)
const struct xen_dm_op_remote_shutdown *data =
&op.u.remote_shutdown;
+ gprintk(XENLOG_DEBUG, "XEN_DMOP_remote_shutdown domain %d reason %d\n",
+ d->domain_id, data->reason);
domain_shutdown(d, data->reason);
+ gprintk(XENLOG_DEBUG, "XEN_DMOP_remote_shutdown domain %d done\n",
+ d->domain_id);
+#if 0
+ {
+ const struct sched_unit *unit;
+ struct vcpu *v;
+ for_each_sched_unit ( d, unit )
+ {
+ printk(" UNIT%d affinities: hard={%*pbl} soft={%*pbl}\n",
+ unit->unit_id, CPUMASK_PR(unit->cpu_hard_affinity),
+ CPUMASK_PR(unit->cpu_soft_affinity));
+
+ for_each_sched_unit_vcpu ( unit, v )
+ {
+ printk(" VCPU%d: CPU%d [has=%c] poll=%d "
+ "upcall_pend=%02x upcall_mask=%02x ",
+ v->vcpu_id, v->processor,
+ v->is_running ? 'T':'F', v->poll_evtchn,
+ vcpu_info(v, evtchn_upcall_pending),
+ !vcpu_event_delivery_is_enabled(v));
+ if ( vcpu_cpu_dirty(v) )
+ printk("dirty_cpu=%u", v->dirty_cpu);
+ printk("\n");
+ printk(" pause_count=%d pause_flags=%lx\n",
+ atomic_read(&v->pause_count), v->pause_flags);
+ }
+ }
+ }
+#endif
rc = 0;
break;
}
diff --git a/xen/arch/x86/hvm/io.c b/xen/arch/x86/hvm/io.c
index a5b0a23f06..913bdb009a 100644
--- a/xen/arch/x86/hvm/io.c
+++ b/xen/arch/x86/hvm/io.c
@@ -140,6 +140,14 @@ bool handle_pio(uint16_t port, unsigned int size, int dir)
if ( dir == IOREQ_WRITE )
data = guest_cpu_user_regs()->eax;
+ if (port == 0xb004)
+ gprintk(XENLOG_DEBUG, "handle_pio port %#x %s 0x%0*lx "
+ "is_shutting_down %d defer_shutdown %d paused_for_shutdown %d is_shut_down %d\n",
+ port,
+ dir == IOREQ_WRITE ? "write" : "read",
+ size*2, (dir == IOREQ_WRITE?data:0) & ((1ul << (size * 8)) - 1),
+ curr->domain->is_shutting_down, curr->defer_shutdown,
+ curr->paused_for_shutdown, curr->domain->is_shut_down);
rc = hvmemul_do_pio_buffer(port, size, dir, &data);
if ( hvm_ioreq_needs_completion(&vio->io_req) )
@@ -167,7 +175,10 @@ bool handle_pio(uint16_t port, unsigned int size, int dir)
break;
default:
- gdprintk(XENLOG_ERR, "Weird HVM ioemulation status %d.\n", rc);
+ gprintk(XENLOG_ERR, "Unexpected PIO status %d, port %#x %s 0x%0*lx\n",
+ rc, port, dir == IOREQ_WRITE ? "write" : "read",
+ size * 2, data & ((1u << (size * 8)) - 1));
+ BUG();
domain_crash(curr->domain);
return false;
}
diff --git a/xen/common/domain.c b/xen/common/domain.c
index 611116c7fc..0f2458e344 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -852,8 +852,11 @@ int domain_shutdown(struct domain *d, u8 reason)
{
if ( reason == SHUTDOWN_crash )
v->defer_shutdown = 0;
- else if ( v->defer_shutdown )
+ else if ( v->defer_shutdown ) {
+ gprintk(XENLOG_DEBUG, "domain %d domain_shutdown vcpu_id %d defer_shutdown %d\n",
+ d->domain_id, v->vcpu_id, v->defer_shutdown);
continue;
+ }
vcpu_pause_nosync(v);
v->paused_for_shutdown = 1;
}
diff --git a/xen/common/schedule.c b/xen/common/schedule.c
index 54a07ff9e8..7b43d9bcd4 100644
--- a/xen/common/schedule.c
+++ b/xen/common/schedule.c
@@ -1637,6 +1637,8 @@ ret_t do_sched_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
if ( copy_from_guest(&sched_shutdown, arg, 1) )
break;
+ gprintk(XENLOG_DEBUG, "SCHEDOP_shutdown vcpu_id %d reason %d\n",
+ current->vcpu_id, sched_shutdown.reason);
TRACE_3D(TRC_SCHED_SHUTDOWN,
current->domain->domain_id, current->vcpu_id,
sched_shutdown.reason);
@@ -1654,6 +1656,8 @@ ret_t do_sched_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
if ( copy_from_guest(&sched_shutdown, arg, 1) )
break;
+ gprintk(XENLOG_DEBUG, "SCHEDOP_shutdown_code vcpu_id %d reason %d\n",
+ current->vcpu_id, sched_shutdown.reason);
TRACE_3D(TRC_SCHED_SHUTDOWN_CODE,
d->domain_id, current->vcpu_id, sched_shutdown.reason);
@@ -1693,6 +1697,8 @@ ret_t do_sched_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
if ( d == NULL )
break;
+ gprintk(XENLOG_DEBUG, "SCHEDOP_remote_shutdown domain %d reason %d\n",
+ d->domain_id, sched_remote_shutdown.reason);
ret = xsm_schedop_shutdown(XSM_DM_PRIV, current->domain, d);
if ( likely(!ret) )
domain_shutdown(d, sched_remote_shutdown.reason);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment