Vm-events: move monitor vm-events code to common code.
cover Vm-events: move monitor vm-events code to common code.
This patch series is an attempt to move (most) of the monitor vm-events code to the common-side.
Patches summary:
1. Move xen/arch/arm/hvm.c to xen/arch/arm/hvm/hvm.c
2. Merge almost identical functions hvm_event_int3 + This patch series is an attempt to move (most) of the monitor vm-events code to the common-side.
Patches summary:
1. Move xen/arch/arm/hvm.c to xen/arch/arm/hvm/hvm.c
2. Merge almost identical functions hvm_event_int3 + hvm_event_single_step -> hvm_event_software_breakpoint.
3. Add Kconfigs:
HAS_VM_EVENT_WRITE_CTRLREG, HAS_VM_EVENT_SINGLESTEP, HAS_VM_EVENT_SOFTWARE_BREAKPOINT, HAS_VM_EVENT_GUEST_REQUEST
and move monitor_domctl to common-side. Used the Kconfigs to selectively activate implemented monitor vm-events code for each architecture.
4. Some file renames. Read (*) below.
5. Move hvm_event_traps, hvm_event_cr, hvm_event_guest_request, hvm_event_software_breakpoint functions to common-side.
(note: arch_hvm_event_fill_regs on ARM-side will be implemented in a separate patch)
6. Some file renames, plus some minor fixes. Read (*) below.
7. Move monitor bitfield members from struct arch_domain to struct domain. Moved bits: single-step, software-breakpoint and guest-request. (note: write_ctrlreg_* were left on the arch-side, since control-registers number can vary across architectures)
(*) was only necessary to avoid git seeing a file as being modified, rather than moved (would have made the diff unnecessarily bulky).hvm_event_single_step -> hvm_event_software_breakpoint.
3. Add Kconfigs:
HAS_VM_EVENT_WRITE_CTRLREG, HAS_VM_EVENT_SINGLESTEP, HAS_VM_EVENT_SOFTWARE_BREAKPOINT, HAS_VM_EVENT_GUEST_REQUEST
and move monitor_domctl to common-side. Used the Kconfigs to selectively activate implemented monitor vm-events code for each architecture.
4. Some file renames. Read (*) below.
5. Move hvm_event_traps, hvm_event_cr, hvm_event_guest_request, hvm_event_software_breakpoint functions to common-side.
(note: arch_hvm_event_fill_regs on ARM-side will be implemented in a separate patch)
6. Some file renames, plus some minor fixes. Read (*) below.
7. Move monitor bitfield members from struct arch_domain to struct domain. Moved bits: single-step, software-breakpoint and guest-request. (note: write_ctrlreg_* were left on the arch-side, since control-registers number can vary across architectures)
(*) was only necessary to avoid git seeing a file as being modified, rather than moved (would have made the diff unnecessarily bulky).
PATCH 1/7 arm: move arch/arm/hvm.c to arch/arm/hvm/hvm.c
X86-side hvm.c is @ arch/x86/hvm/hvm.c. To maintain arm<->x86 symmetry, also move arch/arm/hvm.c to arch/arm/hvm/hvm.c.
--- xen/arch/arm/Makefile | 2 +- xen/arch/arm/hvm.c | 67 ----------------------------------------------- xen/arch/arm/hvm/Makefile | 1 + xen/arch/arm/hvm/hvm.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 68 deletions(-) delete mode 100644 xen/arch/arm/hvm.c create mode 100644 xen/arch/arm/hvm/Makefile create mode 100644 xen/arch/arm/hvm/hvm.c
xen/arch/arm/Makefile +1 -1
@@ -1,6 +1,7 @@ subdir-$(CONFIG_ARM_32) += arm32 subdir-$(CONFIG_ARM_64) += arm64 subdir-y += platforms +subdir-y += hvm subdir-$(CONFIG_ARM_64) += efi obj-$(EARLY_PRINTK) += early_printk.o
@@ -34,7 +35,6 @@ obj-y += vgic.o vgic-v2.o obj-$(CONFIG_ARM_64) += vgic-v3.o obj-y += vtimer.o obj-y += vuart.o -obj-y += hvm.o obj-y += device.o obj-y += decode.o obj-y += processor.o
xen/arch/arm/hvm.c deleted +0 -67
67 lines not on this page · raw message
xen/arch/arm/hvm/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-y += hvm.o
xen/arch/arm/hvm/hvm.c new file +66 -0
66 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH 2/7 x86: hvm events: merge 2 functions into 1
In reply to Corneliu ZUZUThis patch merges almost identical functions hvm_event_int3 and hvm_event_single_step into a single function called hvm_event_software_breakpoint.
--- xen/arch/x86/hvm/event.c | 52 ++++++++++++++--------------------------- xen/arch/x86/hvm/vmx/vmx.c | 11 +++++---- xen/include/asm-x86/hvm/event.h | 5 ++-- 3 files changed, 26 insertions(+), 42 deletions(-)
xen/arch/x86/hvm/event.c +18 -34
@@ -151,17 +151,20 @@ void hvm_event_guest_request(void) } } -int hvm_event_int3 (unsigned long rip) +int hvm_event_software_breakpoint (unsigned long rip,bool_t single_step) {int rc =0 ;struct vcpu *curr = current; +struct arch_domain *ad = &curr->domain->arch; +bool_t enabled = ( single_step ? ad->monitor.singlestep_enabled + : ad->monitor.software_breakpoint_enabled ); -if ( curr->domain->arch.monitor.software_breakpoint_enabled ) +if ( enabled ) { +uint64_t gfn;struct segment_register sreg;uint32_t pfec = PFEC_page_present | PFEC_insn_fetch;vm_event_request_t req = { - .reason =VM_EVENT_REASON_SOFTWARE_BREAKPOINT , .vcpu_id = curr->vcpu_id, };
@@ -170,37 +173,18 @@ int hvm_event_int3(unsigned long rip) pfec |= PFEC_user_mode;hvm_get_segment_register (curr, x86_seg_cs, &sreg); - req.u.software_breakpoint.gfn =paging_gva_to_gfn (curr, - sreg.base + rip, - &pfec); - - rc =hvm_event_traps (1 , &req); - } - -return rc; -} - -int hvm_event_single_step (unsigned long rip) -{ -int rc =0 ; -struct vcpu *curr = current; - -if ( curr->domain->arch.monitor.singlestep_enabled ) - { -struct segment_register sreg; -uint32_t pfec = PFEC_page_present | PFEC_insn_fetch; -vm_event_request_t req = { - .reason =VM_EVENT_REASON_SINGLESTEP , - .vcpu_id = curr->vcpu_id, - }; - -hvm_get_segment_register (curr, x86_seg_ss, &sreg); -if ( sreg.attr.fields.dpl ==3 ) - pfec |= PFEC_user_mode; - -hvm_get_segment_register (curr, x86_seg_cs, &sreg); - req.u.singlestep.gfn =paging_gva_to_gfn (curr, sreg.base + rip, - &pfec); + gfn =paging_gva_to_gfn (curr, sreg.base + rip, &pfec); + +if ( single_step ) + { + req.reason =VM_EVENT_REASON_SINGLESTEP ; + req.u.singlestep.gfn = gfn; + } +else + { + req.reason =VM_EVENT_REASON_SOFTWARE_BREAKPOINT ; + req.u.software_breakpoint.gfn = gfn; + } rc =hvm_event_traps (1 , &req); }
xen/arch/x86/hvm/vmx/vmx.c +6 -5
@@ -3192,7 +3192,7 @@ void vmx_vmexit_handler(struct cpu_user_regs *regs)break ; }else { -int handled =hvm_event_int3 (regs->eip); +int handled =hvm_event_software_breakpoint (regs->eip,0 );if ( handled <0 ) {
@@ -3517,10 +3517,11 @@ void vmx_vmexit_handler(struct cpu_user_regs *regs)case EXIT_REASON_MONITOR_TRAP_FLAG : v->arch.hvm_vmx.exec_control &= ~CPU_BASED_MONITOR_TRAP_FLAG ;vmx_update_cpu_exec_control (v); -if ( v->arch.hvm_vcpu.single_step ) { -hvm_event_single_step (regs->eip); -if ( v->domain->debugger_attached ) -domain_pause_for_debugger (); +if ( v->arch.hvm_vcpu.single_step ) + { +hvm_event_software_breakpoint (regs->eip,1 ); +if ( v->domain->debugger_attached ) +domain_pause_for_debugger (); }break ;
xen/include/asm-x86/hvm/event.h +2 -3
@@ -27,9 +27,8 @@ bool_t hvm_event_cr(unsigned int index, unsigned long value,#define hvm_event_crX (what, new, old) \ hvm_event_cr(VM_EVENT_X86_##what, new, old)void hvm_event_msr (unsigned int msr,uint64_t value); -/* Called for current VCPU: returns -1 if no listener */ -int hvm_event_int3 (unsigned long rip); -int hvm_event_single_step (unsigned long rip); +int hvm_event_software_breakpoint (unsigned long rip, +bool_t single_step);void hvm_event_guest_request (void );#endif /* __ASM_X86_HVM_EVENT_H__ */
Signature · 1 line
2.5.0
PATCH 3/7 xen/vm-events: Move monitor_domctl to common-side.
In reply to Corneliu ZUZU1. Kconfig:
* Added Kconfigs for common monitor vm-events:
# see files: common/Kconfig, x86/Kconfig
HAS_VM_EVENT_WRITE_CTRLREG
HAS_VM_EVENT_SINGLESTEP
HAS_VM_EVENT_SOFTWARE_BREAKPOINT
HAS_VM_EVENT_GUEST_REQUEST2. Moved monitor_domctl from arch-side to common-side 2.1. Moved arch/x86/monitor.c to common/monitor.c
# see files: arch/x86/Makefile, xen/common/Makefile, xen/common/monitor.c
# changes:
- removed status_check (we would have had to duplicate it in X86
arch_monitor_domctl_event otherwise)
- moved get_capabilities to arch-side (arch_monitor_get_capabilities)
- moved XEN_DOMCTL_MONITOR_OP_EMULATE_EACH_REP to arch-side (see
arch_monitor_domctl_op)
- put XEN_DOMCTL_MONITOR_EVENT_MOV_TO_MSR to x86-side (see
arch_monitor_domctl_event)
- surrounded switch cases w/ CONFIG_HAS_VM_EVENT_* 2.2. Moved asm-x86/monitor.h to xen/monitor.h
# see files: arch/x86/hvm/event.c, arch/x86/hvm/hvm.c,
arch/x86/hvm/vmx/vmx.c, xen/common/domctl.c 2.3. Removed asm-arm/monitor.h (no longer needed)
3. Added x86/monitor_x86.c => will rename in next commit to monitor.c (not done in this commit to avoid git seeing this as being the modified old monitor.c => keeping the same name would have rendered an unnecessarily bulky diff)
# see files: arch/x86/Makefile
# implements X86-side arch_monitor_domctl_event4. Added asm-x86/monitor_arch.h, asm-arm/monitor_arch.h (renamed to monitor.h in next commit, reason is the same as @ (3.).
# define/implement: arch_monitor_get_capabilities, arch_monitor_domctl_op
and arch_monitor_domctl_event
--- xen/arch/x86/Kconfig | 4 + xen/arch/x86/Makefile | 2 +- xen/arch/x86/hvm/event.c | 2 +- xen/arch/x86/hvm/hvm.c | 2 +- xen/arch/x86/hvm/vmx/vmx.c | 2 +- xen/arch/x86/monitor.c | 228 ------------------------------------- xen/arch/x86/monitor_x86.c | 72 ++++++++++++ xen/common/Kconfig | 20 ++++ xen/common/Makefile | 1 + xen/common/domctl.c | 2 +- xen/common/monitor.c | 203 +++++++++++++++++++++++++++++++++ xen/include/asm-arm/monitor.h | 33 ------ xen/include/asm-arm/monitor_arch.h | 53 +++++++++ xen/include/asm-x86/monitor.h | 31 ----- xen/include/asm-x86/monitor_arch.h | 74 ++++++++++++ xen/include/xen/monitor.h | 36 ++++++ 16 files changed, 468 insertions(+), 297 deletions(-) delete mode 100644 xen/arch/x86/monitor.c create mode 100644 xen/arch/x86/monitor_x86.c create mode 100644 xen/common/monitor.c delete mode 100644 xen/include/asm-arm/monitor.h create mode 100644 xen/include/asm-arm/monitor_arch.h delete mode 100644 xen/include/asm-x86/monitor.h create mode 100644 xen/include/asm-x86/monitor_arch.h create mode 100644 xen/include/xen/monitor.h
xen/arch/x86/Kconfig +4 -0
@@ -14,6 +14,10 @@ config X86 select HAS_MEM_ACCESS select HAS_MEM_PAGING select HAS_MEM_SHARING + select HAS_VM_EVENT_WRITE_CTRLREG + select HAS_VM_EVENT_SINGLESTEP + select HAS_VM_EVENT_SOFTWARE_BREAKPOINT + select HAS_VM_EVENT_GUEST_REQUEST select HAS_NS16550 select HAS_PASSTHROUGH select HAS_PCI
xen/arch/x86/Makefile +1 -1
@@ -36,7 +36,7 @@ obj-y += microcode_intel.o # This must come after the vendor specific files. obj-y += microcode.o obj-y += mm.o x86_64/mm.o -obj-y += monitor.o +obj-y += monitor_x86.o obj-y += mpparse.o obj-y += nmi.o obj-y += numa.o
xen/arch/x86/hvm/event.c +1 -1
@@ -20,8 +20,8 @@#include <xen/vm_event.h> #include <xen/paging.h> +#include <xen/monitor.h> #include <asm/hvm/event.h> -#include <asm/monitor.h> #include <asm/altp2m.h> #include <public/vm_event.h>
xen/arch/x86/hvm/hvm.c +1 -1
@@ -32,6 +32,7 @@#include <xen/guest_access.h> #include <xen/event.h> #include <xen/paging.h> +#include <xen/monitor.h> #include <xen/cpu.h> #include <xen/wait.h> #include <xen/mem_access.h>
@@ -51,7 +52,6 @@#include <asm/traps.h> #include <asm/mc146818rtc.h> #include <asm/mce.h> -#include <asm/monitor.h> #include <asm/hvm/hvm.h> #include <asm/hvm/vpt.h> #include <asm/hvm/support.h>
xen/arch/x86/hvm/vmx/vmx.c +1 -1
@@ -25,6 +25,7 @@#include <xen/domain_page.h> #include <xen/hypercall.h> #include <xen/perfc.h> +#include <xen/monitor.h> #include <asm/current.h> #include <asm/io.h> #include <asm/iocap.h>
@@ -57,7 +58,6 @@#include <asm/hvm/nestedhvm.h> #include <asm/altp2m.h> #include <asm/event.h> -#include <asm/monitor.h> #include <public/arch-x86/cpuid.h> static bool_t __initdata opt_force_ept;
xen/arch/x86/monitor.c deleted +0 -228
228 lines not on this page · raw message
xen/arch/x86/monitor_x86.c new file +72 -0
72 lines not on this page · raw message
xen/common/Kconfig +20 -0
@@ -36,6 +36,26 @@ config HAS_MEM_PAGING config HAS_MEM_SHARING bool +config HAS_VM_EVENT_WRITE_CTRLREG + bool + ---help--- + Select if ctrl-reg write monitor vm-events are supported + +config HAS_VM_EVENT_SINGLESTEP + bool + ---help--- + Select if single-step monitor vm-events are supported + +config HAS_VM_EVENT_SOFTWARE_BREAKPOINT + bool + ---help--- + Select if software-breakpoint monitor vm-events are supported + +config HAS_VM_EVENT_GUEST_REQUEST + bool + ---help--- + Select if guest-request monitor vm-events are supported + # Select HAS_PDX if PDX is supported config HAS_PDX bool
xen/common/Makefile +1 -0
@@ -20,6 +20,7 @@ obj-y += lib.o obj-y += lzo.o obj-$(CONFIG_HAS_MEM_ACCESS) += mem_access.o obj-y += memory.o +obj-y += monitor.o obj-y += multicall.o obj-y += notifier.o obj-y += page_alloc.o
xen/common/domctl.c +1 -1
@@ -25,11 +25,11 @@#include <xen/paging.h> #include <xen/hypercall.h> #include <xen/vm_event.h> +#include <xen/monitor.h> #include <asm/current.h> #include <asm/irq.h> #include <asm/page.h> #include <asm/p2m.h> -#include <asm/monitor.h> #include <public/domctl.h> #include <xsm/xsm.h>
xen/common/monitor.c new file +203 -0
203 lines not on this page · raw message
xen/include/asm-arm/monitor.h deleted +0 -33
@@ -1,33 +0,0 @@ -/* -* include/asm-arm/monitor.h -* -* Architecture-specific monitor_op domctl handler. -* -* Copyright (c) 2015 Tamas K Lengyel ([email protected]) -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public -* License v2 as published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* General Public License for more details. -* -* You should have received a copy of the GNU General Public -* License along with this program; If not, see <http://www.gnu.org/licenses/>. -*/ - -#ifndef __ASM_ARM_MONITOR_H__ -#define __ASM_ARM_MONITOR_H__ - -#include <xen/sched.h> -#include <public/domctl.h> - -static inline -int monitor_domctl (struct domain *d,struct xen_domctl_monitor_op *op) -{ -return -ENOSYS ; -} - -#endif /* __ASM_X86_MONITOR_H__ */
xen/include/asm-arm/monitor_arch.h new file +53 -0
53 lines not on this page · raw message
xen/include/asm-x86/monitor.h deleted +0 -31
@@ -1,31 +0,0 @@ -/* -* include/asm-x86/monitor.h -* -* Architecture-specific monitor_op domctl handler. -* -* Copyright (c) 2015 Tamas K Lengyel ([email protected]) -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public -* License v2 as published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* General Public License for more details. -* -* You should have received a copy of the GNU General Public -* License along with this program; If not, see <http://www.gnu.org/licenses/>. -*/ - -#ifndef __ASM_X86_MONITOR_H__ -#define __ASM_X86_MONITOR_H__ - -struct domain ; -struct xen_domctl_monitor_op ; - -#define monitor_ctrlreg_bitmask (ctrlreg_index) (1U << (ctrlreg_index)) - -int monitor_domctl (struct domain *d,struct xen_domctl_monitor_op *op); - -#endif /* __ASM_X86_MONITOR_H__ */
xen/include/asm-x86/monitor_arch.h new file +74 -0
74 lines not on this page · raw message
xen/include/xen/monitor.h new file +36 -0
@@ -0,0 +1,36 @@ +/* +* include/xen/monitor.h +* +* Common monitor_op domctl handler. +* +* Copyright (c) 2015 Tamas K Lengyel ([email protected]) +* Copyright (c) 2016, Bitdefender S.R.L. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public +* License v2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public +* License along with this program; If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef __MONITOR_H__ +#define __MONITOR_H__ + +#include <xen/sched.h> +#include <public/domctl.h> + +#if CONFIG_HAS_VM_EVENT_WRITE_CTRLREG + +#define monitor_ctrlreg_bitmask (ctrlreg_index) (1U << (ctrlreg_index)) + +#endif + +int monitor_domctl (struct domain *d,struct xen_domctl_monitor_op *op); + +#endif /* __MONITOR_H__ */
Signature · 1 line
2.5.0
PATCH 4/7 Rename monitor_x86.c to monitor.c and monitor_arch.h to monitor.h
In reply to Corneliu ZUZU(last commit before this one explains why this was necessary)
--- xen/arch/x86/Makefile | 2 +- xen/arch/x86/monitor.c | 72 +++++++++++++++++++++++++++++++++++++ xen/arch/x86/monitor_x86.c | 72 ------------------------------------- xen/common/monitor.c | 2 +- xen/include/asm-arm/monitor.h | 53 +++++++++++++++++++++++++++ xen/include/asm-arm/monitor_arch.h | 53 --------------------------- xen/include/asm-x86/monitor.h | 74 ++++++++++++++++++++++++++++++++++++++ xen/include/asm-x86/monitor_arch.h | 74 -------------------------------------- 8 files changed, 201 insertions(+), 201 deletions(-) create mode 100644 xen/arch/x86/monitor.c delete mode 100644 xen/arch/x86/monitor_x86.c create mode 100644 xen/include/asm-arm/monitor.h delete mode 100644 xen/include/asm-arm/monitor_arch.h create mode 100644 xen/include/asm-x86/monitor.h delete mode 100644 xen/include/asm-x86/monitor_arch.h
xen/arch/x86/Makefile +1 -1
@@ -36,7 +36,7 @@ obj-y += microcode_intel.o # This must come after the vendor specific files. obj-y += microcode.o obj-y += mm.o x86_64/mm.o -obj-y += monitor_x86.o +obj-y += monitor.o obj-y += mpparse.o obj-y += nmi.o obj-y += numa.o
xen/arch/x86/monitor.c new file +72 -0
72 lines not on this page · raw message
xen/arch/x86/monitor_x86.c deleted +0 -72
72 lines not on this page · raw message
xen/common/monitor.c +1 -1
@@ -25,7 +25,7 @@#include <xsm/xsm.h> #include <public/domctl.h> -#include <asm/monitor_arch.h> /* for monitor_arch_# */ +#include <asm/monitor.h> /* for monitor_arch_# */ #if CONFIG_X86 #include <public/vm_event.h> /* for VM_EVENT_X86_CR3 */
xen/include/asm-arm/monitor.h new file +53 -0
53 lines not on this page · raw message
xen/include/asm-arm/monitor_arch.h deleted +0 -53
53 lines not on this page · raw message
xen/include/asm-x86/monitor.h new file +74 -0
74 lines not on this page · raw message
xen/include/asm-x86/monitor_arch.h deleted +0 -74
74 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH 5/7 xen/vm-events: Move hvm_event_* functions to common-side.
In reply to Corneliu ZUZU1. Moved hvm_event_traps, hvm_event_cr, hvm_event_guest_request, hvm_event_software_breakpoint from arch-side to common-side
1.1. Moved arch/x86/hvm/event.c to common/hvm/event.c
# see files: arch/x86/hvm/Makefile, xen/common/hvm/Makefile, xen/common/hvm/event.c # changes: - moved hvm_event_fill_regs to arch-side (arch_hvm_event_fill_regs) - added vcpu parameter to hvm_event_traps - surrounded common hvm_event_* implementations w/ CONFIG_HAS_VM_EVENT_* - moved hvm_event_msr to arch-side (see x86/hvm/event_x86.c) - moved rip->gfn code in hvm_event_software_breakpoint to arch-side (see arch_hvm_event_gfn_of_ip) and renamed rip param to ip - i.e. now the parameter is a 'generic' instruction pointer, rather than the Intel X86_64 RIP register)
1.2. Moved asm-x86/hvm/event.h to xen/hvm/event.h
# see files: arch/x86/hvm/hvm.c, arch/x86/hvm/vmx/vmx.c
2. Added x86/hvm/event_x86.c => will rename in next commit to event.c (not done in this commit to avoid git seeing this as being the modified old event.c => keeping the same name would have rendered an unnecessarily bulky diff)
# see files: arch/x86/hvm/Makefile # implements X86-specific hvm_event_msr
3. Added asm-x86/hvm/event_arch.h, asm-arm/hvm/event_arch.h (renamed to event.h in next commit, reason is the same as @ (2.).
# define/implement: arch_hvm_event_fill_regs, arch_hvm_event_gfn_of_ip,
hvm_event_msr (X86 side only)
--- xen/arch/x86/hvm/Makefile | 2 +- xen/arch/x86/hvm/event.c | 203 ----------------------------------- xen/arch/x86/hvm/event_x86.c | 51 +++++++++ xen/arch/x86/hvm/hvm.c | 3 +- xen/arch/x86/hvm/vmx/vmx.c | 2 +- xen/common/hvm/Makefile | 1 + xen/common/hvm/event.c | 172 +++++++++++++++++++++++++++++ xen/include/asm-arm/hvm/event_arch.h | 40 +++++++ xen/include/asm-x86/hvm/event.h | 44 -------- xen/include/asm-x86/hvm/event_arch.h | 93 ++++++++++++++++ xen/include/xen/hvm/event.h | 71 ++++++++++++ 11 files changed, 432 insertions(+), 250 deletions(-) delete mode 100644 xen/arch/x86/hvm/event.c create mode 100644 xen/arch/x86/hvm/event_x86.c create mode 100644 xen/common/hvm/event.c create mode 100644 xen/include/asm-arm/hvm/event_arch.h delete mode 100644 xen/include/asm-x86/hvm/event.h create mode 100644 xen/include/asm-x86/hvm/event_arch.h create mode 100644 xen/include/xen/hvm/event.h
xen/arch/x86/hvm/Makefile +1 -1
@@ -3,7 +3,7 @@ subdir-y += vmx obj-y += asid.o obj-y += emulate.o -obj-y += event.o +obj-y += event_x86.o obj-y += hpet.o obj-y += hvm.o obj-y += i8254.o
xen/arch/x86/hvm/event.c deleted +0 -203
203 lines not on this page · raw message
xen/arch/x86/hvm/event_x86.c new file +51 -0
51 lines not on this page · raw message
xen/arch/x86/hvm/hvm.c +2 -1
@@ -33,6 +33,7 @@#include <xen/event.h> #include <xen/paging.h> #include <xen/monitor.h> +#include <xen/hvm/event.h> #include <xen/cpu.h> #include <xen/wait.h> #include <xen/mem_access.h>
@@ -58,7 +59,7 @@#include <asm/hvm/cacheattr.h> #include <asm/hvm/trace.h> #include <asm/hvm/nestedhvm.h> -#include <asm/hvm/event.h> +#include <asm/hvm/event_arch.h> #include <asm/hvm/vmx/vmx.h> #include <asm/hvm/svm/svm.h> /* for cpu_has_tsc_ratio */ #include <asm/altp2m.h>
xen/arch/x86/hvm/vmx/vmx.c +1 -1
@@ -26,6 +26,7 @@#include <xen/hypercall.h> #include <xen/perfc.h> #include <xen/monitor.h> +#include <xen/hvm/event.h> #include <asm/current.h> #include <asm/io.h> #include <asm/iocap.h>
@@ -51,7 +52,6 @@#include <asm/hvm/vpt.h> #include <public/hvm/save.h> #include <asm/hvm/trace.h> -#include <asm/hvm/event.h> #include <asm/xenoprof.h> #include <asm/debugger.h> #include <asm/apic.h>
xen/common/hvm/Makefile +1 -0
@@ -1 +1,2 @@ +obj-y += event.o obj-y += save.o
xen/common/hvm/event.c new file +172 -0
172 lines not on this page · raw message
xen/include/asm-arm/hvm/event_arch.h new file +40 -0
@@ -0,0 +1,40 @@ +/* +* include/asm-arm/hvm/event_arch.h +* +* Arch-specific hardware virtual machine event abstractions. +* +* Copyright (c) 2016, Bitdefender S.R.L. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program; If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef __ASM_ARM_HVM_EVENT_ARCH_H__ +#define __ASM_ARM_HVM_EVENT_ARCH_H__ + +static inline +void arch_hvm_event_fill_regs (vm_event_request_t *req) +{ +/* Not supported on ARM. */ +} + +#endif /* __ASM_ARM_HVM_EVENT_ARCH_H__ */ + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* tab-width: 4 +* indent-tabs-mode: nil +* End: +*/
xen/include/asm-x86/hvm/event.h deleted +0 -44
44 lines not on this page · raw message
xen/include/asm-x86/hvm/event_arch.h new file +93 -0
93 lines not on this page · raw message
xen/include/xen/hvm/event.h new file +71 -0
71 lines not on this page · raw message
Signature · 1 line
2.5.0
PATCH 6/7 Rename event_x86.c to event.c and event_arch.h to event.h + minor fixes
In reply to Corneliu ZUZU* rename arch/x86/hvm/event_x86.c to arch/x86/hvm/event.c and
asm-{x86,arm}/hvm/event_arch.h to asm-{x86/arm}/hvm/event.h (last commit
before this one explains why this was necessary)Minor fixes:
* ARM fix: xen/common/hvm/event.c was not actually compiled
(see file-changes: xen/common/Makefile, xen/common/hvm/Makefile)
* xen/common/hvm/event.c: fix malformed file header comment
* xen/hvm/event.h: fix comment & change hvm_event_crX first param name to a more descriptive one
--- xen/arch/x86/hvm/Makefile | 2 +- xen/arch/x86/hvm/event.c | 51 ++++++++++++++++++++ xen/arch/x86/hvm/event_x86.c | 51 -------------------- xen/arch/x86/hvm/hvm.c | 2 +- xen/common/Makefile | 2 +- xen/common/hvm/Makefile | 2 +- xen/common/hvm/event.c | 44 ++++++++--------- xen/include/asm-arm/hvm/event.h | 40 ++++++++++++++++ xen/include/asm-arm/hvm/event_arch.h | 40 ---------------- xen/include/asm-x86/hvm/event.h | 93 ++++++++++++++++++++++++++++++++++++ xen/include/asm-x86/hvm/event_arch.h | 93 ------------------------------------ xen/include/xen/hvm/event.h | 6 +-- 12 files changed, 213 insertions(+), 213 deletions(-) create mode 100644 xen/arch/x86/hvm/event.c delete mode 100644 xen/arch/x86/hvm/event_x86.c create mode 100644 xen/include/asm-arm/hvm/event.h delete mode 100644 xen/include/asm-arm/hvm/event_arch.h create mode 100644 xen/include/asm-x86/hvm/event.h delete mode 100644 xen/include/asm-x86/hvm/event_arch.h
xen/arch/x86/hvm/Makefile +1 -1
@@ -3,7 +3,7 @@ subdir-y += vmx obj-y += asid.o obj-y += emulate.o -obj-y += event_x86.o +obj-y += event.o obj-y += hpet.o obj-y += hvm.o obj-y += i8254.o
xen/arch/x86/hvm/event.c new file +51 -0
51 lines not on this page · raw message
xen/arch/x86/hvm/event_x86.c deleted +0 -51
51 lines not on this page · raw message
xen/arch/x86/hvm/hvm.c +1 -1
@@ -59,7 +59,7 @@#include <asm/hvm/cacheattr.h> #include <asm/hvm/trace.h> #include <asm/hvm/nestedhvm.h> -#include <asm/hvm/event_arch.h> +#include <asm/hvm/event.h> #include <asm/hvm/vmx/vmx.h> #include <asm/hvm/svm/svm.h> /* for cpu_has_tsc_ratio */ #include <asm/altp2m.h>
xen/common/Makefile +1 -1
@@ -67,7 +67,7 @@ obj-$(xenoprof) += xenoprof.o obj-$(CONFIG_COMPAT) += $(addprefix compat/,domain.o kernel.o memory.o multicall.o tmem_xen.o xlat.o) -subdir-$(CONFIG_X86) += hvm +subdir-y += hvm subdir-$(coverage) += gcov
xen/common/hvm/Makefile +1 -1
@@ -1,2 +1,2 @@ obj-y += event.o -obj-y += save.o +obj-$(CONFIG_X86) += save.o
xen/common/hvm/event.c +22 -22
52 lines not on this page · raw message
xen/include/asm-arm/hvm/event.h new file +40 -0
@@ -0,0 +1,40 @@ +/* +* include/asm-arm/hvm/event.h +* +* Arch-specific hardware virtual machine event abstractions. +* +* Copyright (c) 2016, Bitdefender S.R.L. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program; If not, see <http://www.gnu.org/licenses/>. +*/ + +#ifndef __ASM_ARM_HVM_EVENT_H__ +#define __ASM_ARM_HVM_EVENT_H__ + +static inline +void arch_hvm_event_fill_regs (vm_event_request_t *req) +{ +/* Not supported on ARM. */ +} + +#endif /* __ASM_ARM_HVM_EVENT_H__ */ + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* tab-width: 4 +* indent-tabs-mode: nil +* End: +*/
xen/include/asm-arm/hvm/event_arch.h deleted +0 -40
@@ -1,40 +0,0 @@ -/* -* include/asm-arm/hvm/event_arch.h -* -* Arch-specific hardware virtual machine event abstractions. -* -* Copyright (c) 2016, Bitdefender S.R.L. -* -* This program is free software; you can redistribute it and/or modify it -* under the terms and conditions of the GNU General Public License, -* version 2, as published by the Free Software Foundation. -* -* This program is distributed in the hope it will be useful, but WITHOUT -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -* more details. -* -* You should have received a copy of the GNU General Public License along with -* this program; If not, see <http://www.gnu.org/licenses/>. -*/ - -#ifndef __ASM_ARM_HVM_EVENT_ARCH_H__ -#define __ASM_ARM_HVM_EVENT_ARCH_H__ - -static inline -void arch_hvm_event_fill_regs (vm_event_request_t *req) -{ -/* Not supported on ARM. */ -} - -#endif /* __ASM_ARM_HVM_EVENT_ARCH_H__ */ - -/* -* Local variables: -* mode: C -* c-file-style: "BSD" -* c-basic-offset: 4 -* tab-width: 4 -* indent-tabs-mode: nil -* End: -*/
xen/include/asm-x86/hvm/event.h new file +93 -0
93 lines not on this page · raw message
xen/include/asm-x86/hvm/event_arch.h deleted +0 -93
93 lines not on this page · raw message
xen/include/xen/hvm/event.h +3 -3
@@ -27,7 +27,7 @@#if CONFIG_HAS_VM_EVENT_WRITE_CTRLREG /* -* Called for current VCPU on crX/MSR changes by guest. +* Called for current VCPU on control-register changes by guest. * The event might not fire if the client has subscribed to it in onchangeonly * mode, hence the bool_t return type for control register write events. */
@@ -36,8 +36,8 @@ bool_t hvm_event_cr(unsigned int index, unsigned long old);#if CONFIG_X86 -#define hvm_event_crX (what, new, old) \ - hvm_event_cr(VM_EVENT_X86_##what, new, old) +#define hvm_event_crX (cr, new, old) \ + hvm_event_cr(VM_EVENT_X86_##cr, new, old)#endif #endif // HAS_VM_EVENT_WRITE_CTRLREG
Signature · 1 line
2.5.0
PATCH 7/7 arch.monitor: move bits to common (arch_domain to domain)
In reply to Corneliu ZUZUThis patch moves bitfield members for single-step, software-breakpoint and guest-request monitor vm-events from the arch-side (struct arch_domain) to the common-side (struct domain). Ctrl-reg bits (i.e. write_ctrlreg_* members) are left on the arch-side, because control-registers number can vary across architectures.
--- xen/arch/x86/hvm/vmx/vmcs.c | 4 ++-- xen/common/hvm/event.c | 12 ++++++------ xen/common/monitor.c | 17 +++++++---------- xen/include/asm-x86/domain.h | 16 ++++++---------- xen/include/xen/sched.h | 16 ++++++++++++++++ 5 files changed, 37 insertions(+), 28 deletions(-)
xen/arch/x86/hvm/vmx/vmcs.c +2 -2
@@ -1706,8 +1706,8 @@ void vmx_do_resume(struct vcpu *v) } debug_state = v->domain->debugger_attached - || v->domain->arch.monitor.software_breakpoint_enabled - || v->domain->arch.monitor.singlestep_enabled; + || v->domain->monitor.software_breakpoint_enabled + || v->domain->monitor.singlestep_enabled;if (unlikely (v->arch.hvm_vcpu.debug_state_latch != debug_state) ) {
xen/common/hvm/event.c +6 -6
@@ -110,16 +110,16 @@ bool_t hvm_event_cr(unsigned int index,void hvm_event_guest_request (void ) {struct vcpu *curr = current; -struct arch_domain *ad = &curr->domain->arch; +struct domain *d = curr->domain; -if ( ad->monitor.guest_request_enabled ) +if ( d->monitor.guest_request_enabled ) {vm_event_request_t req = { .reason =VM_EVENT_REASON_GUEST_REQUEST , .vcpu_id = curr->vcpu_id, }; -hvm_event_traps (curr, ad->monitor.guest_request_sync, &req); +hvm_event_traps (curr, d->monitor.guest_request_sync, &req); } }
@@ -131,9 +131,9 @@ int hvm_event_software_breakpoint(unsigned long ip, bool_t single_step) {int rc =0 ;struct vcpu *curr = current; -struct arch_domain *ad = &curr->domain->arch; -bool_t enabled = ( single_step ? ad->monitor.singlestep_enabled - : ad->monitor.software_breakpoint_enabled ); +struct domain *d = curr->domain; +bool_t enabled = ( single_step ? d->monitor.singlestep_enabled + : d->monitor.software_breakpoint_enabled );if ( enabled ) {
xen/common/monitor.c +7 -10
@@ -121,14 +121,13 @@ int monitor_domctl(struct domain *d, struct xen_domctl_monitor_op *mop)case XEN_DOMCTL_MONITOR_EVENT_SINGLESTEP : { -struct arch_domain *ad = &d->arch; -bool_t old_status = ad->monitor.singlestep_enabled; +bool_t old_status = d->monitor.singlestep_enabled;if (unlikely (old_status == requested_status) )return -EEXIST ;domain_pause (d); - ad->monitor.singlestep_enabled = !old_status; + d->monitor.singlestep_enabled = !old_status;domain_unpause (d);break ; }
@@ -139,14 +138,13 @@ int monitor_domctl(struct domain *d, struct xen_domctl_monitor_op *mop)case XEN_DOMCTL_MONITOR_EVENT_SOFTWARE_BREAKPOINT : { -struct arch_domain *ad = &d->arch; -bool_t old_status = ad->monitor.software_breakpoint_enabled; +bool_t old_status = d->monitor.software_breakpoint_enabled;if (unlikely (old_status == requested_status) )return -EEXIST ;domain_pause (d); - ad->monitor.software_breakpoint_enabled = !old_status; + d->monitor.software_breakpoint_enabled = !old_status;domain_unpause (d);break ; }
@@ -157,15 +155,14 @@ int monitor_domctl(struct domain *d, struct xen_domctl_monitor_op *mop)case XEN_DOMCTL_MONITOR_EVENT_GUEST_REQUEST : { -struct arch_domain *ad = &d->arch; -bool_t old_status = ad->monitor.guest_request_enabled; +bool_t old_status = d->monitor.guest_request_enabled;if (unlikely (old_status == requested_status) )return -EEXIST ;domain_pause (d); - ad->monitor.guest_request_sync = mop->u.guest_request.sync; - ad->monitor.guest_request_enabled = !old_status; + d->monitor.guest_request_sync = mop->u.guest_request.sync; + d->monitor.guest_request_enabled = !old_status;domain_unpause (d);break ; }
xen/include/asm-x86/domain.h +6 -10
@@ -376,17 +376,13 @@ struct arch_domainunsigned long *pirq_eoi_map;unsigned long pirq_eoi_map_mfn; -/* Monitor options */ +/* Arch-specific monitor vm-event options */ struct { -unsigned int write_ctrlreg_enabled :4 ; -unsigned int write_ctrlreg_sync :4 ; -unsigned int write_ctrlreg_onchangeonly :4 ; -unsigned int mov_to_msr_enabled :1 ; -unsigned int mov_to_msr_extended :1 ; -unsigned int singlestep_enabled :1 ; -unsigned int software_breakpoint_enabled :1 ; -unsigned int guest_request_enabled :1 ; -unsigned int guest_request_sync :1 ; +uint16_t write_ctrlreg_enabled :4 ; +uint16_t write_ctrlreg_sync :4 ; +uint16_t write_ctrlreg_onchangeonly :4 ; +uint16_t mov_to_msr_enabled :1 ; +uint16_t mov_to_msr_extended :1 ; } monitor;/* Mem_access emulation control */
xen/include/xen/sched.h +16 -0
@@ -464,6 +464,22 @@ struct domain/* vNUMA topology accesses are protected by rwlock. */ rwlock_t vnuma_rwlock;struct vnuma_info *vnuma; + +/* Common monitor vm-events options */ +struct { +#if CONFIG_HAS_VM_EVENT_SINGLESTEP +uint8_t singlestep_enabled :1 ; +#endif // HAS_VM_EVENT_SINGLESTEP + +#if CONFIG_HAS_VM_EVENT_SOFTWARE_BREAKPOINT +uint8_t software_breakpoint_enabled :1 ; +#endif // HAS_VM_EVENT_SOFTWARE_BREAKPOINT + +#if CONFIG_HAS_VM_EVENT_GUEST_REQUEST +uint8_t guest_request_enabled :1 ; +uint8_t guest_request_sync :1 ; +#endif // HAS_VM_EVENT_GUEST_REQUEST + } monitor; };/* Protect updates/reads (resp.) of domain_list and domain_hash. */
Signature · 1 line
2.5.0
Re: [PATCH 1/7] arm: move arch/arm/hvm.c to arch/arm/hvm/hvm.c
In reply to Corneliu ZUZUQuoted 4 lines · Corneliu ZUZU
X86-side
hvm.cis @arch/x86/hvm/hvm.c. To maintain arm<->x86 symmetry, also movearch/arm/hvm.ctoarch/arm/hvm/hvm.c.Signed-off-by Corneliu ZUZU <[email protected]>
For future reference, constructing your patches with -M (detect renames) makes reviews of patches like this far easier.
While you are editing this file, please put a local variable block on the bottom of the file. See the final section of CODING_STYLE in the root.
~Andrew
Quoted 30 lines · Corneliu ZUZU
This patch series is an attempt to move (most) of the monitor vm-events code to the common-side.
Patches summary:
1. Move
xen/arch/arm/hvm.ctoxen/arch/arm/hvm/hvm.c2. Merge almost identical functions
hvm_event_int3+hvm_event_single_step->hvm_event_software_breakpoint.3. Add Kconfigs:
HAS_VM_EVENT_WRITE_CTRLREG,HAS_VM_EVENT_SINGLESTEP,HAS_VM_EVENT_SOFTWARE_BREAKPOINT,HAS_VM_EVENT_GUEST_REQUEST
and movemonitor_domctlto common-side. Used the Kconfigs to selectively activate implemented monitor vm-events code for each architecture.4. Some file renames. Read (*) below.
5. Move
hvm_event_traps,hvm_event_cr,hvm_event_guest_request,hvm_event_software_breakpointfunctions to common-side.
(note:arch_hvm_event_fill_regson ARM-side will be implemented in a separate patch)6. Some file renames, plus some minor fixes. Read (*) below.
7. Move monitor bitfield members from struct
arch_domainto struct domain. Moved bits: single-step, software-breakpoint and guest-request. (note: write_ctrlreg_* were left on the arch-side, since control-registers number can vary across architectures)
Quoted 7 lines
(*) was only necessary to avoid git seeing a file as being modified, rather than moved (would have made the diff unnecessarily bulky).
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Somehow git send-email managed to malform the introductory message. Corrections made, read above instead :)
Re: [PATCH 1/7] arm: move arch/arm/hvm.c to arch/arm/hvm/hvm.c
In reply to Andrew CooperQuoted 4 lines · Andrew Cooper
Quoted 3 lines · Corneliu ZUZU
X86-side
hvm.cis @arch/x86/hvm/hvm.c. To maintain arm<->x86 symmetry, also movearch/arm/hvm.ctoarch/arm/hvm/hvm.c.
Quoted 9 lines
Quoted 1 line
Signed-off-by Corneliu ZUZU <[email protected]>For future reference, constructing your patches with -M (detect renames) makes reviews of patches like this far easier.
While you are editing this file, please put a local variable block on the bottom of the file. See the final section of
CODING_STYLEin the root.~Andrew
I'm really sorry, I forgot, I was actually *counting* on that option, wanted to use it as -M40% actually. And I really don't get why git malformed the introductory message. Since the diffs would indeed look *much* better w/ the -M option and I should also add the variable block @ the end of that file (which was originally missing) would it be advised to resend this series?
Corneliu.
Re: [PATCH 1/7] arm: move arch/arm/hvm.c to arch/arm/hvm/hvm.c
Quoted 15 lines · Corneliu ZUZU
Quoted 5 lines · Andrew Cooper
Quoted 4 lines · Corneliu ZUZU
X86-side
hvm.cis @arch/x86/hvm/hvm.c. To maintain arm<->x86 symmetry, also movearch/arm/hvm.ctoarch/arm/hvm/hvm.c.Signed-off-by Corneliu ZUZU <[email protected]>Quoted 9 lines
For future reference, constructing your patches with -M (detect renames) makes reviews of patches like this far easier.
While you are editing this file, please put a local variable block on the bottom of the file. See the final section of
CODING_STYLEin the root.~Andrew
Quoted 9 lines
I'm really sorry, I forgot, I was actually *counting* on that option, wanted to use it as -M40%
actually. And I really don't get why git malformed the introductory message.
Since the diffs would indeed look *much* better w/ the -M option and I should also add
the variable block @ the end of that file (which was originally missing) would it be advised to
resend this series?
I would wait for some other review first. There are some useful comments to be given even with the series like this.
~Andrew
Re: [PATCH 2/7] x86: hvm events: merge 2 functions into 1
In reply to Corneliu ZUZUxen/include/asm-x86/hvm/event.h bool_t hvm_event_cr(unsigned int index, unsigned long value, · line 31
Quoted 13 lines · Corneliu ZUZU
xen/include/asm-x86/hvm/event.h +2
-3@@ -27,9 +27,8 @@ bool_t hvm_event_cr(unsigned int index, unsigned long value,#define hvm_event_crX (what, new, old) \ hvm_event_cr(VM_EVENT_X86_##what, new, old)void hvm_event_msr (unsigned int msr,uint64_t value); -/* Called for current VCPU: returns -1 if no listener */ -int hvm_event_int3 (unsigned long rip); -int hvm_event_single_step (unsigned long rip); +int hvm_event_software_breakpoint (unsigned long rip, +bool_t single_step);
Are we liable to ever gain any other type of software breakpoint? Might it be more sense to pass an enum rather than a bool here?
Otherwise, the changes look sensible.
~Andrew
Re: [PATCH 2/7] x86: hvm events: merge 2 functions into 1
Quoted 8 lines · Andrew Cooper
Review
Quoted 1 line · Corneliu ZUZU
(quoted diff) +0
-0
b/xen/include/asm-x86/hvm/event.hxen/include/asm-x86/hvm/event.h bool_t hvm_event_cr(unsigned int index, unsigned long
Quoted 4 lines
index 11eb1fe..7c2252b 100644
xen/include/asm-x86/hvm/event.h +0
-0@@ -27,9 +27,8 @@ bool_t hvm_event_cr(unsigned int index, unsigned longvalue,
Quoted 12 lines
xen/include/asm-x86/hvm/event.h bool_t hvm_event_cr(unsigned int index, unsigned long value, · line 31
Quoted 8 lines
xen/include/asm-x86/hvm/event.h +2
-3#define hvm_event_crX (what, new, old) \ hvm_event_cr(VM_EVENT_X86_##what, new, old)void hvm_event_msr (unsigned int msr,uint64_t value); -/* Called for current VCPU: returns -1 if no listener */ -int hvm_event_int3 (unsigned long rip); -int hvm_event_single_step (unsigned long rip); +int hvm_event_software_breakpoint (unsigned long rip, +bool_t single_step);Are we liable to ever gain any other type of software breakpoint? Might it be more sense to pass an enum rather than a bool here?
Exactly what I was thinking, that would make the code somewhat more readable.
Tamas
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 2/7] x86: hvm events: merge 2 functions into 1
In reply to Andrew CooperQuoted 17 lines · Andrew Cooper
xen/include/asm-x86/hvm/event.h bool_t hvm_event_cr(unsigned int index, unsigned long value, · line 31
Quoted 13 lines · Corneliu ZUZU
xen/include/asm-x86/hvm/event.h +2
-3@@ -27,9 +27,8 @@ bool_t hvm_event_cr(unsigned int index, unsigned long value,#define hvm_event_crX (what, new, old) \ hvm_event_cr(VM_EVENT_X86_##what, new, old)void hvm_event_msr (unsigned int msr,uint64_t value); -/* Called for current VCPU: returns -1 if no listener */ -int hvm_event_int3 (unsigned long rip); -int hvm_event_single_step (unsigned long rip); +int hvm_event_software_breakpoint (unsigned long rip, +bool_t single_step);Are we liable to ever gain any other type of software breakpoint? Might it be more sense to pass an enum rather than a bool here?
Quoted 4 lines
Otherwise, the changes look sensible.
~Andrew
Well, IMHO, no. Besides breakpointing/trapping after each instruction (i.e. VM_EVENT_REASON_SINGLESTEP) and on arbitrary instructions (VM_EVENT_REASON_SOFTWARE_BREAKPOINT) I don't see what other types of breakpointing one can define (at least from the hypervisor's point of view), and if in the future there will be other types, that could also be changed into an enum then.
But making that param an enum now would also be fine by me.
Since I noticed Tamas also prefers this option, I will make that change.
Corneliu.
Re: [PATCH 3/7] xen/vm-events: Move monitor_domctl to common-side.
In reply to Corneliu ZUZUQuoted 556 lines · Corneliu ZUZU
1.
Kconfig:
* Added Kconfigs for common monitor vm-events:# see files: common/Kconfig, x86/Kconfig HAS_VM_EVENT_WRITE_CTRLREG HAS_VM_EVENT_SINGLESTEP HAS_VM_EVENT_SOFTWARE_BREAKPOINT HAS_VM_EVENT_GUEST_REQUEST2. Moved
monitor_domctlfrom arch-side to common-side 2.1. Movedarch/x86/monitor.ctocommon/monitor.c# see files: arch/x86/Makefile, xen/common/Makefile, xen/common/monitor.c # changes: - removed status_check (we would have had to duplicate it in X86 arch_monitor_domctl_event otherwise) - moved get_capabilities to arch-side (arch_monitor_get_capabilities) - moved XEN_DOMCTL_MONITOR_OP_EMULATE_EACH_REP to arch-side (see arch_monitor_domctl_op) - put XEN_DOMCTL_MONITOR_EVENT_MOV_TO_MSR to x86-side (see arch_monitor_domctl_event) - surrounded switch cases w/ CONFIG_HAS_VM_EVENT_*2.2. Moved
asm-x86/monitor.htoxen/monitor.h# see files: arch/x86/hvm/event.c, arch/x86/hvm/hvm.c, arch/x86/hvm/vmx/vmx.c, xen/common/domctl.c2.3. Removed
asm-arm/monitor.h(no longer needed)3. Added
x86/monitor_x86.c=> will rename in next commit tomonitor.c(not done
in this commit to avoid git seeing this as being the modified oldmonitor.c=>
keeping the same name would have rendered an unnecessarily bulky diff)# see files: arch/x86/Makefile # implements X86-side arch_monitor_domctl_event4. Added
asm-x86/monitor_arch.h,asm-arm/monitor_arch.h(renamed tomonitor.hin next commit, reason is the same as @ (3.). # define/implement:arch_monitor_get_capabilities,arch_monitor_domctl_op
andarch_monitor_domctl_eventSigned-off-by Corneliu ZUZU <[email protected]>--- xen/arch/x86/Kconfig | 4 + xen/arch/x86/Makefile | 2 +- xen/arch/x86/hvm/event.c | 2 +- xen/arch/x86/hvm/hvm.c | 2 +- xen/arch/x86/hvm/vmx/vmx.c | 2 +- xen/arch/x86/monitor.c | 228 ------------------------------------- xen/arch/x86/monitor_x86.c | 72 ++++++++++++ xen/common/Kconfig | 20 ++++ xen/common/Makefile | 1 + xen/common/domctl.c | 2 +- xen/common/monitor.c | 203 +++++++++++++++++++++++++++++++++ xen/include/asm-arm/monitor.h | 33 ------ xen/include/asm-arm/monitor_arch.h | 53 +++++++++ xen/include/asm-x86/monitor.h | 31 ----- xen/include/asm-x86/monitor_arch.h | 74 ++++++++++++ xen/include/xen/monitor.h | 36 ++++++ 16 files changed, 468 insertions(+), 297 deletions(-) delete mode 100644 xen/arch/x86/monitor.c create mode 100644 xen/arch/x86/monitor_x86.c create mode 100644 xen/common/monitor.c delete mode 100644 xen/include/asm-arm/monitor.h create mode 100644 xen/include/asm-arm/monitor_arch.h delete mode 100644 xen/include/asm-x86/monitor.h create mode 100644 xen/include/asm-x86/monitor_arch.h create mode 100644 xen/include/xen/monitor.hxen/arch/x86/Kconfig +4
-0@@ -14,6 +14,10 @@ config X86 select HAS_MEM_ACCESS select HAS_MEM_PAGING select HAS_MEM_SHARING + select HAS_VM_EVENT_WRITE_CTRLREG + select HAS_VM_EVENT_SINGLESTEP + select HAS_VM_EVENT_SOFTWARE_BREAKPOINT + select HAS_VM_EVENT_GUEST_REQUEST select HAS_NS16550 select HAS_PASSTHROUGH select HAS_PCIxen/arch/x86/Makefile +1
-1@@ -36,7 +36,7 @@ obj-y += microcode_intel.o # This must come after the vendor specific files. obj-y += microcode.o obj-y += mm.o x86_64/mm.o -obj-y += monitor.o +obj-y += monitor_x86.o obj-y += mpparse.o obj-y += nmi.o obj-y += numa.oxen/arch/x86/hvm/event.c +1
-1@@ -20,8 +20,8 @@#include <xen/vm_event.h> #include <xen/paging.h> +#include <xen/monitor.h> #include <asm/hvm/event.h> -#include <asm/monitor.h> #include <asm/altp2m.h> #include <public/vm_event.h> xen/arch/x86/hvm/hvm.c +1
-1@@ -32,6 +32,7 @@#include <xen/guest_access.h> #include <xen/event.h> #include <xen/paging.h> +#include <xen/monitor.h> #include <xen/cpu.h> #include <xen/wait.h> #include <xen/mem_access.h> @@ -51,7 +52,6 @@#include <asm/traps.h> #include <asm/mc146818rtc.h> #include <asm/mce.h> -#include <asm/monitor.h> #include <asm/hvm/hvm.h> #include <asm/hvm/vpt.h> #include <asm/hvm/support.h> xen/arch/x86/hvm/vmx/vmx.c +1
-1@@ -25,6 +25,7 @@#include <xen/domain_page.h> #include <xen/hypercall.h> #include <xen/perfc.h> +#include <xen/monitor.h> #include <asm/current.h> #include <asm/io.h> #include <asm/iocap.h> @@ -57,7 +58,6 @@#include <asm/hvm/nestedhvm.h> #include <asm/altp2m.h> #include <asm/event.h> -#include <asm/monitor.h> #include <public/arch-x86/cpuid.h> static bool_t __initdata opt_force_ept;xen/arch/x86/monitor.c deleted +0
-18@@ -1,228 +0,0 @@ -/* -* arch/x86/monitor.c -* -* Architecture-specific monitor_op domctl handler. -* -* Copyright (c) 2015 Tamas K Lengyel ([email protected]) -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public -* License v2 as published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* General Public License for more details. -* -* You should have received a copy of the GNU General Public -* License along with this program; If not, see < http://www.gnu.org/licenses/>.
- */xen/arch/x86/monitor.c deleted +0
-209- -#include <xen/config.h> -#include <xen/sched.h> -#include <xen/mm.h> -#include <asm/domain.h> -#include <asm/monitor.h> -#include <public/domctl.h> -#include <xsm/xsm.h> - -/* -* Sanity check whether option is already enabled/disabled -*/ -static inline -int status_check (struct xen_domctl_monitor_op *mop,bool_t status) -{ -bool_t requested_status = (mop->op ==XEN_DOMCTL_MONITOR_OP_ENABLE ); - -if ( status == requested_status ) -return -EEXIST ; - -return 0 ; -} - -static inline uint32_t get_capabilities (struct domain *d) -{ -uint32_t capabilities =0 ; - -/* -* At the moment only Intel HVM domains are supported. However, event -* delivery could be extended to AMD and PV domains. -*/ -if ( !is_hvm_domain (d) || !cpu_has_vmx ) -return capabilities; - - capabilities = (1 <<XEN_DOMCTL_MONITOR_EVENT_WRITE_CTRLREG ) | - (1 <<XEN_DOMCTL_MONITOR_EVENT_MOV_TO_MSR ) | - (1 <<XEN_DOMCTL_MONITOR_EVENT_SOFTWARE_BREAKPOINT ) | - (1 <<XEN_DOMCTL_MONITOR_EVENT_GUEST_REQUEST ); - -/* Since we know this is on VMX, we can just call the hvm func */ -if (hvm_is_singlestep_supported () ) - capabilities |= (1 <<XEN_DOMCTL_MONITOR_EVENT_SINGLESTEP ); - -return capabilities; -} - -int monitor_domctl (struct domain *d,struct xen_domctl_monitor_op *mop) -{ -int rc; -struct arch_domain *ad = &d->arch; -uint32_t capabilities =get_capabilities (d); - -if ( current->domain == d )/* no domain_pause() */ -return -EPERM ; - - rc =xsm_vm_event_control (XSM_PRIV , d, mop->op, mop->event); -if ( rc ) -return rc; - -switch ( mop->op ) - { -case XEN_DOMCTL_MONITOR_OP_GET_CAPABILITIES : - mop->event = capabilities; -return 0 ; - -case XEN_DOMCTL_MONITOR_OP_EMULATE_EACH_REP : -domain_pause (d); - ad->mem_access_emulate_each_rep = !!mop->event; -domain_unpause (d); -return 0 ; - } - -/* -* Sanity check -*/ -if ( mop->op !=XEN_DOMCTL_MONITOR_OP_ENABLE && - mop->op !=XEN_DOMCTL_MONITOR_OP_DISABLE ) -return -EOPNOTSUPP ; - -/* Check if event type is available. */ -if ( !(capabilities & (1 << mop->event)) ) -return -EOPNOTSUPP ; - -switch ( mop->event ) - { -case XEN_DOMCTL_MONITOR_EVENT_WRITE_CTRLREG : - { -unsigned int ctrlreg_bitmask = -monitor_ctrlreg_bitmask (mop->u.mov_to_cr.index); -bool_t status = - !!(ad->monitor.write_ctrlreg_enabled & ctrlreg_bitmask); -struct vcpu *v; - - rc =status_check (mop, status); -if ( rc ) -return rc; - -domain_pause (d); - -if ( mop->u.mov_to_cr.sync ) - ad->monitor.write_ctrlreg_sync |= ctrlreg_bitmask; -else - ad->monitor.write_ctrlreg_sync &= ~ctrlreg_bitmask; - -if ( mop->u.mov_to_cr.onchangeonly ) - ad->monitor.write_ctrlreg_onchangeonly |= ctrlreg_bitmask; -else - ad->monitor.write_ctrlreg_onchangeonly &= ~ctrlreg_bitmask; - -if ( !status ) - ad->monitor.write_ctrlreg_enabled |= ctrlreg_bitmask; -else - ad->monitor.write_ctrlreg_enabled &= ~ctrlreg_bitmask; - -if ( mop->u.mov_to_cr.index ==VM_EVENT_X86_CR3 ) -/* Latches new CR3 mask through CR0 code */ - for_each_vcpu ( d, v ) -hvm_update_guest_cr (v,0 ); - -domain_unpause (d); - -break ; - } - -case XEN_DOMCTL_MONITOR_EVENT_MOV_TO_MSR : - { -bool_t status = ad->monitor.mov_to_msr_enabled; - - rc =status_check (mop, status); -if ( rc ) -return rc; - -if ( mop->op ==XEN_DOMCTL_MONITOR_OP_ENABLE && - mop->u.mov_to_msr.extended_capture && - !hvm_enable_msr_exit_interception (d) ) -return -EOPNOTSUPP ; - -domain_pause (d); - -if ( mop->op ==XEN_DOMCTL_MONITOR_OP_ENABLE && - mop->u.mov_to_msr.extended_capture ) - ad->monitor.mov_to_msr_extended =1 ; -else - ad->monitor.mov_to_msr_extended =0 ; - - ad->monitor.mov_to_msr_enabled = !status; -domain_unpause (d); -break ; - } - -case XEN_DOMCTL_MONITOR_EVENT_SINGLESTEP : - { -bool_t status = ad->monitor.singlestep_enabled; - - rc =status_check (mop, status); -if ( rc ) -return rc; - -domain_pause (d); - ad->monitor.singlestep_enabled = !status; -domain_unpause (d); -break ; - } - -case XEN_DOMCTL_MONITOR_EVENT_SOFTWARE_BREAKPOINT : - { -bool_t status = ad->monitor.software_breakpoint_enabled; - - rc =status_check (mop, status); -if ( rc ) -return rc; - -domain_pause (d); - ad->monitor.software_breakpoint_enabled = !status; -domain_unpause (d); -break ; - } - -case XEN_DOMCTL_MONITOR_EVENT_GUEST_REQUEST : - { -bool_t status = ad->monitor.guest_request_enabled; - - rc =status_check (mop, status); -if ( rc ) -return rc; - -domain_pause (d); - ad->monitor.guest_request_sync = mop->u.guest_request.sync; - ad->monitor.guest_request_enabled = !status; -domain_unpause (d); -break ; - } - -default : -return -EOPNOTSUPP ; - - }; - -return 0 ; -} - -/* -* Local variables: -* mode: C -* c-file-style: "BSD" -* c-basic-offset: 4 -* indent-tabs-mode: nil -* End: -*/ xen/arch/x86/monitor_x86.c new file +19
-0@@ -0,0 +1,72 @@ +/* +* arch/x86/monitor_x86.c +* +* Arch-specific monitor_op domctl handler. +* +* Copyright (c) 2015 Tamas K Lengyel ([email protected]) +* Copyright (c) 2016, Bitdefender S.R.L. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public +* License v2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public +* License along with this program; If not, see < http://www.gnu.org/licenses/>.
+ */xen/arch/x86/monitor_x86.c new file +52
-0+ +#include <asm/monitor_arch.h> + +bool_t arch_monitor_domctl_event (struct domain *d, +struct xen_domctl_monitor_op *mop, +int *rc) +{ +struct arch_domain *ad = &d->arch; +bool_t requested_status = (XEN_DOMCTL_MONITOR_OP_ENABLE == mop->op); + +switch ( mop->event ) + { +case XEN_DOMCTL_MONITOR_EVENT_MOV_TO_MSR : + { +bool_t old_status = ad->monitor.mov_to_msr_enabled; + +if (unlikely (old_status == requested_status) ) +return -EEXIST ; + +if (XEN_DOMCTL_MONITOR_OP_ENABLE == mop->op && + mop->u.mov_to_msr.extended_capture && + !hvm_enable_msr_exit_interception (d) ) +return -EOPNOTSUPP ; + +domain_pause (d); + +if (XEN_DOMCTL_MONITOR_OP_ENABLE == mop->op && + mop->u.mov_to_msr.extended_capture ) + ad->monitor.mov_to_msr_extended =1 ; +else + ad->monitor.mov_to_msr_extended =0 ; + + ad->monitor.mov_to_msr_enabled = !old_status; +domain_unpause (d); +break ; + } + +default : +return 0 ; + } + +return 1 ; +} + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/ xen/common/Kconfig +20
-0@@ -36,6 +36,26 @@ config HAS_MEM_PAGING config HAS_MEM_SHARING bool +config HAS_VM_EVENT_WRITE_CTRLREG + bool + ---help--- + Select if ctrl-reg write monitor vm-events are supported + +config HAS_VM_EVENT_SINGLESTEP + bool + ---help--- + Select if single-step monitor vm-events are supported + +config HAS_VM_EVENT_SOFTWARE_BREAKPOINT + bool + ---help--- + Select if software-breakpoint monitor vm-events are supported + +config HAS_VM_EVENT_GUEST_REQUEST + bool + ---help--- + Select if guest-request monitor vm-events are supported + # Select HAS_PDX if PDX is supported config HAS_PDX boolxen/common/Makefile +1
-0@@ -20,6 +20,7 @@ obj-y += lib.o obj-y += lzo.o obj-$(CONFIG_HAS_MEM_ACCESS) += mem_access.o obj-y += memory.o +obj-y += monitor.o obj-y += multicall.o obj-y += notifier.o obj-y += page_alloc.oxen/common/domctl.c +1
-1@@ -25,11 +25,11 @@#include <xen/paging.h> #include <xen/hypercall.h> #include <xen/vm_event.h> +#include <xen/monitor.h> #include <asm/current.h> #include <asm/irq.h> #include <asm/page.h> #include <asm/p2m.h> -#include <asm/monitor.h> #include <public/domctl.h> #include <xsm/xsm.h> xen/common/monitor.c new file +19
-0@@ -0,0 +1,203 @@ +/* +* xen/common/monitor.c +* +* Common monitor_op domctl handler. +* +* Copyright (c) 2015 Tamas K Lengyel ([email protected]) +* Copyright (c) 2016, Bitdefender S.R.L. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public +* License v2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public +* License along with this program; If not, see <
xen/common/monitor.c line 30
Quoted 10 lines
xen/common/monitor.c new file +10
-0+ +#include <xen/monitor.h> +#include <xen/sched.h> /* for domain_pause, ... */ +#include <xen/config.h> /* for XENLOG_WARNING */ +#include <xsm/xsm.h> +#include <public/domctl.h> + +#include <asm/monitor_arch.h> /* for monitor_arch_# */ + +#if CONFIG_X86
Wouldn't it be safe to include these headers on ARM as well?
Quoted 10 lines
xen/common/monitor.c new file +9
-0+#include <public/vm_event.h> /* for VM_EVENT_X86_CR3 */ +#include <asm/hvm/hvm.h> /* for hvm_update_guest_cr, ... */ +#endif + +int monitor_domctl (struct domain *d,struct xen_domctl_monitor_op *mop) +{ +int rc; +bool_t requested_status; +
xen/common/monitor.c line 49
Quoted 10 lines
xen/common/monitor.c new file +10
-0+if (unlikely (current->domain == d) )/* no domain_pause() */ +return -EPERM ; + + rc =xsm_vm_event_control (XSM_PRIV , d, mop->op, mop->event); +if (unlikely (rc) ) +return rc; + +if (unlikely (mop->op !=XEN_DOMCTL_MONITOR_OP_ENABLE && + mop->op !=XEN_DOMCTL_MONITOR_OP_DISABLE ) ) + {
Please make a switch on mop->op instead where the default case is to call arch_monitor_domctl. It would be a bit easier to follow.
+ if ( XEN_DOMCTL_MONITOR_OP_GET_CAPABILITIES == mop->op )
xen/common/monitor.c line 55
Quoted 6 lines
xen/common/monitor.c new file +5
-0+ { + mop->event =arch_monitor_get_capabilities (d); +return 0 ; + } +
"proly"->probably?
Quoted 12 lines
xen/common/monitor.c new file +10
-0+/* The monitor op is proly handled on the arch-side. */ +if (likely (arch_monitor_domctl_op (d, mop, &rc)) ) +return rc; + +/* unrecognized op */ +return -EOPNOTSUPP ; + } + +/* Check if event type is available. */ + if ( unlikely(!(arch_monitor_get_capabilities(d) & (1 <<
mop->event))) )
xen/common/monitor.c line 71
Quoted 6 lines
xen/common/monitor.c new file +6
-0+return -EOPNOTSUPP ; + + requested_status = (XEN_DOMCTL_MONITOR_OP_ENABLE == mop->op); + +switch ( mop->event ) + {
Empty line not needed.
xen/common/monitor.c
Quoted 3 lines
xen/common/monitor.c new file +2
-0+ +#if CONFIG_HAS_VM_EVENT_WRITE_CTRLREG
Emtpy line not needed.
Quoted 20 lines
xen/common/monitor.c new file +19
-0+ +case XEN_DOMCTL_MONITOR_EVENT_WRITE_CTRLREG : + { +struct arch_domain *ad = &d->arch; +unsigned int ctrlreg_bitmask = +monitor_ctrlreg_bitmask (mop->u.mov_to_cr.index); +bool_t old_status = + !!(ad->monitor.write_ctrlreg_enabled & ctrlreg_bitmask); + +if (unlikely (old_status == requested_status) ) +return -EEXIST ; + +domain_pause (d); + +if ( mop->u.mov_to_cr.sync ) + ad->monitor.write_ctrlreg_sync |= ctrlreg_bitmask; +else + ad->monitor.write_ctrlreg_sync &= ~ctrlreg_bitmask; +
xen/common/monitor.c line 102
Quoted 10 lines
xen/common/monitor.c new file +10
-0+if ( mop->u.mov_to_cr.onchangeonly ) + ad->monitor.write_ctrlreg_onchangeonly |= ctrlreg_bitmask; +else + ad->monitor.write_ctrlreg_onchangeonly &= ~ctrlreg_bitmask; + +if ( !old_status ) + ad->monitor.write_ctrlreg_enabled |= ctrlreg_bitmask; +else + ad->monitor.write_ctrlreg_enabled &= ~ctrlreg_bitmask; +
So I don't particularly like this #if check here. IMHO this should be done in arch-specific function that you call from here that is just empty for ARM. It could be a static inline function as it's rather small.
Quoted 2 lines
+#if
CONFIG_X86
+ if ( VM_EVENT_X86_CR3 == mop->u.mov_to_cr.index )
Quoted 7 lines
xen/common/monitor.c new file +6
-0+ { +struct vcpu *v; +/* Latches new CR3 mask through CR0 code. */ + for_each_vcpu ( d, v ) +hvm_update_guest_cr (v,0 ); + }
xen/common/monitor.c line 120
Quoted 10 lines
xen/common/monitor.c new file +10
-0+#endif + +domain_unpause (d); + + break; + } + +#endif // HAS_VM_EVENT_WRITE_CTRLREG + +#if CONFIG_HAS_VM_EVENT_SINGLESTEP
Emtpy line not needed.
Quoted 9 lines
xen/common/monitor.c new file +8
-0+ +case XEN_DOMCTL_MONITOR_EVENT_SINGLESTEP : + { +struct arch_domain *ad = &d->arch; +bool_t old_status = ad->monitor.singlestep_enabled; + +if (unlikely (old_status == requested_status) ) +return -EEXIST ;
xen/common/monitor.c line 138
Quoted 10 lines
xen/common/monitor.c new file +10
-0+ +domain_pause (d); + ad->monitor.singlestep_enabled = !old_status; +domain_unpause (d); + break; + } + +#endif // HAS_VM_EVENT_SINGLESTEP + +#if CONFIG_HAS_VM_EVENT_SOFTWARE_BREAKPOINT
Emtpy line not needed.
Quoted 9 lines
xen/common/monitor.c new file +8
-0+ +case XEN_DOMCTL_MONITOR_EVENT_SOFTWARE_BREAKPOINT : + { +struct arch_domain *ad = &d->arch; +bool_t old_status = ad->monitor.software_breakpoint_enabled; + +if (unlikely (old_status == requested_status) ) +return -EEXIST ;
xen/common/monitor.c line 156
Quoted 10 lines
xen/common/monitor.c new file +10
-0+ +domain_pause (d); + ad->monitor.software_breakpoint_enabled = !old_status; +domain_unpause (d); + break; + } + +#endif // HAS_VM_EVENT_SOFTWARE_BREAKPOINT + +#if CONFIG_HAS_VM_EVENT_GUEST_REQUEST
Emtpy line not needed.
Quoted 7 lines
xen/common/monitor.c new file +5
-0+ +case XEN_DOMCTL_MONITOR_EVENT_GUEST_REQUEST : + { +struct arch_domain *ad = &d->arch; +bool_t old_status = ad->monitor.guest_request_enabled;
xen/common/monitor.c line 171
Quoted 10 lines
xen/common/monitor.c new file +10
-0+ +if (unlikely (old_status == requested_status) ) +return -EEXIST ; + +domain_pause (d); + ad->monitor.guest_request_sync = mop->u.guest_request.sync; + ad->monitor.guest_request_enabled = !old_status; +domain_unpause (d); +break ; + }
Looks good otherwise.
Thanks,
Tamas
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 2/7] x86: hvm events: merge 2 functions into 1
In reply to Corneliu ZUZUQuoted 28 lines · Corneliu ZUZU
Quoted 21 lines · Andrew Cooper
Quoted 6 lines · Corneliu ZUZU
xen/include/asm-x86/hvm/event.h +0
-0xen/include/asm-x86/hvm/event.h bool_t hvm_event_cr(unsigned int index, unsigned long · line 33
Quoted 10 lines
xen/include/asm-x86/hvm/event.h +2
-3@@ -27,9 +27,8 @@ bool_t hvm_event_cr(unsigned int index, unsigned long value,#define hvm_event_crX (what, new, old) \ hvm_event_cr(VM_EVENT_X86_##what, new, old)void hvm_event_msr (unsigned int msr,uint64_t value); -/* Called for current VCPU: returns -1 if no listener */ -int hvm_event_int3 (unsigned long rip); -int hvm_event_single_step (unsigned long rip); +int hvm_event_software_breakpoint (unsigned long rip, +bool_t single_step);Are we liable to ever gain any other type of software breakpoint? Might it be more sense to pass an enum rather than a bool here?
Quoted 5 lines
Otherwise, the changes look sensible.
~Andrew
Quoted 10 lines
Well, IMHO, no. Besides breakpointing/trapping after each instruction (i.e.
VM_EVENT_REASON_SINGLESTEP)
and on arbitrary instructions (VM_EVENT_REASON_SOFTWARE_BREAKPOINT) I don't see what other
types of breakpointing one can define (at least from the hypervisor's point of view), and if in the future
there will be other types, that could also be changed into an enum then. But making that param an enum now would also be fine by me. Since I noticed Tamas also prefers this option, I will make that change.
It's just about code readability. Functionally it would be the same as it is right now, two options in the enum will likely be represented by 0/1. But when you read the code you don't have to keep that boolean state in mind, you explicitly have the path spelled out.
Tamas
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 4/7] Rename monitor_x86.c to monitor.c and monitor_arch.h to monitor.h
In reply to Corneliu ZUZUQuoted 4 lines · Corneliu ZUZU
(last commit before this one explains why this was necessary)
Signed-off-by Corneliu ZUZU <[email protected]>
I assume this patch will be gone in the next iteration after using -M so skipping it now.
Tamas
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 7/7] arch.monitor: move bits to common (arch_domain to domain)
In reply to Corneliu ZUZUQuoted 9 lines · Corneliu ZUZU
This patch moves bitfield members for single-step, software-breakpoint and guest-request monitor vm-events from the arch-side (struct
arch_domain) to the common-side (struct domain). Ctrl-reg bits (i.e. write_ctrlreg_* members)
are left on the arch-side, because control-registers number can vary across architectures.Signed-off-by Corneliu ZUZU <[email protected]>
Technically this looks fine, but I do wonder if and what plans you have to actually implement these events for ARM. I haven't spent too much time looking into it, but I'm not aware of equivalent features on ARM to Intel MTF (singlestepping) or to software-breakpoint trapping. The only instruction I know that functionally comes close to software-breakpoint trapping (INT3) is the SMC instruction which can be trapped into the VMM, but I would not call that a "breakpoint" in the traditional sense.
Tamas
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 3/7] xen/vm-events: Move monitor_domctl to common-side.
In reply to Tamas K LengyelQuoted 5 lines · Tamas K Lengyel
On Mon, Feb 8, 2016 at 9:57 AM, Corneliu ZUZU <[email protected] <mailto:[email protected]>> wrote:
+#if CONFIG_X86
Quoted 7 lines
Wouldn't it be safe to include these headers on ARM as well?
+#include <public/vm_event.h> /* for VM_EVENT_X86_CR3 */ +#include <asm/hvm/hvm.h> /* for hvm_update_guest_cr, ... */ +#endif
It wouldn't break anything, but they are only necessary on X86, so why include them?
Quoted 6 lines
+
+ if ( unlikely(mop->op !=XEN_DOMCTL_MONITOR_OP_ENABLE&&
+mop->op!=XEN_DOMCTL_MONITOR_OP_DISABLE) )
+ {
Quoted 9 lines
Please make a switch on
mop->opinstead where the default case is to callarch_monitor_domctl. It would be a bit easier to follow.+ if (
XEN_DOMCTL_MONITOR_OP_GET_CAPABILITIES==mop->op)
+ {
+mop->event=arch_monitor_get_capabilities(d);
+ return 0;
+ }
+
Noted, good point.
Quoted 7 lines
"proly"->probably?
+ /* The monitor op is proly handled on the arch-side. */
+ if (likely(arch_monitor_domctl_op(d, mop, &rc)))
+ return rc;
Yep, will "proly" change that, heh, just kidding. Noted :D.
Quoted 1 line
Empty line not needed. (*)
Noted.
Quoted 5 lines
So I don't particularly like this #if check here. IMHO this should be done in arch-specific function that you call from here that is just empty for ARM. It could be a static inline function as it's rather small.
+#if
CONFIG_X86
Quoted 9 lines
+ if (
VM_EVENT_X86_CR3==mop->u.mov_to_cr.index)
+ {
+ struct vcpu *v;
+ /* Latches new CR3 mask through CR0 code. */
+for_each_vcpu( d, v )
+hvm_update_guest_cr(v, 0);
+ }
+#endif
I agree, but I was actually hoping to approach that in a future ARM-patch I'm going to send after this one. On ARM, that part of code (where hypervisor CR trapping is enabled based on write_ctrlreg_enabled bits) is done in another place (on the scheduling tail). I wanted to approach removing that #ifdef and finding maybe a solution to do that similarly for X86. Would it be ok to leave this for that discussion? It would be simpler to illustrate what I have in mind.
Quoted 5 lines
Looks good otherwise.
Thanks,
Tamas
Thanks,
Corneliu.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 2/7] x86: hvm events: merge 2 functions into 1
In reply to Tamas K LengyelQuoted 46 lines · Tamas K Lengyel
On Mon, Feb 8, 2016 at 10:49 AM, Corneliu ZUZU <[email protected] <mailto:[email protected]>> wrote:
On 2/8/2016 7:15 PM, Andrew Cooper wrote:
On 08/02/16 16:57, Corneliu ZUZU wrote:
diff --git
a/xen/include/asm-x86/hvm/event.hb/xen/include/asm-x86/hvm/event.h
index 11eb1fe..7c2252b 100644
---a/xen/include/asm-x86/hvm/event.h
+++b/xen/include/asm-x86/hvm/event.h
@@ -27,9 +27,8 @@bool_thvm_event_cr(unsigned int index, unsigned long value,
#definehvm_event_crX(what, new, old)\
hvm_event_cr(VM_EVENT_X86_##what, new, old)
voidhvm_event_msr(unsigned int msr, uint64_t value);
-/* Called for current VCPU: returns -1 if no listener */ -inthvm_event_int3(unsigned long rip);
-inthvm_event_single_step(unsigned long rip); +int hvm_event_software_breakpoint(unsigned long rip,
+bool_tsingle_step);Are we liable to ever gain any other type of software breakpoint? Might
it be more sense to pass an enum rather than a bool here?Otherwise, the changes look sensible.
~Andrew
Well, IMHO, no. Besides breakpointing/trapping after each instruction (i.e.
VM_EVENT_REASON_SINGLESTEP)
and on arbitrary instructions (VM_EVENT_REASON_SOFTWARE_BREAKPOINT) I don't see what other types of breakpointing one can define (at least from the hypervisor's point of view), and if in the future
there will be other types, that could also be changed into an enum then.
But making that param an enum now would also be fine by me. Since I noticed Tamas also prefers this option, I will make that change.
Quoted 4 lines
It's just about code readability. Functionally it would be the same as it is right now, two options in the enum will likely be represented by 0/1. But when you read the code you don't have to keep that boolean state in mind, you explicitly have the path spelled out.
Tamas
That makes sense, and probably that enum value will be handled in a switch. Will do.
Corneliu.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 3/7] xen/vm-events: Move monitor_domctl to common-side.
In reply to Corneliu ZUZUQuoted 19 lines
So I don't particularly like this #if check here. IMHO this should be done in arch-specific function that you call from here that is just empty for ARM. It could be a static inline function as it's rather small.
Quoted 2 lines
+#if
CONFIG_X86+ if (
VM_EVENT_X86_CR3==mop->u.mov_to_cr.index)xen/common/monitor.c line 111
Quoted 8 lines
xen/common/monitor.c new file +7
-0+ { +struct vcpu *v; +/* Latches new CR3 mask through CR0 code. */ + for_each_vcpu ( d, v ) +hvm_update_guest_cr (v,0 ); + } +#endif
Quoted 10 lines
I agree, but I was actually hoping to approach that in a future ARM-patch I'm going to send after this one.
On ARM, that part of code (where hypervisor CR trapping is enabled based onwrite_ctrlreg_enabledbits)
is done in another place (on the scheduling tail). I wanted to approach removing that #ifdef and finding maybe
a solution to do that similarly for X86. Would it be ok to leave this for that discussion? It would be simpler to illustrate
what I have in mind.
SGTM.
Thanks,
Tamas
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 4/7] Rename monitor_x86.c to monitor.c and monitor_arch.h to monitor.h
In reply to Tamas K LengyelQuoted 6 lines · Tamas K Lengyel
On Mon, Feb 8, 2016 at 9:57 AM, Corneliu ZUZU <[email protected] <mailto:[email protected]>> wrote:
(last commit before this one explains why this was necessary)
Quoted 8 lines
Signed-off-by Corneliu ZUZU <[email protected]<mailto:[email protected]>>
I assume this patch will be gone in the next iteration after using -M so skipping it now.
Tamas
No, originally I intended to use the -M option, I just forgot. This is needed even w/ the -M option.
The reason is git seeing file <somepath1>/a.c as being modified when moving it to <somepath2>/a.c and at the same time adding <somepath1>/a.c in place of the old one, *even if* the similarity between the old <somepath1>/a.c and <somepath2>/a.c would be *100%* and you'd use the -M option. A google-search led me to a 2009-dated page that described this as a lack of git diff's algo that would be improved upon. It seems they aren't there yet.
Corneliu.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 7/7] arch.monitor: move bits to common (arch_domain to domain)
In reply to Tamas K LengyelQuoted 14 lines · Tamas K Lengyel
On Mon, Feb 8, 2016 at 9:58 AM, Corneliu ZUZU <[email protected] <mailto:[email protected]>> wrote:
This patch moves bitfield members for single-step, software-breakpoint and
guest-request monitor vm-events from the arch-side (structarch_domain) to
the common-side (struct domain). Ctrl-reg bits (i.e. write_ctrlreg_* members)
are left on the arch-side, because control-registers number can vary across
architectures.
Quoted 5 lines
Signed-off-by Corneliu ZUZU <[email protected]<mailto:[email protected]>>
Technically this looks fine, but I do wonder if and what plans you have to actually implement these events for ARM.
Currently I've only planned implementations for control-register write events & guest-requests. The other two also seem feasible though, I might give adding those a shot sometime after sending the other patches.
Quoted 4 lines
I haven't spent too much time looking into it, but I'm not aware of equivalent features on ARM to Intel MTF (singlestepping) or to software-breakpoint trapping. The only instruction I know that functionally comes close to software-breakpoint trapping (INT3) is the SMC instruction which can be trapped into the VMM, but I would not call that a "breakpoint" in the traditional sense.
Tamas
There's the debugging architecture, hypervisor control of that is possible on both 32-bit & 64-bit ARM. It isn't as easy as for X86 though, where MTF is a hypervisor-internal feature and INT3 can be trapped specifically, whereas on ARM granularity of trap-setting is less of a concern apparently. For this reason, the only issue I see here is the performance penalty these traps would cause for arbitrary software breakpoints (for obvious reasons that doesn't matter in the case of single-stepping).
For INT3, the ARM equivalent is be the BKPT/BRK (set HDCR.TDE on AArch32/MDCR_EL2.TDE AArch64) instruction. Trapping on this instruction implies trapping on
- AArch32: some other debug exceptions (looking @ B1.8.9, ARMv7 DDI 0406C.b)
- AArch64: *all software debug exceptions* + *all debug register accesses* (this might cause some headaches) For MTF-like functionality, the debug architecture also provides ways for single-stepping. That would similarly generate software breakpoint exceptions which can be routed to the hypervisor.
Corneliu.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 1/7] arm: move arch/arm/hvm.c to arch/arm/hvm/hvm.c
In reply to Corneliu ZUZUQuoted 2 lines · Corneliu ZUZU
X86-side
hvm.cis @arch/x86/hvm/hvm.c. To maintain arm<->x86 symmetry, also movearch/arm/hvm.ctoarch/arm/hvm/hvm.c.
Why are we doing this? These are not header files, their paths don't necessarily need to be the same and xen/arch/x86/hvm/hvm.c is very different from xen/arch/arm/hvm.c.
Please state the reason more clearly.
Quoted 186 lines
Signed-off-by Corneliu ZUZU <[email protected]>--- xen/arch/arm/Makefile | 2 +- xen/arch/arm/hvm.c | 67 ----------------------------------------------- xen/arch/arm/hvm/Makefile | 1 + xen/arch/arm/hvm/hvm.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 68 deletions(-) delete mode 100644 xen/arch/arm/hvm.c create mode 100644 xen/arch/arm/hvm/Makefile create mode 100644 xen/arch/arm/hvm/hvm.cxen/arch/arm/Makefile +1
-1@@ -1,6 +1,7 @@ subdir-$(CONFIG_ARM_32) += arm32 subdir-$(CONFIG_ARM_64) += arm64 subdir-y += platforms +subdir-y += hvm subdir-$(CONFIG_ARM_64) += efi obj-$(EARLY_PRINTK) += early_printk.o@@ -34,7 +35,6 @@ obj-y += vgic.o vgic-v2.o obj-$(CONFIG_ARM_64) += vgic-v3.o obj-y += vtimer.o obj-y += vuart.o -obj-y += hvm.o obj-y += device.o obj-y += decode.o obj-y += processor.oxen/arch/arm/hvm.c deleted +0
-67@@ -1,67 +0,0 @@ -#include <xen/config.h> -#include <xen/init.h> -#include <xen/lib.h> -#include <xen/errno.h> -#include <xen/guest_access.h> -#include <xen/sched.h> - -#include <xsm/xsm.h> - -#include <public/xen.h> -#include <public/hvm/params.h> -#include <public/hvm/hvm_op.h> - -#include <asm/hypercall.h> - -long do_hvm_op (unsigned long op,XEN_GUEST_HANDLE_PARAM (void ) arg) - -{ -long rc =0 ; - -switch ( op ) - { -case HVMOP_set_param: -case HVMOP_get_param: - { -struct xen_hvm_param a; -struct domain *d; - -if (copy_from_guest (&a, arg,1 ) ) -return -EFAULT ; - -if ( a.index >=HVM_NR_PARAMS ) -return -EINVAL ; - - d =rcu_lock_domain_by_any_id (a.domid); -if ( d ==NULL ) -return -ESRCH ; - - rc =xsm_hvm_param (XSM_TARGET , d, op); -if ( rc ) - goto param_fail; - -if ( op == HVMOP_set_param ) - { - d->arch.hvm_domain.params[a.index] = a.value; - } -else - { - a.value = d->arch.hvm_domain.params[a.index]; - rc =copy_to_guest (arg, &a,1 ) ? -EFAULT :0 ; - } - - param_fail: -rcu_unlock_domain (d); -break ; - } - -default : - { -gdprintk (XENLOG_DEBUG ,"HVMOP op=%lu: not implemented\n" , op); - rc = -ENOSYS ; -break ; - } - } - -return rc; -}xen/arch/arm/hvm/Makefile new file +1
-0@@ -0,0 +1 @@ +obj-y += hvm.oxen/arch/arm/hvm/hvm.c new file +66
-0@@ -0,0 +1,66 @@ +#include <xen/config.h> +#include <xen/init.h> +#include <xen/lib.h> +#include <xen/errno.h> +#include <xen/guest_access.h> +#include <xen/sched.h> + +#include <xsm/xsm.h> + +#include <public/xen.h> +#include <public/hvm/params.h> +#include <public/hvm/hvm_op.h> + +#include <asm/hypercall.h> + +long do_hvm_op (unsigned long op,XEN_GUEST_HANDLE_PARAM (void ) arg) +{ +long rc =0 ; + +switch ( op ) + { +case HVMOP_set_param: +case HVMOP_get_param: + { +struct xen_hvm_param a; +struct domain *d; + +if (copy_from_guest (&a, arg,1 ) ) +return -EFAULT ; + +if ( a.index >=HVM_NR_PARAMS ) +return -EINVAL ; + + d =rcu_lock_domain_by_any_id (a.domid); +if ( d ==NULL ) +return -ESRCH ; + + rc =xsm_hvm_param (XSM_TARGET , d, op); +if ( rc ) + goto param_fail; + +if ( op == HVMOP_set_param ) + { + d->arch.hvm_domain.params[a.index] = a.value; + } +else + { + a.value = d->arch.hvm_domain.params[a.index]; + rc =copy_to_guest (arg, &a,1 ) ? -EFAULT :0 ; + } + + param_fail: +rcu_unlock_domain (d); +break ; + } + +default : + { +gdprintk (XENLOG_DEBUG ,"HVMOP op=%lu: not implemented\n" , op); + rc = -ENOSYS ; +break ; + } + } + +return rc; +}Signature · 1 line
2.5.0
Re: [PATCH 2/7] x86: hvm events: merge 2 functions into 1
In reply to Corneliu ZUZUQuoted 4 lines
Quoted 1 line
Quoted 1 line · On 08.02.16 at 17:57, <[email protected]> wrote:
This patch merges almost identical functions
hvm_event_int3andhvm_event_single_stepinto a single function calledhvm_event_software_breakpoint.
Except that "software breakpoint" is rather questionable a name here, considering that on x86 this is basically an alias for "int3". If it was "breakpoint", one might argue (see the other responses you've got) that breakpoint event resulting from debug register settings might then be candidates to come here too.
Jan
Re: [PATCH 1/7] arm: move arch/arm/hvm.c to arch/arm/hvm/hvm.c
In reply to Stefano StabelliniQuoted 17 lines · Stefano Stabellini
Quoted 2 lines · Corneliu ZUZU
X86-side
hvm.cis @arch/x86/hvm/hvm.c. To maintain arm<->x86 symmetry, also movearch/arm/hvm.ctoarch/arm/hvm/hvm.c.Why are we doing this? These are not header files, their paths don't necessarily need to be the same and
xen/arch/x86/hvm/hvm.cis very different fromxen/arch/arm/hvm.c.Please state the reason more clearly.
Quoted 7 lines
Signed-off-by Corneliu ZUZU <[email protected]>--- xen/arch/arm/Makefile | 2 +- xen/arch/arm/hvm.c | 67 ----------------------------------------------- xen/arch/arm/hvm/Makefile | 1 + xen/arch/arm/hvm/hvm.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++
Because the ARM side hvm.c currently exists solely to add an implementation for do_hvm_op, which on x86 is @ arch/x86/hvm/hvm.c. I presume the ARM hvm.c got its name from the X86 file, so I thought a symmetry between the two was intended from the start. Also, the hvm directory was created to separate hvm-specific code, which is the case w/ do_hvm_op on any arch.
Corneliu.
Re: [PATCH 2/7] x86: hvm events: merge 2 functions into 1
In reply to Jan BeulichQuoted 11 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 08.02.16 at 17:57, <[email protected]> wrote:
This patch merges almost identical functions
hvm_event_int3andhvm_event_single_stepinto a single function calledhvm_event_software_breakpoint.Except that "software breakpoint" is rather questionable a name here, considering that on x86 this is basically an alias for "int3". If it was "breakpoint", one might argue (see the other responses you've got) that breakpoint event resulting from debug register settings might then be candidates to come here too.
Jan
Yeah..should I then:
* keep both functions and only rename hvm_event_int3 to hvm_event_software_breakpoint
* separate the code that gets the GFN of the instruction pointer in a static inline function ?
Corneliu.
Re: [PATCH 1/7] arm: move arch/arm/hvm.c to arch/arm/hvm/hvm.c
In reply to Corneliu ZUZUQuoted 20 lines
Quoted 1 line
Quoted 1 line · On 09.02.16 at 12:28, <[email protected]> wrote:
Quoted 17 lines · Stefano Stabellini
Quoted 2 lines · Corneliu ZUZU
X86-side
hvm.cis @arch/x86/hvm/hvm.c. To maintain arm<->x86 symmetry, also movearch/arm/hvm.ctoarch/arm/hvm/hvm.c.Why are we doing this? These are not header files, their paths don't necessarily need to be the same and
xen/arch/x86/hvm/hvm.cis very different fromxen/arch/arm/hvm.c.Please state the reason more clearly.
Quoted 7 lines
Signed-off-by Corneliu ZUZU <[email protected]>--- xen/arch/arm/Makefile | 2 +- xen/arch/arm/hvm.c | 67 ----------------------------------------------- xen/arch/arm/hvm/Makefile | 1 + xen/arch/arm/hvm/hvm.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++
Quoted 9 lines
Because the ARM side
hvm.ccurrently exists solely to add an implementation fordo_hvm_op, which on x86 is @arch/x86/hvm/hvm.c. I presume the ARMhvm.cgot its name
from the X86 file, so I thought a symmetry between the two was intended from the start.
Also, the hvm directory was created to separate hvm-specific code, which is the case w/do_hvm_opon any arch.
While I'm not an ARM maintainer, this change still strikes me as odd (or a change for the change's sake). A directory with just one file in it (and - afaict - no current perspective to gain more) is just pointless. In fact it's usually the other way around: When a file grows (or would grow) too large, a similarly named subdirectory gets introduced with the contents "scattered" across multiple files in that directory.
Jan
Re: [PATCH 2/7] x86: hvm events: merge 2 functions into 1
In reply to Corneliu ZUZUQuoted 12 lines
Quoted 1 line
Quoted 1 line · On 09.02.16 at 12:52, <[email protected]> wrote:
Quoted 9 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 08.02.16 at 17:57, <[email protected]> wrote:
This patch merges almost identical functions
hvm_event_int3andhvm_event_single_stepinto a single function calledhvm_event_software_breakpoint.Except that "software breakpoint" is rather questionable a name here, considering that on x86 this is basically an alias for "int3". If it was "breakpoint", one might argue (see the other responses you've got) that breakpoint event resulting from debug register settings might then be candidates to come here too.
Quoted 3 lines
Yeah..should I then:
* keep both functions and only renamehvm_event_int3tohvm_event_software_breakpoint
I actually think that the intention of folding two almost identical functions is a good one. I'm merely suggesting to think of a better name - perhaps just "breakpoint" or "debug event"?
Re: [PATCH 1/7] arm: move arch/arm/hvm.c to arch/arm/hvm/hvm.c
In reply to Jan BeulichQuoted 30 lines · Jan Beulich
Quoted 20 lines
Quoted 1 line
Quoted 1 line · On 09.02.16 at 12:28, <[email protected]> wrote:
Quoted 17 lines · Stefano Stabellini
Quoted 2 lines · Corneliu ZUZU
X86-side
hvm.cis @arch/x86/hvm/hvm.c. To maintain arm<->x86 symmetry, also movearch/arm/hvm.ctoarch/arm/hvm/hvm.c.Why are we doing this? These are not header files, their paths don't necessarily need to be the same and
xen/arch/x86/hvm/hvm.cis very different fromxen/arch/arm/hvm.c.Please state the reason more clearly.
Quoted 7 lines
Signed-off-by Corneliu ZUZU <[email protected]>--- xen/arch/arm/Makefile | 2 +- xen/arch/arm/hvm.c | 67 ----------------------------------------------- xen/arch/arm/hvm/Makefile | 1 + xen/arch/arm/hvm/hvm.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++Quoted 9 lines
Because the ARM side
hvm.ccurrently exists solely to add an implementation fordo_hvm_op, which on x86 is @arch/x86/hvm/hvm.c. I presume the ARMhvm.cgot its name
from the X86 file, so I thought a symmetry between the two was intended from the start.
Also, the hvm directory was created to separate hvm-specific code, which is the case w/do_hvm_opon any arch.
Quoted 7 lines
While I'm not an ARM maintainer, this change still strikes me as odd (or a change for the change's sake). A directory with just one file in it (and - afaict - no current perspective to gain more) is just pointless. In fact it's usually the other way around: When a file grows (or would grow) too large, a similarly named subdirectory gets introduced with the contents "scattered" across multiple files in that directory.
That's exactly what I thought.
Re: [PATCH 2/7] x86: hvm events: merge 2 functions into 1
In reply to Jan BeulichQuoted 11 lines · Jan Beulich
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 09.02.16 at 12:52, <[email protected]> wrote:
Quoted 9 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · On 08.02.16 at 17:57, <[email protected]> wrote:
This patch merges almost identical functions
hvm_event_int3andhvm_event_single_stepinto a single function calledhvm_event_software_breakpoint.Except that "software breakpoint" is rather questionable a name here, considering that on x86 this is basically an alias for "int3". If it was "breakpoint", one might argue (see the other responses you've got) that breakpoint event resulting from debug register settings might then be candidates to come here too.
Quoted 8 lines
Quoted 3 lines
Yeah..should I then:
* keep both functions and only renamehvm_event_int3tohvm_event_software_breakpointI actually think that the intention of folding two almost identical functions is a good one. I'm merely suggesting to think of a better name - perhaps just "breakpoint" or "debug event"?
SGTM. I'll change it to hvm_event_breakpoint then.
Corneliu.
Re: [PATCH 1/7] arm: move arch/arm/hvm.c to arch/arm/hvm/hvm.c
In reply to Jan BeulichQuoted 36 lines · Jan Beulich
Quoted 19 lines
Quoted 1 line
Quoted 1 line · On 09.02.16 at 12:28, <[email protected]> wrote:
Quoted 17 lines · Stefano Stabellini
Quoted 2 lines · Corneliu ZUZU
X86-side
hvm.cis @arch/x86/hvm/hvm.c. To maintain arm<->x86 symmetry, also movearch/arm/hvm.ctoarch/arm/hvm/hvm.c.Why are we doing this? These are not header files, their paths don't necessarily need to be the same and
xen/arch/x86/hvm/hvm.cis very different fromxen/arch/arm/hvm.c.Please state the reason more clearly.
Quoted 7 lines
Signed-off-by Corneliu ZUZU <[email protected]>--- xen/arch/arm/Makefile | 2 +- xen/arch/arm/hvm.c | 67 ----------------------------------------------- xen/arch/arm/hvm/Makefile | 1 + xen/arch/arm/hvm/hvm.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++Quoted 9 lines
Because the ARM side
hvm.ccurrently exists solely to add an implementation fordo_hvm_op, which on x86 is @arch/x86/hvm/hvm.c. I presume the ARMhvm.cgot its name
from the X86 file, so I thought a symmetry between the two was intended from the start.
Also, the hvm directory was created to separate hvm-specific code, which is the case w/do_hvm_opon any arch.While I'm not an ARM maintainer, this change still strikes me as odd (or a change for the change's sake). A directory with just one file in it (and - afaict - no current perspective to gain more) is just pointless. In fact it's usually the other way around: When a file grows (or would grow) too large, a similarly named subdirectory gets introduced with the contents "scattered" across multiple files in that directory.
Quoted 1 line
Jan
There are already directories w/ just one/a few files in them, even small (e.g. common/gcov/gcov.c). IMHO no harm is done if a file is put in its proper directory even before it grows too large. This way one can find the file more easily, future additions are more visibly encouraged to also be separated in that directory when it makes sense, symmetry between arch directories remains intact (=> easier to compare between code for different arches/find equivalent files between them).
But I am not a Xen maintainer, I'm only a contributor so I can only suggest :). If ARM maintainers (e.g. Tamas) feel the same, I will move the file back.
Corneliu.
Re: [PATCH 1/7] arm: move arch/arm/hvm.c to arch/arm/hvm/hvm.c
Quoted 63 lines · Corneliu ZUZU
Quoted 47 lines · Jan Beulich
Quoted 25 lines · On 09.02.16 at 12:28, <[email protected]> wrote:
Quoted 8 lines
Quoted 1 line
On 2/9/2016 1:03 PM, Stefano Stabellini wrote:
Quoted 3 lines · Corneliu ZUZU
X86-side
hvm.cis @arch/x86/hvm/hvm.c. To maintain arm<->x86 symmetry, also movearch/arm/hvm.ctoarch/arm/hvm/hvm.c.Quoted 17 lines
Why are we doing this? These are not header files, their paths don't necessarily need to be the same and
xen/arch/x86/hvm/hvm.cis very different fromxen/arch/arm/hvm.c.Please state the reason more clearly.
Signed-off-by Corneliu ZUZU <[email protected]>Quoted 9 lines
--- xen/arch/arm/Makefile | 2 +- xen/arch/arm/hvm.c | 67 ----------------------------------------------- xen/arch/arm/hvm/Makefile | 1 + xen/arch/arm/hvm/hvm.c | 66++++++++++++++++++++++++++++++++++++++++++++++
Because the ARM side
hvm.ccurrently exists solely to add anQuoted 13 lines
implementation
fordo_hvm_op, which on x86 is @arch/x86/hvm/hvm.c. I presume the ARMhvm.cgot
its name
from the X86 file, so I thought a symmetry between the two was intended from
the start.
Also, the hvm directory was created to separate hvm-specific code, which is
the case w/do_hvm_opon any arch.While I'm not an ARM maintainer, this change still strikes me as odd (or a change for the change's sake). A directory with just one file in it (and - afaict - no current perspective to gain more) is just pointless. In fact it's usually the other way around: When a file grows (or would grow) too large, a similarly named subdirectory gets introduced with the contents "scattered" across multiple files in that directory.
Quoted 2 lines
Jan
There are already directories w/ just one/a few files in them, even small (e.g.
common/gcov/gcov.c).
IMHO no harm is done if a file is put in its proper directory even before it grows too large.
This way one can find the file more easily, future additions are more visibly encouraged to
also be separated in that directory when it makes sense, symmetry between arch directories remains
intact (=> easier to compare between code for different arches/find equivalent files between them).
Quoted 4 lines
But I am not a Xen maintainer, I'm only a contributor so I can only suggest :).
If ARM maintainers (e.g. Tamas) feel the same, I will move the file back.
I don't really have a strong opinion about this either way, so if the others prefer it staying as it is then there is no point moving it.
Tamas
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH 1/7] arm: move arch/arm/hvm.c to arch/arm/hvm/hvm.c
Quoted 21 lines · Tamas K Lengyel
On Tue, Feb 9, 2016 at 5:32 AM, Corneliu ZUZU <[email protected] <mailto:[email protected]>> wrote:
There are already directories w/ just one/a few files in them, even small (e.g.
common/gcov/gcov.c).
IMHO no harm is done if a file is put in its proper directory even before it grows too large.
This way one can find the file more easily, future additions are more visibly encouraged to
also be separated in that directory when it makes sense, symmetry between arch directories remains
intact (=> easier to compare between code for different arches/find equivalent files between them).But I am not a Xen maintainer, I'm only a contributor so I can only suggest :).
If ARM maintainers (e.g. Tamas) feel the same, I will move the file back.
Quoted 4 lines
I don't really have a strong opinion about this either way, so if the others prefer it staying as it is then there is no point moving it.
Tamas
Ok, will do, thanks for the feedback.
Corneliu.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel