From patchwork Mon Feb 8 16:04:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Douglas Goldstein X-Patchwork-Id: 8251651 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 B54FC9F319 for ; Mon, 8 Feb 2016 16:07:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 908CC202EC for ; Mon, 8 Feb 2016 16:07:49 +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 51A7A20254 for ; Mon, 8 Feb 2016 16:07:48 +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 1aSoJF-0000Vd-VC; Mon, 08 Feb 2016 16:05:05 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aSoJE-0000VY-8z for xen-devel@lists.xen.org; Mon, 08 Feb 2016 16:05:04 +0000 Received: from [85.158.139.211] by server-4.bemta-5.messagelabs.com id 44/92-12635-FACB8B65; Mon, 08 Feb 2016 16:05:03 +0000 X-Env-Sender: cardoe@cardoe.com X-Msg-Ref: server-10.tower-206.messagelabs.com!1454947502!21008073!1 X-Originating-IP: [209.85.161.195] 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 16146 invoked from network); 8 Feb 2016 16:05:02 -0000 Received: from mail-yw0-f195.google.com (HELO mail-yw0-f195.google.com) (209.85.161.195) by server-10.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 8 Feb 2016 16:05:02 -0000 Received: by mail-yw0-f195.google.com with SMTP id q190so4263737ywd.2 for ; Mon, 08 Feb 2016 08:05:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cardoe.com; s=google; h=from:to:cc:subject:date:message-id; bh=2HvW+eXiHsDpspEM6hIDtculYdNgdPj/EChAlI5izPk=; b=QERkHfbmSObnBUJ2RgaOvzteTc+EEHuTkYJcpwnLHS9BDC1GgoMNhqjC3kK671gK82 IV9aRLKJNBrh5OLHSEuIr9bIWBKT0Hgc/0VFdLF0buhklV05OcJ7Yux4PwX+VHl65UxY 2iUj9yiYh4YhvwTWRAH/Td7t+MGwSyV0nFmfY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=2HvW+eXiHsDpspEM6hIDtculYdNgdPj/EChAlI5izPk=; b=meXB1MF9PHiCOxvbG01cIg3TBprl3dTa7BnxBXCFEpCFD//HvWJckDox1x22hqtS/0 oBHjLCzkSLb4LFs2X3jdZjx9D1oCbfCm1pctHQJloQBVPn99m9eXrfwHsy5Zbwj8A5B8 zSqB+M+W6/XOUqyDmmiPOtBme7Tx0km+iBlwmyN34jj7fnbTx5WSK8XpXPtkVX1+iGUA rrOY5id0ZmP6GdafVPe3f4sX9MQ69MVwt6bkxLb6AvQnNJ7oqVSTB2EXRs39y9oNQa9u phAo5RceJlERIlvUNfsezQCf8Dd+KbDK6rsoJPAiEXyJu/KYc3A3A5mMatVHYEXgP/cv o/7g== X-Gm-Message-State: AG10YOTuWxVmBFLgC52oNg77fU+dpjunRvQxtNNs6Of9fcBtOq45cTgslIESmaOXRPX2TA== X-Received: by 10.129.115.215 with SMTP id o206mr16829585ywc.231.1454947501705; Mon, 08 Feb 2016 08:05:01 -0800 (PST) Received: from swanson.lan (c-68-46-196-185.hsd1.al.comcast.net. [68.46.196.185]) by smtp.gmail.com with ESMTPSA id q141sm21260201ywg.2.2016.02.08.08.04.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 08 Feb 2016 08:05:00 -0800 (PST) From: Doug Goldstein To: xen-devel@lists.xen.org Date: Mon, 8 Feb 2016 10:04:46 -0600 Message-Id: <1454947487-8588-1-git-send-email-cardoe@cardoe.com> X-Mailer: git-send-email 2.4.10 Cc: Kevin Tian , Keir Fraser , Jan Beulich , Jun Nakajima , Andrew Cooper , Doug Goldstein , Aravind Gopalakrishnan , Suravee Suthikulpanit , Boris Ostrovsky Subject: [Xen-devel] [PATCH 1/2] xenoprof: fix up ability to disable it 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=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_BL_SPAMCOP_NET, 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 Allow Xenoprof to be fully disabled when toggling the option off. CC: Keir Fraser CC: Jan Beulich CC: Andrew Cooper CC: Boris Ostrovsky CC: Suravee Suthikulpanit CC: Aravind Gopalakrishnan CC: Jun Nakajima CC: Kevin Tian Signed-off-by: Doug Goldstein Reviewed-by: Boris Ostrovsky --- xen/arch/x86/Makefile | 2 +- xen/arch/x86/Rules.mk | 2 ++ xen/arch/x86/cpu/vpmu_amd.c | 9 ++++++--- xen/arch/x86/cpu/vpmu_intel.c | 9 ++++++--- xen/arch/x86/hvm/svm/svm.c | 4 +++- xen/arch/x86/hvm/vmx/vmx.c | 12 ++++++++---- xen/arch/x86/x86_64/compat/entry.S | 4 ++++ xen/arch/x86/x86_64/entry.S | 4 ++++ xen/include/asm-x86/config.h | 1 - 9 files changed, 34 insertions(+), 13 deletions(-) diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile index 8e6e901..434d985 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -3,7 +3,7 @@ subdir-y += cpu subdir-y += genapic subdir-y += hvm subdir-y += mm -subdir-y += oprofile +subdir-$(xenoprof) += oprofile subdir-y += x86_64 obj-bin-y += alternative.init.o diff --git a/xen/arch/x86/Rules.mk b/xen/arch/x86/Rules.mk index a1cdae0..94e4efd 100644 --- a/xen/arch/x86/Rules.mk +++ b/xen/arch/x86/Rules.mk @@ -10,6 +10,8 @@ CFLAGS += -I$(BASEDIR)/include/asm-x86/mach-generic CFLAGS += -I$(BASEDIR)/include/asm-x86/mach-default CFLAGS += '-D__OBJECT_LABEL__=$(subst /,$$,$(subst -,_,$(subst $(BASEDIR)/,,$(CURDIR))/$@))' +CFLAGS-$(xenoprof) += -DCONFIG_XENOPROF + # Prevent floating-point variables from creeping into Xen. CFLAGS += -msoft-float diff --git a/xen/arch/x86/cpu/vpmu_amd.c b/xen/arch/x86/cpu/vpmu_amd.c index 990e6f3..c7b5bd5 100644 --- a/xen/arch/x86/cpu/vpmu_amd.c +++ b/xen/arch/x86/cpu/vpmu_amd.c @@ -22,6 +22,7 @@ */ #include +#include #include #include #include @@ -378,7 +379,8 @@ static int amd_vpmu_do_wrmsr(unsigned int msr, uint64_t msr_content, if ( (type == MSR_TYPE_CTRL) && is_pmu_enabled(msr_content) && !vpmu_is_set(vpmu, VPMU_RUNNING) ) { - if ( !acquire_pmu_ownership(PMU_OWNER_HVM) ) + if ( IS_ENABLED(CONFIG_XENOPROF) && + !acquire_pmu_ownership(PMU_OWNER_HVM) ) return 0; vpmu_set(vpmu, VPMU_RUNNING); @@ -393,7 +395,8 @@ static int amd_vpmu_do_wrmsr(unsigned int msr, uint64_t msr_content, vpmu_reset(vpmu, VPMU_RUNNING); if ( has_hvm_container_vcpu(v) && is_msr_bitmap_on(vpmu) ) amd_vpmu_unset_msr_bitmap(v); - release_pmu_ownship(PMU_OWNER_HVM); + if ( IS_ENABLED(CONFIG_XENOPROF) ) + release_pmu_ownship(PMU_OWNER_HVM); } if ( !vpmu_is_set(vpmu, VPMU_CONTEXT_LOADED) @@ -441,7 +444,7 @@ static void amd_vpmu_destroy(struct vcpu *v) vpmu->context = NULL; vpmu->priv_context = NULL; - if ( vpmu_is_set(vpmu, VPMU_RUNNING) ) + if ( IS_ENABLED(CONFIG_XENOPROF) && vpmu_is_set(vpmu, VPMU_RUNNING) ) release_pmu_ownship(PMU_OWNER_HVM); vpmu_clear(vpmu); diff --git a/xen/arch/x86/cpu/vpmu_intel.c b/xen/arch/x86/cpu/vpmu_intel.c index 50b5831..226f5e7 100644 --- a/xen/arch/x86/cpu/vpmu_intel.c +++ b/xen/arch/x86/cpu/vpmu_intel.c @@ -19,6 +19,7 @@ */ #include +#include #include #include #include @@ -476,7 +477,7 @@ static int core2_vpmu_alloc_resource(struct vcpu *v) struct xen_pmu_intel_ctxt *core2_vpmu_cxt = NULL; uint64_t *p = NULL; - if ( !acquire_pmu_ownership(PMU_OWNER_HVM) ) + if ( IS_ENABLED(CONFIG_XENOPROF) && !acquire_pmu_ownership(PMU_OWNER_HVM) ) return 0; if ( has_hvm_container_vcpu(v) ) @@ -517,7 +518,8 @@ static int core2_vpmu_alloc_resource(struct vcpu *v) return 1; out_err: - release_pmu_ownship(PMU_OWNER_HVM); + if ( IS_ENABLED(CONFIG_XENOPROF) ) + release_pmu_ownship(PMU_OWNER_HVM); xfree(core2_vpmu_cxt); xfree(p); @@ -892,7 +894,8 @@ static void core2_vpmu_destroy(struct vcpu *v) vpmu->priv_context = NULL; if ( has_hvm_container_vcpu(v) && cpu_has_vmx_msr_bitmap ) core2_vpmu_unset_msr_bitmap(v->arch.hvm_vmx.msr_bitmap); - release_pmu_ownship(PMU_OWNER_HVM); + if ( IS_ENABLED(CONFIG_XENOPROF) ) + release_pmu_ownship(PMU_OWNER_HVM); vpmu_clear(vpmu); } diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index e62dfa1..473c781 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -17,6 +17,7 @@ */ #include +#include #include #include #include @@ -1214,7 +1215,8 @@ static void svm_vcpu_destroy(struct vcpu *v) { vpmu_destroy(v); svm_destroy_vmcb(v); - passive_domain_destroy(v); + if ( IS_ENABLED(CONFIG_XENOPROF) ) + passive_domain_destroy(v); } static void svm_inject_trap(const struct hvm_trap *trap) diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index b9f340c..669bc2d 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -16,6 +16,7 @@ */ #include +#include #include #include #include @@ -173,7 +174,8 @@ static void vmx_vcpu_destroy(struct vcpu *v) vmx_vcpu_disable_pml(v); vmx_destroy_vmcs(v); vpmu_destroy(v); - passive_domain_destroy(v); + if ( IS_ENABLED(CONFIG_XENOPROF) ) + passive_domain_destroy(v); } static DEFINE_PER_CPU(struct vmx_msr_state, host_msr_state); @@ -2447,7 +2449,8 @@ static int vmx_msr_read_intercept(unsigned int msr, uint64_t *msr_content) goto gp_fault; break; default: - if ( passive_domain_do_rdmsr(msr, msr_content) ) + if ( IS_ENABLED(CONFIG_XENOPROF) && + passive_domain_do_rdmsr(msr, msr_content) ) goto done; switch ( long_mode_do_msr_read(msr, msr_content) ) { @@ -2666,10 +2669,11 @@ static int vmx_msr_write_intercept(unsigned int msr, uint64_t msr_content) goto gp_fault; break; default: - if ( passive_domain_do_wrmsr(msr, msr_content) ) + if ( IS_ENABLED(CONFIG_XENOPROF) && + passive_domain_do_wrmsr(msr, msr_content) ) return X86EMUL_OKAY; - if ( wrmsr_viridian_regs(msr, msr_content) ) + if ( wrmsr_viridian_regs(msr, msr_content) ) break; switch ( long_mode_do_msr_write(msr, msr_content) ) diff --git a/xen/arch/x86/x86_64/compat/entry.S b/xen/arch/x86/x86_64/compat/entry.S index 3088aa7..6424ed0 100644 --- a/xen/arch/x86/x86_64/compat/entry.S +++ b/xen/arch/x86/x86_64/compat/entry.S @@ -394,6 +394,10 @@ compat_crash_page_fault: #define compat_kexec_op do_ni_hypercall #endif +#ifndef CONFIG_XENOPROF +#define compat_xenoprof_op do_ni_hypercall +#endif + ENTRY(compat_hypercall_table) .quad compat_set_trap_table /* 0 */ .quad do_mmu_update diff --git a/xen/arch/x86/x86_64/entry.S b/xen/arch/x86/x86_64/entry.S index 94a54aa..0a73878 100644 --- a/xen/arch/x86/x86_64/entry.S +++ b/xen/arch/x86/x86_64/entry.S @@ -727,6 +727,10 @@ ENTRY(exception_table) #define do_kexec_op do_ni_hypercall #endif +#ifndef CONFIG_XENOPROF +#define do_xenoprof_op do_ni_hypercall +#endif + ENTRY(hypercall_table) .quad do_set_trap_table /* 0 */ .quad do_mmu_update diff --git a/xen/include/asm-x86/config.h b/xen/include/asm-x86/config.h index d97877d..a45d3ee 100644 --- a/xen/include/asm-x86/config.h +++ b/xen/include/asm-x86/config.h @@ -47,7 +47,6 @@ #define CONFIG_VGA 1 #define CONFIG_VIDEO 1 -#define CONFIG_XENOPROF 1 #define CONFIG_WATCHDOG 1 #define CONFIG_MULTIBOOT 1