|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v1 20/28] x86/hvm: rework XEN_DOMCTL_debug_op
From: Denis Mukhin <dmukhin@xxxxxxxx>
Currently, XEN_DOMCTL_debug_op assumes operations on VCPUs only
and only for Intel VMX-supported HVM domains. This limits its
usability in the test infrastructure.
Generalize XEN_DOMCTL_debug_op to allow operations on any x86 HVM
domain.
Signed-off-by: Denis Mukhin <dmukhin@xxxxxxxx>
---
xen/arch/x86/domctl.c | 24 ++++--------
xen/arch/x86/hvm/hvm.c | 59 ++++++++++++++++++++----------
xen/arch/x86/include/asm/hvm/hvm.h | 3 +-
xen/include/public/domctl.h | 1 +
4 files changed, 49 insertions(+), 38 deletions(-)
diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
index 12c14bb3f514..7a52aff71620 100644
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -912,23 +912,13 @@ long arch_do_domctl(
case XEN_DOMCTL_debug_op:
{
- struct vcpu *v;
-
- ret = -EOPNOTSUPP;
- if ( !IS_ENABLED(CONFIG_HVM) )
- break;
-
- ret = -EINVAL;
- if ( (domctl->u.debug_op.vcpu >= d->max_vcpus) ||
- ((v = d->vcpu[domctl->u.debug_op.vcpu]) == NULL) )
- break;
-
- ret = -EINVAL;
- if ( (v == curr) || /* no vcpu_pause() */
- !is_hvm_domain(d) )
- break;
-
- ret = hvm_debug_op(v, domctl->u.debug_op.op);
+ if ( IS_ENABLED(CONFIG_HVM) )
+ ret = hvm_debug_op(d,
+ domctl->u.debug_op.op,
+ domctl->u.debug_op.vcpu,
+ domctl->u.debug_op.arg);
+ else
+ ret = -EOPNOTSUPP;
break;
}
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index ef9c7cd05777..42139837904a 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -5200,32 +5200,52 @@ long do_hvm_op(unsigned long op,
XEN_GUEST_HANDLE_PARAM(void) arg)
return rc;
}
-int hvm_debug_op(struct vcpu *v, int32_t op)
+static int hvm_debug_op_single_step_allowed(const struct domain *d,
+ unsigned int vcpu)
{
+ if ( (vcpu >= d->max_vcpus) || (d->vcpu[vcpu] == NULL) )
+ return -EINVAL;
+
+ if ( (d->vcpu[vcpu] == current) || /* no vcpu_pause() */
+ !is_hvm_domain(d) )
+ return -EINVAL;
+
+ if ( !IS_ENABLED(CONFIG_INTEL_VMX) || !cpu_has_monitor_trap_flag )
+ return -EOPNOTSUPP;
+
+ return 0;
+}
+
+int hvm_debug_op(struct domain *d, unsigned int op, unsigned int vcpu,
+ unsigned int arg)
+{
+ struct vcpu *v;
int rc = 0;
- switch ( op )
- {
- case XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_ON:
- case XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_OFF:
- if ( !cpu_has_monitor_trap_flag )
- return -EOPNOTSUPP;
- break;
- default:
- return -ENOSYS;
- }
-
- BUILD_ERROR_IF_NOT(CONFIG_INTEL_VMX);
-
- vcpu_pause(v);
-
switch ( op )
{
case XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_ON:
+ rc = hvm_debug_op_single_step_allowed(d, vcpu);
+ if ( rc )
+ break;
+
+ v = d->vcpu[vcpu];
+
+ vcpu_pause(v);
v->arch.hvm.single_step = true;
+ vcpu_unpause(v); /* guest will latch new state */
+
break;
case XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_OFF:
+ rc = hvm_debug_op_single_step_allowed(d, vcpu);
+ if ( rc )
+ break;
+
+ v = d->vcpu[vcpu];
+
+ vcpu_pause(v);
+
v->arch.hvm.single_step = false;
#ifdef CONFIG_ALTP2M
@@ -5233,15 +5253,14 @@ int hvm_debug_op(struct vcpu *v, int32_t op)
v->arch.hvm.fast_single_step.p2midx = 0;
#endif
+ vcpu_unpause(v); /* guest will latch new state */
+
break;
- default: /* Excluded above */
- ASSERT_UNREACHABLE();
+ default:
return -ENOSYS;
}
- vcpu_unpause(v); /* guest will latch new state */
-
return rc;
}
diff --git a/xen/arch/x86/include/asm/hvm/hvm.h
b/xen/arch/x86/include/asm/hvm/hvm.h
index 1f0f7749b579..6efc533b35df 100644
--- a/xen/arch/x86/include/asm/hvm/hvm.h
+++ b/xen/arch/x86/include/asm/hvm/hvm.h
@@ -369,7 +369,8 @@ void *hvm_map_guest_frame_ro(unsigned long gfn, bool
permanent);
void hvm_unmap_guest_frame(void *p, bool permanent);
void hvm_mapped_guest_frames_mark_dirty(struct domain *d);
-int hvm_debug_op(struct vcpu *v, int32_t op);
+int hvm_debug_op(struct domain *d, unsigned int op, unsigned int vcpu,
+ unsigned int arg);
/* Caller should pause vcpu before calling this function */
void hvm_toggle_singlestep(struct vcpu *v);
diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h
index 4ca8a2d7ca65..546d9a8ac9c0 100644
--- a/xen/include/public/domctl.h
+++ b/xen/include/public/domctl.h
@@ -768,6 +768,7 @@ struct xen_domctl_subscribe {
struct xen_domctl_debug_op {
uint32_t op; /* IN */
uint32_t vcpu; /* IN */
+ uint32_t arg; /* IN */
};
/*
--
2.55.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |