From patchwork Wed Feb 17 18:02:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Douglas Goldstein X-Patchwork-Id: 8341871 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 0EF3F9F38B for ; Wed, 17 Feb 2016 18:05:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0573020270 for ; Wed, 17 Feb 2016 18:05:36 +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 DEA112024F for ; Wed, 17 Feb 2016 18:05:34 +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 1aW6RK-0005Mp-JN; Wed, 17 Feb 2016 18:03:02 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aW6RI-0005MC-H8 for xen-devel@lists.xen.org; Wed, 17 Feb 2016 18:03:00 +0000 Received: from [85.158.137.68] by server-16.bemta-3.messagelabs.com id DE/A6-07451-3D5B4C65; Wed, 17 Feb 2016 18:02:59 +0000 X-Env-Sender: cardoe@cardoe.com X-Msg-Ref: server-10.tower-31.messagelabs.com!1455732178!23141569!1 X-Originating-IP: [209.85.161.177] 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 41589 invoked from network); 17 Feb 2016 18:02:59 -0000 Received: from mail-yw0-f177.google.com (HELO mail-yw0-f177.google.com) (209.85.161.177) by server-10.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Feb 2016 18:02:59 -0000 Received: by mail-yw0-f177.google.com with SMTP id h129so19649234ywb.1 for ; Wed, 17 Feb 2016 10:02:59 -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=EPhb9OZVhla3MNNMfB/KNQfaSteriYk2a54SGaOPcJI=; b=Uzn9fUM9lTe1J9HyQcgYXKQkinoOII7BxVYFI+ARVXOlnhWZSYMPnOB4A51YMCMHh9 yFTHXIEL/3oiQd7/hYm+GP/GVKOgUSCoUJGE7xDqMZFv7c7n/5DJTdBHUb5C/9i8BWL2 KZ6Xqs6Y7zsaRrEgcpzpXzJWbVOSHekfMjfE8= 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=EPhb9OZVhla3MNNMfB/KNQfaSteriYk2a54SGaOPcJI=; b=Qgpy2MRkFH3wTljcvhsCLECiAaboN4I/9lpUsA+MkWD1qKx+VwTgudaNRNvDN8Rpei xErXO5RuIdM90cZgYzTk03HoA2HOUuo7JtwtGa2d7/TVpBVgvqhpMaYfjJUJFEPl5RlX HBo1h7j7Vs7pbyTHZlio1biy8zeoz2Lybz72jqNUf5lZ3gY67HAjPv8TJ7x37w8d9SzP Peqnxd8gOoO/ABIbqZMtZ6T/JRJGmM+n4zgXFrUHhF3kVO5Ff6ZyOXRbpiKd72E56nWc Zb6uIG8kxdNeaSbfgaNkhnPQkCkzutV8gD5LUlIkMqUXzTnCnLdCVSB/IpNXIR5Tb3pk GeXw== X-Gm-Message-State: AG10YORrJm50Er3SOjMu1Dllr+CyS3InMGCmCyaLRh/sOnXIGPkmTUChZDn6IFuCw+gpbA== X-Received: by 10.129.152.9 with SMTP id p9mr1627225ywg.85.1455732178014; Wed, 17 Feb 2016 10:02:58 -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 h131sm1561540ywb.25.2016.02.17.10.02.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 17 Feb 2016 10:02:56 -0800 (PST) From: Doug Goldstein To: xen-devel@lists.xen.org Date: Wed, 17 Feb 2016 12:02:44 -0600 Message-Id: <1455732165-27027-1-git-send-email-cardoe@cardoe.com> X-Mailer: git-send-email 2.4.10 Cc: Keir Fraser , Doug Goldstein , Jan Beulich , Andrew Cooper Subject: [Xen-devel] [PATCH v4 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=-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 Allow Xenoprof to be fully disabled when toggling the option off. Signed-off-by: Doug Goldstein --- CC: Keir Fraser CC: Jan Beulich CC: Andrew Cooper change since v3: - drop (void)var; from static inlines - fix typo that broke build (must have forgotten to do XEN_CONFIG_EXPERT=y make change since v2: - move all functions in xenoprof.h inside CONFIG_XENOPROF as suggested by Andrew Cooper change since v1: - switch to #define empty 'functions' as suggested by Andrew Cooper --- xen/arch/x86/Makefile | 2 +- xen/arch/x86/Rules.mk | 2 ++ xen/arch/x86/x86_64/compat/entry.S | 4 ++++ xen/arch/x86/x86_64/entry.S | 4 ++++ xen/include/asm-x86/config.h | 1 - xen/include/asm-x86/xenoprof.h | 19 +++++++++++++++++++ xen/include/xen/xenoprof.h | 25 +++++++++++++++++++------ 7 files changed, 49 insertions(+), 8 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/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 diff --git a/xen/include/asm-x86/xenoprof.h b/xen/include/asm-x86/xenoprof.h index b006ddc..7044084 100644 --- a/xen/include/asm-x86/xenoprof.h +++ b/xen/include/asm-x86/xenoprof.h @@ -67,9 +67,28 @@ void xenoprof_backtrace(struct vcpu *, const struct cpu_user_regs *, "xenoprof/x86 with autotranslated mode enabled" \ "isn't supported yet\n"); \ } while (0) + +#ifdef CONFIG_XENOPROF int passive_domain_do_rdmsr(unsigned int msr, uint64_t *msr_content); int passive_domain_do_wrmsr(unsigned int msr, uint64_t msr_content); void passive_domain_destroy(struct vcpu *v); +#else +static inline int passive_domain_do_rdmsr(unsigned int msr, + uint64_t *msr_content) +{ + return 0; +} + +static inline int passive_domain_do_wrmsr(unsigned int msr, + uint64_t msr_content) +{ + return 0; +} + +static inline void passive_domain_destroy(struct vcpu *v) +{ +} +#endif #endif /* __ASM_X86_XENOPROF_H__ */ diff --git a/xen/include/xen/xenoprof.h b/xen/include/xen/xenoprof.h index 9b9ef56..8148c01 100644 --- a/xen/include/xen/xenoprof.h +++ b/xen/include/xen/xenoprof.h @@ -64,19 +64,32 @@ struct xenoprof { #endif struct domain; -int is_active(struct domain *d); -int is_passive(struct domain *d); -void free_xenoprof_pages(struct domain *d); - -int xenoprof_add_trace(struct vcpu *, uint64_t pc, int mode); - #define PMU_OWNER_NONE 0 #define PMU_OWNER_XENOPROF 1 #define PMU_OWNER_HVM 2 + +#ifdef CONFIG_XENOPROF int acquire_pmu_ownership(int pmu_ownership); void release_pmu_ownership(int pmu_ownership); +int is_active(struct domain *d); +int is_passive(struct domain *d); +void free_xenoprof_pages(struct domain *d); + +int xenoprof_add_trace(struct vcpu *, uint64_t pc, int mode); + void xenoprof_log_event(struct vcpu *, const struct cpu_user_regs *, uint64_t pc, int mode, int event); +#else +static inline int acquire_pmu_ownership(int pmu_ownership) +{ + return 1; +} + +static inline void release_pmu_ownership(int pmu_ownership) +{ +} +#endif + #endif /* __XEN__XENOPROF_H__ */