From patchwork Mon Feb 8 16:57:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corneliu ZUZU X-Patchwork-Id: 8252251 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 659AA9F1C1 for ; Mon, 8 Feb 2016 17:01:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EC83C203B8 for ; Mon, 8 Feb 2016 17:01:15 +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 646F4203B7 for ; Mon, 8 Feb 2016 17:01:14 +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 1aSp8s-0005RX-Oq; Mon, 08 Feb 2016 16:58:26 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aSp8r-0005Qc-Hj for xen-devel@lists.xen.org; Mon, 08 Feb 2016 16:58:25 +0000 Received: from [193.109.254.147] by server-6.bemta-14.messagelabs.com id 05/A3-16618-039C8B65; Mon, 08 Feb 2016 16:58:24 +0000 X-Env-Sender: czuzu@bitdefender.com X-Msg-Ref: server-2.tower-27.messagelabs.com!1454950702!20343388!1 X-Originating-IP: [91.199.104.161] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 25805 invoked from network); 8 Feb 2016 16:58:23 -0000 Received: from mx01.buh.bitdefender.com (HELO mx01.buh.bitdefender.com) (91.199.104.161) by server-2.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 8 Feb 2016 16:58:23 -0000 Comment: DomainKeys? See http://domainkeys.sourceforge.net/ DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=bitdefender.com; b=G3R2SQgwjQA4xpHlP0E82Ma095HI8HwR6iKzRdtmln2gERC65bY2N7CWXlMs3tIknmIM/9qASyfjqy2xQjGyN8oFxBrhkSt1ZVeiVLiQ6zDwd/KPwvsFUF6toooeMK2Q6qGOWOox+FXqXbuM/MZT+CkiH5FnHZYOVa1FdlDOR5Xe402p18czBER6Mm4CBFqst1chtGCiEtzA3M0X8QfUrH6sisFQxsibnyehJ9EcaBOdRax5a3EHp6vBaIcRUXwzZ3tOP5Wqb4Y61EAp4IgRTLNl24hgP4GmjQ9c80YqPmatU+f7iGbAZiG8VOt2mQD7VcMwss4B/W3XfE2FfAsOqQ==; 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=kjTzp73wVV85jMQ9HIUK9YU+qH8=; b=VoDAseSV2lMz/FlbZnoACSd7ZS0b /PdfNoE3owpSfZXTbQA2SgBTkY5LJ5rXNV4yTYVNaP+1KM7HBidXCn29t9K8LAHR 4pATZeEt1b8LSX1FcTP9RcCtekRZcu05KaWwEf3Yl7yYaFksybiHBVBOpAYUS2U2 EyxfkIdlX3Fhlm6Hogy81RQh2v5r8jGFIUTwcoGJ7TiZmrFiCFrASVJi3PRivOOu KvVdVDLA46jLQlUkkG4Zk9EF5aaX8Ig8aJtJNiLaj10WSp8OGEDxmvwxZnx0MWKy Xhgq59hHr/1LnfG/L34ObtYJCqj8bvrRK9IMsK0DVm9jaogU6dtc4zOllw== Received: (qmail 25543 invoked from network); 8 Feb 2016 18:58:20 +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:20 +0200 Received: from smtp02.buh.bitdefender.net (unknown [10.17.80.76]) by mx-sr.buh.bitdefender.com (Postfix) with ESMTP id 349027FBD6 for ; Mon, 8 Feb 2016 18:58:20 +0200 (EET) Received: (qmail 31578 invoked from network); 8 Feb 2016 18:58:20 +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:19 +0200 From: Corneliu ZUZU To: xen-devel@lists.xen.org Date: Mon, 8 Feb 2016 18:57:59 +0200 Message-Id: <1454950682-9459-5-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.000013, 0.011730)], BW: [Enabled, t: (0.000007,0.000001)], RBL DNSBL: [Disabled], APM: [Enabled, Score: 500, t: (0.008554), Flags: 2A917CE3; NN_LARGISH_BIGGISH; 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.013960)], URL: [Enabled, t: (0.000028)], RTDA: [Enabled, t: (0.039240), Hit: No, Details: v2.3.3; Id: 2m1ghdm.1aaoi8dn9.289un], 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 4/7] Rename monitor_x86.c to monitor.c and monitor_arch.h to monitor.h 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 (last commit before this one explains why this was necessary) Signed-off-by: Corneliu ZUZU --- 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 diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile index 6e80cf0..8e6e901 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -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 diff --git a/xen/arch/x86/monitor.c b/xen/arch/x86/monitor.c new file mode 100644 index 0000000..568def2 --- /dev/null +++ b/xen/arch/x86/monitor.c @@ -0,0 +1,72 @@ +/* + * arch/x86/monitor.c + * + * Arch-specific monitor_op domctl handler. + * + * Copyright (c) 2015 Tamas K Lengyel (tamas@tklengyel.com) + * 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 . + */ + +#include + +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: + */ diff --git a/xen/arch/x86/monitor_x86.c b/xen/arch/x86/monitor_x86.c deleted file mode 100644 index d19fd15..0000000 --- a/xen/arch/x86/monitor_x86.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * arch/x86/monitor_x86.c - * - * Arch-specific monitor_op domctl handler. - * - * Copyright (c) 2015 Tamas K Lengyel (tamas@tklengyel.com) - * 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 . - */ - -#include - -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: - */ diff --git a/xen/common/monitor.c b/xen/common/monitor.c index 7bbeba5..1165aeb 100644 --- a/xen/common/monitor.c +++ b/xen/common/monitor.c @@ -25,7 +25,7 @@ #include #include -#include /* for monitor_arch_# */ +#include /* for monitor_arch_# */ #if CONFIG_X86 #include /* for VM_EVENT_X86_CR3 */ diff --git a/xen/include/asm-arm/monitor.h b/xen/include/asm-arm/monitor.h new file mode 100644 index 0000000..eb770da --- /dev/null +++ b/xen/include/asm-arm/monitor.h @@ -0,0 +1,53 @@ +/* + * include/asm-arm/monitor.h + * + * Arch-specific monitor_op domctl handler. + * + * Copyright (c) 2015 Tamas K Lengyel (tamas@tklengyel.com) + * 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 . + */ + +#ifndef __ASM_ARM_MONITOR_H__ +#define __ASM_ARM_MONITOR_H__ + +#include +#include + +static inline +uint32_t arch_monitor_get_capabilities(struct domain *d) +{ + /* No monitor vm-events implemented on ARM. */ + return 0; +} + +static inline +bool_t arch_monitor_domctl_op(struct domain *d, + struct xen_domctl_monitor_op *mop, + int *rc) +{ + /* No arch-specific monitor ops on ARM. */ + return 0; +} + +static inline +bool_t arch_monitor_domctl_event(struct domain *d, + struct xen_domctl_monitor_op *mop, + int *rc) +{ + /* No arch-specific monitor vm-events on ARM. */ + return 0; +} + +#endif /* __ASM_ARM_MONITOR_H__ */ diff --git a/xen/include/asm-arm/monitor_arch.h b/xen/include/asm-arm/monitor_arch.h deleted file mode 100644 index d0df66c..0000000 --- a/xen/include/asm-arm/monitor_arch.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * include/asm-arm/monitor_arch.h - * - * Arch-specific monitor_op domctl handler. - * - * Copyright (c) 2015 Tamas K Lengyel (tamas@tklengyel.com) - * 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 . - */ - -#ifndef __ASM_ARM_MONITOR_ARCH_H__ -#define __ASM_ARM_MONITOR_ARCH_H__ - -#include -#include - -static inline -uint32_t arch_monitor_get_capabilities(struct domain *d) -{ - /* No monitor vm-events implemented on ARM. */ - return 0; -} - -static inline -bool_t arch_monitor_domctl_op(struct domain *d, - struct xen_domctl_monitor_op *mop, - int *rc) -{ - /* No arch-specific monitor ops on ARM. */ - return 0; -} - -static inline -bool_t arch_monitor_domctl_event(struct domain *d, - struct xen_domctl_monitor_op *mop, - int *rc) -{ - /* No arch-specific monitor vm-events on ARM. */ - return 0; -} - -#endif /* __ASM_ARM_MONITOR_ARCH_H__ */ diff --git a/xen/include/asm-x86/monitor.h b/xen/include/asm-x86/monitor.h new file mode 100644 index 0000000..b12823c --- /dev/null +++ b/xen/include/asm-x86/monitor.h @@ -0,0 +1,74 @@ +/* + * include/asm-x86/monitor.h + * + * Arch-specific monitor_op domctl handler. + * + * Copyright (c) 2015 Tamas K Lengyel (tamas@tklengyel.com) + * 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 . + */ + +#ifndef __ASM_X86_MONITOR_H__ +#define __ASM_X86_MONITOR_H__ + +#include /* for struct domain, is_hvm_domain, ... */ +#include /* for XEN_DOMCTL_MONITOR_#, ... */ +#include /* for cpu_has_vmx */ +#include /* for hvm_is_singlestep_supported */ + +static inline +uint32_t arch_monitor_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; +} + +static inline +bool_t arch_monitor_domctl_op(struct domain *d, + struct xen_domctl_monitor_op *mop, + int *rc) +{ + if( likely(XEN_DOMCTL_MONITOR_OP_EMULATE_EACH_REP == mop->op) ) + { + domain_pause(d); + d->arch.mem_access_emulate_each_rep = !!mop->event; + domain_unpause(d); + *rc = 0; + return 1; + } + return 0; +} + +bool_t arch_monitor_domctl_event(struct domain *d, + struct xen_domctl_monitor_op *mop, + int *rc); + +#endif /* __ASM_X86_MONITOR_H__ */ diff --git a/xen/include/asm-x86/monitor_arch.h b/xen/include/asm-x86/monitor_arch.h deleted file mode 100644 index d9daf65..0000000 --- a/xen/include/asm-x86/monitor_arch.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * include/asm-x86/monitor_arch.h - * - * Arch-specific monitor_op domctl handler. - * - * Copyright (c) 2015 Tamas K Lengyel (tamas@tklengyel.com) - * 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 . - */ - -#ifndef __ASM_X86_MONITOR_ARCH_H__ -#define __ASM_X86_MONITOR_ARCH_H__ - -#include /* for struct domain, is_hvm_domain, ... */ -#include /* for XEN_DOMCTL_MONITOR_#, ... */ -#include /* for cpu_has_vmx */ -#include /* for hvm_is_singlestep_supported */ - -static inline -uint32_t arch_monitor_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; -} - -static inline -bool_t arch_monitor_domctl_op(struct domain *d, - struct xen_domctl_monitor_op *mop, - int *rc) -{ - if( likely(XEN_DOMCTL_MONITOR_OP_EMULATE_EACH_REP == mop->op) ) - { - domain_pause(d); - d->arch.mem_access_emulate_each_rep = !!mop->event; - domain_unpause(d); - *rc = 0; - return 1; - } - return 0; -} - -bool_t arch_monitor_domctl_event(struct domain *d, - struct xen_domctl_monitor_op *mop, - int *rc); - -#endif /* __ASM_X86_MONITOR_ARCH_H__ */