|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [RFC PATCH v1 04/10] vpmu.c: factor out register conversion
A followup commit will use this to store the guest's regs when domid ==
DOMID_XEN.
To avoid code duplication move the code into a function.
No functional change.
Signed-off-by: Edwin Török <edwin.torok@xxxxxxxxx>
---
xen/arch/x86/cpu/vpmu.c | 49 ++++++++++++++++++++++-------------------
1 file changed, 26 insertions(+), 23 deletions(-)
diff --git a/xen/arch/x86/cpu/vpmu.c b/xen/arch/x86/cpu/vpmu.c
index 7be79c2d00..713311a1ac 100644
--- a/xen/arch/x86/cpu/vpmu.c
+++ b/xen/arch/x86/cpu/vpmu.c
@@ -160,6 +160,31 @@ static inline struct vcpu *choose_hwdom_vcpu(void)
return hardware_domain->vcpu[idx];
}
+static inline void vpmu_convert_regs(struct xen_pmu_regs *r, uint64_t *flags,
+ struct vcpu *sampled,
+ const struct cpu_user_regs *cur_regs) {
+ r->ip = cur_regs->rip;
+ r->sp = cur_regs->rsp;
+ r->flags = cur_regs->rflags;
+
+ if (!is_hvm_vcpu(sampled)) {
+ r->ss = cur_regs->ss;
+ r->cs = cur_regs->cs;
+ if (!(sampled->arch.flags & TF_kernel_mode))
+ *flags |= PMU_SAMPLE_USER;
+ } else {
+ struct segment_register seg;
+
+ hvm_get_segment_register(sampled, x86_seg_cs, &seg);
+ r->cs = seg.sel;
+ hvm_get_segment_register(sampled, x86_seg_ss, &seg);
+ r->ss = seg.sel;
+ r->cpl = seg.dpl;
+ if (!(sampled->arch.hvm.guest_cr[0] & X86_CR0_PE))
+ *flags |= PMU_SAMPLE_REAL;
+ }
+}
+
void vpmu_do_interrupt(void)
{
struct vcpu *sampled = current, *sampling;
@@ -255,29 +280,7 @@ void vpmu_do_interrupt(void)
else
cur_regs = guest_cpu_user_regs();
- r->ip = cur_regs->rip;
- r->sp = cur_regs->rsp;
- r->flags = cur_regs->rflags;
-
- if ( !is_hvm_vcpu(sampled) )
- {
- r->ss = cur_regs->ss;
- r->cs = cur_regs->cs;
- if ( !(sampled->arch.flags & TF_kernel_mode) )
- *flags |= PMU_SAMPLE_USER;
- }
- else
- {
- struct segment_register seg;
-
- hvm_get_segment_register(sampled, x86_seg_cs, &seg);
- r->cs = seg.sel;
- hvm_get_segment_register(sampled, x86_seg_ss, &seg);
- r->ss = seg.sel;
- r->cpl = seg.dpl;
- if ( !(sampled->arch.hvm.guest_cr[0] & X86_CR0_PE) )
- *flags |= PMU_SAMPLE_REAL;
- }
+ vpmu_convert_regs(r, flags, sampled, cur_regs);
}
vpmu->xenpmu_data->domain_id = domid;
--
2.47.1
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |