@@ -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
new file mode 100644
@@ -0,0 +1,51 @@
+/*
+ * arch/x86/hvm/event.c
+ *
+ * Arch-specific hardware virtual machine event abstractions.
+ *
+ * Copyright (c) 2004, Intel Corporation.
+ * Copyright (c) 2005, International Business Machines Corporation.
+ * Copyright (c) 2008, Citrix Systems, Inc.
+ * 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/>.
+ */
+
+#include <xen/hvm/event.h>
+
+void hvm_event_msr(unsigned int msr, uint64_t value)
+{
+ struct vcpu *curr = current;
+
+ if ( curr->domain->arch.monitor.mov_to_msr_enabled )
+ {
+ vm_event_request_t req = {
+ .reason = VM_EVENT_REASON_MOV_TO_MSR,
+ .vcpu_id = curr->vcpu_id,
+ .u.mov_to_msr.msr = msr,
+ .u.mov_to_msr.value = value,
+ };
+
+ hvm_event_traps(curr, 1, &req);
+ }
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
deleted file mode 100644
@@ -1,51 +0,0 @@
-/*
- * arch/x86/hvm/event_x86.c
- *
- * Arch-specific hardware virtual machine event abstractions.
- *
- * Copyright (c) 2004, Intel Corporation.
- * Copyright (c) 2005, International Business Machines Corporation.
- * Copyright (c) 2008, Citrix Systems, Inc.
- * 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/>.
- */
-
-#include <xen/hvm/event.h>
-
-void hvm_event_msr(unsigned int msr, uint64_t value)
-{
- struct vcpu *curr = current;
-
- if ( curr->domain->arch.monitor.mov_to_msr_enabled )
- {
- vm_event_request_t req = {
- .reason = VM_EVENT_REASON_MOV_TO_MSR,
- .vcpu_id = curr->vcpu_id,
- .u.mov_to_msr.msr = msr,
- .u.mov_to_msr.value = value,
- };
-
- hvm_event_traps(curr, 1, &req);
- }
-}
-
-/*
- * Local variables:
- * mode: C
- * c-file-style: "BSD"
- * c-basic-offset: 4
- * tab-width: 4
- * indent-tabs-mode: nil
- * End:
- */
@@ -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>
@@ -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
@@ -1,2 +1,2 @@
obj-y += event.o
-obj-y += save.o
+obj-$(CONFIG_X86) += save.o
@@ -1,30 +1,30 @@
/*
-* xen/common/hvm/event.c
-*
-* Common hardware virtual machine event abstractions.
-*
-* Copyright (c) 2004, Intel Corporation.
-* Copyright (c) 2005, International Business Machines Corporation.
-* Copyright (c) 2008, Citrix Systems, Inc.
-* 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/>.
-*/
+ * xen/common/hvm/event.c
+ *
+ * Common hardware virtual machine event abstractions.
+ *
+ * Copyright (c) 2004, Intel Corporation.
+ * Copyright (c) 2005, International Business Machines Corporation.
+ * Copyright (c) 2008, Citrix Systems, Inc.
+ * 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/>.
+ */
#include <xen/hvm/event.h>
#include <xen/vm_event.h> /* for vm_event_# calls */
#include <xen/monitor.h>
-#include <asm/hvm/event_arch.h> /* for hvm_event_arch_# calls */
+#include <asm/hvm/event.h> /* for hvm_event_arch_# calls */
#if CONFIG_X86
#include <asm/altp2m.h>
#endif
new file mode 100644
@@ -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:
+ */
deleted file mode 100644
@@ -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:
- */
new file mode 100644
@@ -0,0 +1,93 @@
+/*
+ * include/asm-x86/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_X86_HVM_EVENT_H__
+#define __ASM_X86_HVM_EVENT_H__
+
+#include <xen/sched.h>
+#include <xen/paging.h>
+#include <public/vm_event.h>
+
+static inline
+void arch_hvm_event_fill_regs(vm_event_request_t *req)
+{
+ const struct cpu_user_regs *regs = guest_cpu_user_regs();
+ const struct vcpu *curr = current;
+
+ req->data.regs.x86.rax = regs->eax;
+ req->data.regs.x86.rcx = regs->ecx;
+ req->data.regs.x86.rdx = regs->edx;
+ req->data.regs.x86.rbx = regs->ebx;
+ req->data.regs.x86.rsp = regs->esp;
+ req->data.regs.x86.rbp = regs->ebp;
+ req->data.regs.x86.rsi = regs->esi;
+ req->data.regs.x86.rdi = regs->edi;
+
+ req->data.regs.x86.r8 = regs->r8;
+ req->data.regs.x86.r9 = regs->r9;
+ req->data.regs.x86.r10 = regs->r10;
+ req->data.regs.x86.r11 = regs->r11;
+ req->data.regs.x86.r12 = regs->r12;
+ req->data.regs.x86.r13 = regs->r13;
+ req->data.regs.x86.r14 = regs->r14;
+ req->data.regs.x86.r15 = regs->r15;
+
+ req->data.regs.x86.rflags = regs->eflags;
+ req->data.regs.x86.rip = regs->eip;
+
+ req->data.regs.x86.msr_efer = curr->arch.hvm_vcpu.guest_efer;
+ req->data.regs.x86.cr0 = curr->arch.hvm_vcpu.guest_cr[0];
+ req->data.regs.x86.cr3 = curr->arch.hvm_vcpu.guest_cr[3];
+ req->data.regs.x86.cr4 = curr->arch.hvm_vcpu.guest_cr[4];
+}
+
+/*
+ * Returns the GFN of the given instruction pointer.
+ * Needed by hvm_event_software_breakpoint.
+ */
+static inline
+uint64_t arch_hvm_event_gfn_of_ip(unsigned long ip)
+{
+ struct vcpu *curr = current;
+ struct segment_register sreg;
+ uint32_t pfec = PFEC_page_present | PFEC_insn_fetch;
+
+ hvm_get_segment_register(curr, x86_seg_ss, &sreg);
+ if ( 3 == sreg.attr.fields.dpl )
+ pfec |= PFEC_user_mode;
+
+ hvm_get_segment_register(curr, x86_seg_cs, &sreg);
+
+ return (uint64_t) paging_gva_to_gfn(curr, sreg.base + ip, &pfec);
+}
+
+void hvm_event_msr(unsigned int msr, uint64_t value);
+
+#endif /* __ASM_X86_HVM_EVENT_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
deleted file mode 100644
@@ -1,93 +0,0 @@
-/*
- * include/asm-x86/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_X86_HVM_EVENT_ARCH_H__
-#define __ASM_X86_HVM_EVENT_ARCH_H__
-
-#include <xen/sched.h>
-#include <xen/paging.h>
-#include <public/vm_event.h>
-
-static inline
-void arch_hvm_event_fill_regs(vm_event_request_t *req)
-{
- const struct cpu_user_regs *regs = guest_cpu_user_regs();
- const struct vcpu *curr = current;
-
- req->data.regs.x86.rax = regs->eax;
- req->data.regs.x86.rcx = regs->ecx;
- req->data.regs.x86.rdx = regs->edx;
- req->data.regs.x86.rbx = regs->ebx;
- req->data.regs.x86.rsp = regs->esp;
- req->data.regs.x86.rbp = regs->ebp;
- req->data.regs.x86.rsi = regs->esi;
- req->data.regs.x86.rdi = regs->edi;
-
- req->data.regs.x86.r8 = regs->r8;
- req->data.regs.x86.r9 = regs->r9;
- req->data.regs.x86.r10 = regs->r10;
- req->data.regs.x86.r11 = regs->r11;
- req->data.regs.x86.r12 = regs->r12;
- req->data.regs.x86.r13 = regs->r13;
- req->data.regs.x86.r14 = regs->r14;
- req->data.regs.x86.r15 = regs->r15;
-
- req->data.regs.x86.rflags = regs->eflags;
- req->data.regs.x86.rip = regs->eip;
-
- req->data.regs.x86.msr_efer = curr->arch.hvm_vcpu.guest_efer;
- req->data.regs.x86.cr0 = curr->arch.hvm_vcpu.guest_cr[0];
- req->data.regs.x86.cr3 = curr->arch.hvm_vcpu.guest_cr[3];
- req->data.regs.x86.cr4 = curr->arch.hvm_vcpu.guest_cr[4];
-}
-
-/*
- * Returns the GFN of the given instruction pointer.
- * Needed by hvm_event_software_breakpoint.
- */
-static inline
-uint64_t arch_hvm_event_gfn_of_ip(unsigned long ip)
-{
- struct vcpu *curr = current;
- struct segment_register sreg;
- uint32_t pfec = PFEC_page_present | PFEC_insn_fetch;
-
- hvm_get_segment_register(curr, x86_seg_ss, &sreg);
- if ( 3 == sreg.attr.fields.dpl )
- pfec |= PFEC_user_mode;
-
- hvm_get_segment_register(curr, x86_seg_cs, &sreg);
-
- return (uint64_t) paging_gva_to_gfn(curr, sreg.base + ip, &pfec);
-}
-
-void hvm_event_msr(unsigned int msr, uint64_t value);
-
-#endif /* __ASM_X86_HVM_EVENT_ARCH_H__ */
-
-/*
- * Local variables:
- * mode: C
- * c-file-style: "BSD"
- * c-basic-offset: 4
- * tab-width: 4
- * indent-tabs-mode: nil
- * End:
- */
@@ -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
* 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 Signed-off-by: Corneliu ZUZU <czuzu@bitdefender.com> --- 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