From patchwork Thu Jun 16 14:08:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corneliu ZUZU X-Patchwork-Id: 9181011 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8D39360776 for ; Thu, 16 Jun 2016 14:11:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B375280B0 for ; Thu, 16 Jun 2016 14:11:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E3CF28357; Thu, 16 Jun 2016 14:11:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B741B280B0 for ; Thu, 16 Jun 2016 14:10:57 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bDXyS-0004H6-3t; Thu, 16 Jun 2016 14:08:48 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bDXyR-0004Gq-0U for xen-devel@lists.xen.org; Thu, 16 Jun 2016 14:08:47 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id DE/20-22092-EE2B2675; Thu, 16 Jun 2016 14:08:46 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrMIsWRWlGSWpSXmKPExsUSfTxjoe7bTUn hBm+Xa1gs+biYxYHR4+ju30wBjFGsmXlJ+RUJrBk9ZxIKjjtWXD7SytTAuN28i5GTQ0jAQ6Jz 22HmLkYuIHsto8T2u8dZIZyTjBLNBzewdTFygFXt+uwJEV/NKPH3zFsWkG42AW2Jc4fuMYHYI gLSEtc+X2YEKWIWmMMs8e/kPVaQZmEBG4lfD7NAalgEVCVufL7NBmLzCrhI3Lh6jR2kREJATm LBhXSQMKeAq8SHvROh1rpIdB2MBAlLCORIfJ7YxQxRLSXxv1UJZJGEwBIWiZv7DzJB1MhIPJp 4k20Co9ACRoZVjOrFqUVlqUW6xnpJRZnpGSW5iZk5uoYGZnq5qcXFiempOYlJxXrJ+bmbGIEB yAAEOxg7/jkdYpTkYFIS5a2vTwoX4kvKT6nMSCzOiC8qzUktPsQow8GhJMG7ciNQTrAoNT21I i0zBxgLMGkJDh4lEd49IGne4oLE3OLMdIjUKUZdjmNzb6xlEmLJy89LlRLnrQcpEgApyijNgx sBi8tLjLJSwryMQEcJ8RSkFuVmlqDKv2IU52BUEubdBjKFJzOvBG7TK6AjmICOsJkeD3JESSJ CSqqBMSnCpCvq/LWyTVMCjgWFn81w+nbFeZf8x2ULl99zfnysU/WPS8CL5MczwuTeG660KP7O vqH2p95v1T1KtdVm9R0ujHMOSGTzLoufXFe0va1VY9O1OXESDPPSKwW/dzk+/OfFeav+uwSLf NzMqllHbn43K9hUckt0mXmb2rfvK7fIN6raV1oxK7EUZyQaajEXFScCALkoRUbGAgAA X-Env-Sender: czuzu@bitdefender.com X-Msg-Ref: server-6.tower-21.messagelabs.com!1466086124!19272171!1 X-Originating-IP: [91.199.104.161] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 51058 invoked from network); 16 Jun 2016 14:08:45 -0000 Received: from mx01.bbu.dsd.mx.bitdefender.com (HELO mx01.bbu.dsd.mx.bitdefender.com) (91.199.104.161) by server-6.tower-21.messagelabs.com with DHE-RSA-AES128-GCM-SHA256 encrypted SMTP; 16 Jun 2016 14:08:45 -0000 Received: (qmail 19725 invoked from network); 16 Jun 2016 17:08:44 +0300 Received: from unknown (HELO mx-sr.buh.bitdefender.com) (10.17.80.103) by mx01.bbu.dsd.mx.bitdefender.com with AES256-GCM-SHA384 encrypted SMTP; 16 Jun 2016 17:08:44 +0300 Received: from smtp01.buh.bitdefender.com (unknown [10.17.80.75]) by mx-sr.buh.bitdefender.com (Postfix) with ESMTP id 7827C7FBD2 for ; Thu, 16 Jun 2016 17:08:44 +0300 (EEST) Received: (qmail 28528 invoked from network); 16 Jun 2016 17:08:44 +0300 Received: from unknown (HELO czuzu-dev-vm.clj.bitdefender.biz) (czuzu@bitdefender.com@91.199.104.243) by smtp01.buh.bitdefender.com with SMTP; 16 Jun 2016 17:08:44 +0300 From: Corneliu ZUZU To: xen-devel@lists.xen.org Date: Thu, 16 Jun 2016 17:08:47 +0300 Message-Id: <1466086127-7563-1-git-send-email-czuzu@bitdefender.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1466085888-7428-1-git-send-email-czuzu@bitdefender.com> References: <1466085888-7428-1-git-send-email-czuzu@bitdefender.com> X-BitDefender-Scanner: Clean, Agent: BitDefender qmail 3.1.6 on smtp01.buh.bitdefender.com, sigver: 7.65934 X-BitDefender-Spam: No (0) X-BitDefender-SpamStamp: Build: [Engines: 2.15.6.911, Dats: 424498, Stamp: 3], Multi: [Enabled, t: (0.000011, 0.008990)], BW: [Enabled, t: (0.000007,0.000001)], RBL DNSBL: [Disabled], APM: [Enabled, Score: 500, t: (0.005879), Flags: BB9BAF5C; 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.014538)], URL: [Enabled, t: (0.000012)], RTDA: [Enabled, t: (0.035534), Hit: No, Details: v2.4.2; Id: 2m1ghm1.1akqg1u25.qnkc], total: 0(775) X-BitDefender-CF-Stamp: none Cc: Kevin Tian , Stefano Stabellini , Jan Beulich , Razvan Cojocaru , George Dunlap , Andrew Cooper , Julien Grall , Paul Durrant , Tamas K Lengyel , Jun Nakajima Subject: [Xen-devel] [PATCH 3/7] vm-event: introduce vm_event_vcpu_enter X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP In an effort to improve on the vm-event interface, we introduce a new function called vm_event_vcpu_enter. Its significance is that of a "final touch" vCPU function - i.e. it should be called by implementing architectures just before re-entering vCPUs. On X86 for example, it is called on the scheduling tail (hvm_do_resume) and just before reentering the guest world after a hypervisor trap (vmx_vmenter_helper). Signed-off-by: Corneliu ZUZU --- xen/arch/arm/domain.c | 5 ++++- xen/arch/arm/traps.c | 2 ++ xen/arch/x86/hvm/emulate.c | 2 +- xen/arch/x86/hvm/event.c | 1 - xen/arch/x86/hvm/hvm.c | 3 ++- xen/arch/x86/hvm/vmx/vmx.c | 4 ++++ xen/arch/x86/mm/p2m.c | 1 - xen/arch/x86/vm_event.c | 4 +--- xen/common/monitor.c | 2 +- xen/common/vm_event.c | 1 - xen/include/asm-arm/vm_event.h | 6 +++++- xen/include/asm-x86/vm_event.h | 6 +++++- xen/include/xen/vm_event.h | 15 +++++++++++++++ 13 files changed, 40 insertions(+), 12 deletions(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index d31f821..ba248c8 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -251,6 +252,8 @@ static void schedule_tail(struct vcpu *prev) ctxt_switch_to(current); + vm_event_vcpu_enter(current); + local_irq_enable(); context_saved(prev); @@ -296,7 +299,7 @@ void context_switch(struct vcpu *prev, struct vcpu *next) void continue_running(struct vcpu *same) { - /* Nothing to do */ + vm_event_vcpu_enter(same); } void sync_local_execstate(void) diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 7fa2ae5..8c50685 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -2662,6 +2663,7 @@ asmlinkage void leave_hypervisor_tail(void) { local_irq_disable(); if (!softirq_pending(smp_processor_id())) { + vm_event_vcpu_enter(current); gic_inject(); return; } diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c index 266ed89..9b2872a 100644 --- a/xen/arch/x86/hvm/emulate.c +++ b/xen/arch/x86/hvm/emulate.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -23,7 +24,6 @@ #include #include #include -#include static void hvmtrace_io_assist(const ioreq_t *p) { diff --git a/xen/arch/x86/hvm/event.c b/xen/arch/x86/hvm/event.c index 9c51890..26165b4 100644 --- a/xen/arch/x86/hvm/event.c +++ b/xen/arch/x86/hvm/event.c @@ -25,7 +25,6 @@ #include #include #include -#include #include bool_t hvm_event_cr(unsigned int index, unsigned long value, unsigned long old) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 78db903..770bb50 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -65,7 +65,6 @@ #include #include #include -#include #include #include #include @@ -509,6 +508,8 @@ void hvm_do_resume(struct vcpu *v) } } + vm_event_vcpu_enter(v); + /* Inject pending hw/sw trap */ if ( v->arch.hvm_vcpu.inject_trap.vector != -1 ) { diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 670d7dc..b43b94a 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -3874,6 +3875,9 @@ void vmx_vmenter_helper(const struct cpu_user_regs *regs) } out: + if ( guest_mode(regs) ) + vm_event_vcpu_enter(curr); + HVMTRACE_ND(VMENTRY, 0, 1/*cycles*/, 0, 0, 0, 0, 0, 0, 0); __vmwrite(GUEST_RIP, regs->rip); diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index 89462b2..9d37b12 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -36,7 +36,6 @@ #include #include #include -#include #include #include "mm-locks.h" diff --git a/xen/arch/x86/vm_event.c b/xen/arch/x86/vm_event.c index 75647c4..f7eb24a 100644 --- a/xen/arch/x86/vm_event.c +++ b/xen/arch/x86/vm_event.c @@ -18,9 +18,7 @@ * License along with this program; If not, see . */ -#include -#include -#include +#include /* Implicitly serialized by the domctl lock. */ int vm_event_init_domain(struct domain *d) diff --git a/xen/common/monitor.c b/xen/common/monitor.c index b30857a..c46df5a 100644 --- a/xen/common/monitor.c +++ b/xen/common/monitor.c @@ -22,8 +22,8 @@ #include #include #include +#include #include -#include int monitor_domctl(struct domain *d, struct xen_domctl_monitor_op *mop) { diff --git a/xen/common/vm_event.c b/xen/common/vm_event.c index 2906407..15152ba 100644 --- a/xen/common/vm_event.c +++ b/xen/common/vm_event.c @@ -27,7 +27,6 @@ #include #include #include -#include #include /* for public/io/ring.h macros */ diff --git a/xen/include/asm-arm/vm_event.h b/xen/include/asm-arm/vm_event.h index 05c3027..4e5a272 100644 --- a/xen/include/asm-arm/vm_event.h +++ b/xen/include/asm-arm/vm_event.h @@ -20,7 +20,6 @@ #define __ASM_ARM_VM_EVENT_H__ #include -#include #include static inline int vm_event_init_domain(struct domain *d) @@ -56,6 +55,11 @@ static inline void vm_event_fill_regs(vm_event_request_t *req) /* Not supported on ARM. */ } +static inline void arch_vm_event_vcpu_enter(struct vcpu *v) +{ + /* Nothing to do. */ +} + /* * Monitor vm-events. */ diff --git a/xen/include/asm-x86/vm_event.h b/xen/include/asm-x86/vm_event.h index df8e98d..6fb3b58 100644 --- a/xen/include/asm-x86/vm_event.h +++ b/xen/include/asm-x86/vm_event.h @@ -20,7 +20,6 @@ #define __ASM_X86_VM_EVENT_H__ #include -#include /* * Should we emulate the next matching instruction on VCPU resume @@ -44,6 +43,11 @@ void vm_event_set_registers(struct vcpu *v, vm_event_response_t *rsp); void vm_event_fill_regs(vm_event_request_t *req); +static inline void arch_vm_event_vcpu_enter(struct vcpu *v) +{ + /* Nothing to do. */ +} + /* * Monitor vm-events. */ diff --git a/xen/include/xen/vm_event.h b/xen/include/xen/vm_event.h index a10ee40..f124143 100644 --- a/xen/include/xen/vm_event.h +++ b/xen/include/xen/vm_event.h @@ -24,6 +24,7 @@ #define __VM_EVENT_H__ #include +#include #include /* Clean up on domain destruction */ @@ -72,6 +73,20 @@ void vm_event_resume(struct domain *d, struct vm_event_domain *ved); int vm_event_domctl(struct domain *d, xen_domctl_vm_event_op_t *vec, XEN_GUEST_HANDLE_PARAM(void) u_domctl); +/* + * "Final touch" vCPU function, should be called just before re-entering vCPUs, + * e.g. on x86 it is called by hvm_do_resume (scheduling tail) and + * vmx_vmenter_helper (before VMRESUME or VMLAUNCH). + */ +static inline void vm_event_vcpu_enter(struct vcpu *v) +{ + /* don't track idle vcpus, they're not subject to the vm-event subsystem */ + if ( is_idle_vcpu(v) ) + return; + + arch_vm_event_vcpu_enter(v); +} + void vm_event_vcpu_pause(struct vcpu *v); void vm_event_vcpu_unpause(struct vcpu *v);