From patchwork Mon Feb 8 16:58:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corneliu ZUZU X-Patchwork-Id: 8252261 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 866FDBEEE5 for ; Mon, 8 Feb 2016 17:01:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D2A1F203B7 for ; Mon, 8 Feb 2016 17:01:17 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ECBDF203C3 for ; Mon, 8 Feb 2016 17:01:15 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aSp91-0005Xo-1n; Mon, 08 Feb 2016 16:58:35 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aSp8y-0005W3-Tp for xen-devel@lists.xen.org; Mon, 08 Feb 2016 16:58:33 +0000 Received: from [193.109.254.147] by server-10.bemta-14.messagelabs.com id 06/20-25438-839C8B65; Mon, 08 Feb 2016 16:58:32 +0000 X-Env-Sender: czuzu@bitdefender.com X-Msg-Ref: server-6.tower-27.messagelabs.com!1454950708!22376083!1 X-Originating-IP: [91.199.104.161] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 53349 invoked from network); 8 Feb 2016 16:58:31 -0000 Received: from mx01.buh.bitdefender.com (HELO mx01.buh.bitdefender.com) (91.199.104.161) by server-6.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 8 Feb 2016 16:58:31 -0000 Comment: DomainKeys? See http://domainkeys.sourceforge.net/ DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=bitdefender.com; b=w/IdWOgNCi2Dk7x8h17sD57M4hKfERIvEODNXDJ02qe9SbkLC+1qAcza46vXlSxdRlf7sKLuDjaQh4pOXPbJmyjwa23xgRDayrjp78lrnWsX32jHz01SkugiNl1MNeFT35GNd64U3FIgRXQE1AUxYnGJ70RFlDK801zajqcTiNDh2bUPuvRvffkJVyouH/by/1z+GXJgIL9xgyaH4uPmGRMLJHHNELMbv/9dEpEMlHQPzoFHpgIzdHGDCcbEvRttC8ThxjH06DEXrClJ11BcR8JAv+kMJs7kkeiwDmlZEBhNWme+yavRZ7DznmZWWecVlgARlnyd011M1GxX7flUPQ==; h=Received:Received:Received:Received:Received:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References:X-BitDefender-Scanner:X-BitDefender-Spam:X-BitDefender-SpamStamp:X-BitDefender-CF-Stamp; DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=bitdefender.com; h=from:to :cc:subject:date:message-id:in-reply-to:references; s=default; bh=KOW0iq+0x2d+zxSQGpE9TfubPU8=; b=LVr69ZHY+4xckWf1yUbiAA2fHDf4 LQY0h1Bzun6SkftzeARj4udCz3ikc/kZx5rHqjdn+6AqgKLbw6yRO1Y9O5aM2ZgZ E+N7m9GLNq1iR46tbGmawOnnx1iqj5k29RAHLNDtkJhV6Tcy++/IgRrChgwZ2ja3 PhPUPfs6own7FmQl+pyVEO33jgY1fK/WWOt/w+SHIwQp+VdLEW6/6HHYxbC8U/VH rw2/QZxzesUPcLko9I6nszO1fTXt5q4YUzTLTzZvw3zp9N1rhbiPBwLsR04I65O0 Zxo791EX6k1Hzt+Pf3Yd2TcinzFX4udJKByd2iYh2ge/UoH5G/jYORSpgA== Received: (qmail 25867 invoked from network); 8 Feb 2016 18:58:23 +0200 Received: from unknown (HELO mx-sr.buh.bitdefender.com) (10.17.80.103) by mx01.buh.bitdefender.com with AES256-GCM-SHA384 encrypted SMTP; 8 Feb 2016 18:58:23 +0200 Received: from smtp02.buh.bitdefender.net (unknown [10.17.80.76]) by mx-sr.buh.bitdefender.com (Postfix) with ESMTP id D24767FBD8 for ; Mon, 8 Feb 2016 18:58:22 +0200 (EET) Received: (qmail 31602 invoked from network); 8 Feb 2016 18:58:22 +0200 Received: from 82-137-8-119.rdsnet.ro (HELO localhost.localdomain) (czuzu@bitdefender.com@82.137.8.119) by smtp02.buh.bitdefender.net with AES128-SHA256 encrypted SMTP; 8 Feb 2016 18:58:22 +0200 From: Corneliu ZUZU To: xen-devel@lists.xen.org Date: Mon, 8 Feb 2016 18:58:01 +0200 Message-Id: <1454950682-9459-7-git-send-email-czuzu@bitdefender.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1454950682-9459-1-git-send-email-czuzu@bitdefender.com> References: <1454950682-9459-1-git-send-email-czuzu@bitdefender.com> X-BitDefender-Scanner: Clean, Agent: BitDefender qmail 3.1.4 on smtp02.buh.bitdefender.net, sigver: 7.64434 X-BitDefender-Spam: No (0) X-BitDefender-SpamStamp: Build: [Engines: 2.15.6.743, Dats: 413947, Stamp: 3], Multi: [Enabled, t: (0.000012, 0.013503)], BW: [Enabled, t: (0.000008,0.000001)], RBL DNSBL: [Disabled], APM: [Enabled, Score: 500, t: (0.010349), Flags: 2A917CE3; NN_TP_TAG_HTTP; NN_NO_CONTENT_TYPE; NN_LEGIT_SUMM_400_WORDS; NN_LEGIT_BITDEFENDER; NN_LEGIT_S_SQARE_BRACKETS; NN_LEGIT_MAILING_LIST_TO], SGN: [Enabled, t: (0.013974)], URL: [Enabled, t: (0.000032)], RTDA: [Enabled, t: (0.035305), Hit: No, Details: v2.3.3; Id: 2m1ghdo.1aaoi9nek.2hocq], total: 0(775) X-BitDefender-CF-Stamp: none Cc: Kevin Tian , Tamas K Lengyel , Keir Fraser , Ian Campbell , Razvan Cojocaru , Jun Nakajima , Andrew Cooper , Stefano Stabellini , Jan Beulich Subject: [Xen-devel] [PATCH 6/7] Rename event_x86.c to event.c and event_arch.h to event.h + minor fixes X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP * 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 --- 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 diff --git a/xen/arch/x86/hvm/Makefile b/xen/arch/x86/hvm/Makefile index 15daa09..794e793 100644 --- a/xen/arch/x86/hvm/Makefile +++ b/xen/arch/x86/hvm/Makefile @@ -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 diff --git a/xen/arch/x86/hvm/event.c b/xen/arch/x86/hvm/event.c new file mode 100644 index 0000000..3349c34 --- /dev/null +++ b/xen/arch/x86/hvm/event.c @@ -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 . + */ + +#include + +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: + */ diff --git a/xen/arch/x86/hvm/event_x86.c b/xen/arch/x86/hvm/event_x86.c deleted file mode 100644 index 7b54f18..0000000 --- a/xen/arch/x86/hvm/event_x86.c +++ /dev/null @@ -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 . - */ - -#include - -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: - */ diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index d90ca10..6a1ec3b 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -59,7 +59,7 @@ #include #include #include -#include +#include #include #include /* for cpu_has_tsc_ratio */ #include diff --git a/xen/common/Makefile b/xen/common/Makefile index 0d76efe..703faa5 100644 --- a/xen/common/Makefile +++ b/xen/common/Makefile @@ -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 diff --git a/xen/common/hvm/Makefile b/xen/common/hvm/Makefile index 66ae866..12d13b2 100644 --- a/xen/common/hvm/Makefile +++ b/xen/common/hvm/Makefile @@ -1,2 +1,2 @@ obj-y += event.o -obj-y += save.o +obj-$(CONFIG_X86) += save.o diff --git a/xen/common/hvm/event.c b/xen/common/hvm/event.c index 149ea79..d4ce97a 100644 --- a/xen/common/hvm/event.c +++ b/xen/common/hvm/event.c @@ -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 . -*/ + * 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 . + */ #include #include /* for vm_event_# calls */ #include -#include /* for hvm_event_arch_# calls */ +#include /* for hvm_event_arch_# calls */ #if CONFIG_X86 #include #endif diff --git a/xen/include/asm-arm/hvm/event.h b/xen/include/asm-arm/hvm/event.h new file mode 100644 index 0000000..4aa797b --- /dev/null +++ b/xen/include/asm-arm/hvm/event.h @@ -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 . + */ + +#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: + */ diff --git a/xen/include/asm-arm/hvm/event_arch.h b/xen/include/asm-arm/hvm/event_arch.h deleted file mode 100644 index beebca2..0000000 --- a/xen/include/asm-arm/hvm/event_arch.h +++ /dev/null @@ -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 . - */ - -#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: - */ diff --git a/xen/include/asm-x86/hvm/event.h b/xen/include/asm-x86/hvm/event.h new file mode 100644 index 0000000..88a81f0 --- /dev/null +++ b/xen/include/asm-x86/hvm/event.h @@ -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 . + */ + +#ifndef __ASM_X86_HVM_EVENT_H__ +#define __ASM_X86_HVM_EVENT_H__ + +#include +#include +#include + +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: + */ diff --git a/xen/include/asm-x86/hvm/event_arch.h b/xen/include/asm-x86/hvm/event_arch.h deleted file mode 100644 index b9fb559..0000000 --- a/xen/include/asm-x86/hvm/event_arch.h +++ /dev/null @@ -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 . - */ - -#ifndef __ASM_X86_HVM_EVENT_ARCH_H__ -#define __ASM_X86_HVM_EVENT_ARCH_H__ - -#include -#include -#include - -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: - */ diff --git a/xen/include/xen/hvm/event.h b/xen/include/xen/hvm/event.h index 85e63d6..0548945 100644 --- a/xen/include/xen/hvm/event.h +++ b/xen/include/xen/hvm/event.h @@ -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