From patchwork Sat Jul 9 04:19:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corneliu ZUZU X-Patchwork-Id: 9221987 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 B1D2260467 for ; Sat, 9 Jul 2016 04:22:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A27DF286C0 for ; Sat, 9 Jul 2016 04:22:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 95320286C4; Sat, 9 Jul 2016 04:22:20 +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 15150286C0 for ; Sat, 9 Jul 2016 04:22:20 +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 1bLjkW-0002gg-Dw; Sat, 09 Jul 2016 04:20:16 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bLjkU-0002gT-KI for xen-devel@lists.xen.org; Sat, 09 Jul 2016 04:20:14 +0000 Received: from [85.158.137.68] by server-17.bemta-3.messagelabs.com id 57/78-21227-D7B70875; Sat, 09 Jul 2016 04:20:13 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrDIsWRWlGSWpSXmKPExsUSfTxjoW5tdUO 4wfbDIhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8aEs8fYCq4LVEzqWsTawNjA18XIySEk4C7x ctYk5i5GLiB7DaPEpi1zGSGck4wS754/Z4aocpO49WcXK0RiHaPE/E/r2EASbALaEucO3WMCs UUEpCWufb4M1s0ssJRR4uGCq2AJYYEwiaUTGxhBbBYBVYkXS2ezgNi8Ai4SRx7sA6rh4JAQkJ NYcCEdJMwp4Cpx7u1rVojFLhI39k0CGyMhkCOx8tksdohyKYn/rUogqyQEulkkNi6Zyg5RIyP xaOJNtgmMQgsYGVYxahSnFpWlFukameolFWWmZ5TkJmbm6BoaGOvlphYXJ6an5iQmFesl5+du YgSGYj0DA+MOxtYTfocYJTmYlER5L9g2hAvxJeWnVGYkFmfEF5XmpBYfYpTh4FCS4BWvAsoJF qWmp1akZeYAowImLcHBoyTCqwmS5i0uSMwtzkyHSJ1iVJQS5+UESQiAJDJK8+DaYJF4iVFWSp iXkYGBQYinILUoN7MEVf4VozgHo5Iwrx7IFJ7MvBK46a+AFjMBLTYIqAdZXJKIkJJqYPRML6t S4Jt5KPHMP8YvCZ5XT17Iz2xLOfx447Kqb7za6Usfdqw4ZMVR2N6Yl7RG6eGJep01Sp9c+Rkn hnm2qnMGynVaNivdX7deIdit7q1XnLK9d47r54V8rnbTz2gGNKxknLlHX8frd//6g+leKnJmp qwFoSwez98dtDEO5Om0nC4sENWtxFKckWioxVxUnAgAL70J2L8CAAA= X-Env-Sender: czuzu@bitdefender.com X-Msg-Ref: server-11.tower-31.messagelabs.com!1468038012!23375985!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 42090 invoked from network); 9 Jul 2016 04:20:13 -0000 Received: from mx01.bbu.dsd.mx.bitdefender.com (HELO mx01.bbu.dsd.mx.bitdefender.com) (91.199.104.161) by server-11.tower-31.messagelabs.com with DHE-RSA-AES128-GCM-SHA256 encrypted SMTP; 9 Jul 2016 04:20:13 -0000 Received: (qmail 12077 invoked from network); 9 Jul 2016 07:20:12 +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; 9 Jul 2016 07:20:12 +0300 Received: from smtp03.buh.bitdefender.org (unknown [10.17.80.77]) by mx-sr.buh.bitdefender.com (Postfix) with ESMTP id 61EED7FC01 for ; Sat, 9 Jul 2016 07:20:11 +0300 (EEST) Received: (qmail 4526 invoked from network); 9 Jul 2016 07:20:11 +0300 Received: from 188-24-34-246.rdsnet.ro (HELO localhost.localdomain) (czuzu@bitdefender.com@188.24.34.246) by smtp03.buh.bitdefender.org with SMTP; 9 Jul 2016 07:20:11 +0300 From: Corneliu ZUZU To: xen-devel@lists.xen.org Date: Sat, 9 Jul 2016 07:19:12 +0300 Message-Id: <1468037952-6890-1-git-send-email-czuzu@bitdefender.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1468037509-6428-1-git-send-email-czuzu@bitdefender.com> References: <1468037509-6428-1-git-send-email-czuzu@bitdefender.com> X-BitDefender-Scanner: Clean, Agent: BitDefender qmail 3.1.6 on smtp03.buh.bitdefender.org, sigver: 7.66242 X-BitDefender-Spam: No (0) X-BitDefender-SpamStamp: Build: [Engines: 2.15.6.911, Dats: 425852, Stamp: 3], Multi: [Enabled, t: (0.000008, 0.002546)], BW: [Enabled, t: (0.000006,0.000001)], RBL DNSBL: [Disabled], APM: [Enabled, Score: 500, t: (0.002462), Flags: 85D2ED72; NN_NO_CONTENT_TYPE; NN_NO_LINK_NMD; NN_LEGIT_BITDEFENDER; NN_LEGIT_S_SQARE_BRACKETS; NN_LEGIT_MAILING_LIST_TO], SGN: [Enabled, t: (0.009054)], URL: [Enabled, t: (0.000005)], RTDA: [Enabled, t: (0.290688), Hit: No, Details: v2.3.10; Id: 2m1ghm2.1an4umg8t.2jj1], total: 0(775) X-BitDefender-CF-Stamp: none Cc: Andrew Cooper , Tamas K Lengyel , Razvan Cojocaru , Jan Beulich Subject: [Xen-devel] [PATCH 10/16] x86/vm-event: centralize vcpu-destroy cleanup in vm-events code 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 Move vm-event cleanup sequence on vcpu destroyal to vm_event.h along with the other vm-event functions. Signed-off-by: Corneliu ZUZU --- xen/arch/x86/domain.c | 4 ++-- xen/arch/x86/vm_event.c | 5 +---- xen/include/asm-x86/vm_event.h | 10 ++++++++++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index bb59247..2a702be 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -56,6 +56,7 @@ #include #include #include +#include #include #include #include @@ -492,8 +493,7 @@ int vcpu_initialise(struct vcpu *v) void vcpu_destroy(struct vcpu *v) { - xfree(v->arch.vm_event); - v->arch.vm_event = NULL; + vm_event_cleanup_vcpu_destroy(v); if ( is_pv_32bit_vcpu(v) ) { diff --git a/xen/arch/x86/vm_event.c b/xen/arch/x86/vm_event.c index e795e5e..bb9c0a0 100644 --- a/xen/arch/x86/vm_event.c +++ b/xen/arch/x86/vm_event.c @@ -67,10 +67,7 @@ void vm_event_cleanup_domain(struct domain *d, struct vm_event_domain *ved) /* Per-vcpu uninitializations. */ for_each_vcpu ( d, v ) - { - xfree(v->arch.vm_event); - v->arch.vm_event = NULL; - } + vm_event_cleanup_vcpu_destroy(v); d->arch.mem_access_emulate_each_rep = 0; } diff --git a/xen/include/asm-x86/vm_event.h b/xen/include/asm-x86/vm_event.h index 934f385..c1b82ab 100644 --- a/xen/include/asm-x86/vm_event.h +++ b/xen/include/asm-x86/vm_event.h @@ -35,6 +35,16 @@ int vm_event_init_domain(struct domain *d, struct vm_event_domain *ved); void vm_event_cleanup_domain(struct domain *d, struct vm_event_domain *ved); +/* Called on vCPU destroy. */ +static inline void vm_event_cleanup_vcpu_destroy(struct vcpu *v) +{ + if ( likely(!v->arch.vm_event) ) + return; + + xfree(v->arch.vm_event); + v->arch.vm_event = NULL; +} + void vm_event_toggle_singlestep(struct domain *d, struct vcpu *v); void vm_event_set_registers(struct vcpu *v, vm_event_response_t *rsp);