From patchwork Fri Aug 11 15:25:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felix Schmoll X-Patchwork-Id: 9896209 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 7452960236 for ; Fri, 11 Aug 2017 15:28:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 64AD328C54 for ; Fri, 11 Aug 2017 15:28:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5965A28C59; Fri, 11 Aug 2017 15:28:22 +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=-3.6 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 4EF7A28C54 for ; Fri, 11 Aug 2017 15:28: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 1dgBon-0005Ax-7m; Fri, 11 Aug 2017 15:25:45 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dgBol-0005Al-R8 for xen-devel@lists.xen.org; Fri, 11 Aug 2017 15:25:44 +0000 Received: from [193.109.254.147] by server-7.bemta-6.messagelabs.com id 61/5E-03557-77CCD895; Fri, 11 Aug 2017 15:25:43 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprFIsWRWlGSWpSXmKPExsXiVRvkpFt2pjf SYHOGxZKPi1kcGD2O7v7NFMAYxZqZl5RfkcCa8X/uUraCbxUV/3f/ZWxgnJvcxcjFISQwkVHi zNEzLCAOi8AlFomd07uYQRwJgXcsEt/2b2PqYuQAcuIk+k+FdjFyApnlEguWfWYHsYUENCW+d HcxQkz6xyjRP2khC0iCTcBAYvbKi8wgtoiAksS9VZOZQIqYBdYxSyy89hMsISzgI7Hj9QywSS wCqhLnfrxnA7F5Bewknq15xQixTV5iV9tF1gmMfAsYGVYxahSnFpWlFukaGuglFWWmZ5TkJmb mAHlmermpxcWJ6ak5iUnFesn5uZsYgaHCAAQ7GI+/jzvEKMnBpCTKm+DTGynEl5SfUpmRWJwR X1Sak1p8iFGGg0NJgnfHaaCcYFFqempFWmYOMGhh0hIcPEoivJkgad7igsTc4sx0iNQpRnuOD avXf2HiWNCzAUhOOrAdSL6a8P8bkxBLXn5eqpQ4rwVImwBIW0ZpHtxQWJRdYpSVEuZlBDpTiK cgtSg3swRV/hWjOAejkjBvEcgUnsy8Erjdr4DOYgI6q88H7KySRISUVANjbcjsHKGKVQtCniX 2LTv/ynO64XyTu2U/4/tMDinPsAu5bvJmk6e6Vn193Y69m5iazyqfaN5aPV3y12IRX5ajs0s0 k45ull9iekpfJtnzuN0nhaWB31WXxrUeP35V9Vhexeb6Z9nqPyPyDhvn+U2PrZ1qYvxTfFG8J b+fWbL876gV099xO2QrsRRnJBpqMRcVJwIA/L9IfK0CAAA= X-Env-Sender: eggi.innovations@gmail.com X-Msg-Ref: server-3.tower-27.messagelabs.com!1502465141!111121161!1 X-Originating-IP: [74.125.82.66] X-SpamReason: No, hits=0.7 required=7.0 tests=BODY_RANDOM_LONG, RCVD_ILLEGAL_IP X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 58871 invoked from network); 11 Aug 2017 15:25:41 -0000 Received: from mail-wm0-f66.google.com (HELO mail-wm0-f66.google.com) (74.125.82.66) by server-3.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 11 Aug 2017 15:25:41 -0000 Received: by mail-wm0-f66.google.com with SMTP id q189so6892747wmd.0 for ; Fri, 11 Aug 2017 08:25:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=AU7QAqi9wkT0WYZHsP25vz1mRfqnSNHXvZWCt/0rPMA=; b=AqOq0hhNVsgRLidMJHG9L7CpD3fcTl/owlvOOSP2fP2sel5fIdiL4R5yvXBMnSJ+lk hIkDMetOKKxmu6KmFz31MpOGRDafKDOXNOPM3EgniMYtJt2oxTyh8jrPEa7562ZkoqWV 9OdvmYKlMUA3erEe8SJR+cQCtPaVC4xPVAZpS8xt7mNnJQNnu8/DpebtAF459+mzdHs5 uI7hQqKqaLcFA+4DfilWiLwFZJZv4+CoMSJTKElNBqmeWMuk3rFbDNhzL9wluJFZnMwo ngQC2MDh+BwbiGTicuKXR79hNbFT2+PZzVaKf9lQgiMpquByHYIJYL/hJo/i3XCknwg5 DX7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=AU7QAqi9wkT0WYZHsP25vz1mRfqnSNHXvZWCt/0rPMA=; b=Zubvd1PEU2ZI6JTkbufswJhJo/gICsTiatjjNsOpxXzMbNLbJhwmOVttaUmCOuJwO3 uU4KPdhMbcllKDEwDKsMRPl/+CY/yozS8xG8t4Xm/pHVCWIv+cEh5Grbk15uuLlgKsRe cd7TTs05AdCA3J1FmP8he9WEv7+s31HUsUHI8wT9xTM+dTPOe7duLzVKF+BhzhrrzkZx 9aso530san8Oxgml//gv0cbsiSBxIBpeS5CF+CFTATdpI8l33hTOWTvodBrJFYou+T1G 2nGY/TwGn9A0NKY3voZQhRlPog/XfORn/N3LKnxTiaouZKHXeTdUhrVgQIZU0VVm1r3r tBrw== X-Gm-Message-State: AHYfb5hZgzq6kh0mu4NSW2X/4BznFog6XcNh1SMuTZBtV9DRPD1DMhW4 CnRu7WiqcjyxEA== X-Received: by 10.28.58.19 with SMTP id h19mr9139207wma.85.1502465141404; Fri, 11 Aug 2017 08:25:41 -0700 (PDT) Received: from localhost.localdomain ([2.216.91.240]) by smtp.gmail.com with ESMTPSA id p83sm1107336wmf.38.2017.08.11.08.25.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Aug 2017 08:25:40 -0700 (PDT) From: Felix Schmoll To: xen-devel@lists.xenproject.org Date: Fri, 11 Aug 2017 17:25:34 +0200 Message-Id: <20170811152534.3536-1-eggi.innovations@gmail.com> X-Mailer: git-send-email 2.11.0 Cc: Stefano Stabellini , Wei Liu , George Dunlap , Andrew Cooper , Felix Schmoll , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich , xen-devel@lists.xen.org Subject: [Xen-devel] [PATCH v3] xen: Implement hypercall for tracing of program counters 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 This commit makes the changes to the hypervisor, the build system as well as libxc necessary in order to facilitate tracing of program counters. A discussion of the design can be found in the mailing list: https://lists.xen.org/archives/html/xen-devel/2017-05/threads.html#02210 The list of files to be included for tracing might still be too extensive, resulting in indeterministic tracing output for some use cases. Signed-off-by: Felix Schmoll --- Changed since v2: * Fix bug that hypercall wouldn't return -EFAULT * Adjust error return codes of hypercall * Add description to Kconfig * Move compile-option from Kconfig to Kconfig.debug * Formatting changes --- CC: Andrew Cooper CC: George Dunlap CC: Ian Jackson CC: Jan Beulich CC: Konrad Rzeszutek Wilk CC: Stefano Stabellini CC: Tim Deegan CC: Wei Liu CC: Julien Grall CC: xen-devel@lists.xen.org --- xen/Kconfig.debug | 7 +++- xen/Rules.mk | 4 ++ xen/arch/arm/traps.c | 1 + xen/arch/x86/Makefile | 2 + xen/arch/x86/hvm/hypercall.c | 1 + xen/arch/x86/hypercall.c | 1 + xen/arch/x86/pv/Makefile | 2 + xen/arch/x86/pv/hypercall.c | 1 + xen/common/Makefile | 13 ++++++ xen/common/domain.c | 4 ++ xen/common/trace_pc.c | 96 +++++++++++++++++++++++++++++++++++++++++++ xen/common/trace_pc_stub.c | 39 ++++++++++++++++++ xen/include/public/trace_pc.h | 38 +++++++++++++++++ xen/include/public/xen.h | 1 + xen/include/xen/hypercall.h | 7 ++++ xen/include/xen/sched.h | 6 +++ xen/include/xen/trace_pc.h | 31 ++++++++++++++ 17 files changed, 253 insertions(+), 1 deletion(-) create mode 100644 xen/common/trace_pc.c create mode 100644 xen/common/trace_pc_stub.c create mode 100644 xen/include/public/trace_pc.h create mode 100644 xen/include/xen/trace_pc.h diff --git a/xen/Kconfig.debug b/xen/Kconfig.debug index 689f2974c0..d87dcd78f4 100644 --- a/xen/Kconfig.debug +++ b/xen/Kconfig.debug @@ -98,7 +98,6 @@ config PERF_ARRAYS ---help--- Enables software performance counter array histograms. - config VERBOSE_DEBUG bool "Verbose debug messages" default DEBUG @@ -114,6 +113,12 @@ config DEVICE_TREE_DEBUG logged in the Xen ring buffer. If unsure, say N here. +config TRACE_PC + bool "Enable pc-tracing" + default false + ---help--- + Adds tracing support to the hypervisor (needed for the trace_pc hypercall). + endif # DEBUG || EXPERT endmenu diff --git a/xen/Rules.mk b/xen/Rules.mk index 77bcd44922..dde14e3228 100644 --- a/xen/Rules.mk +++ b/xen/Rules.mk @@ -170,6 +170,10 @@ clean:: $(addprefix _clean_, $(subdir-all)) _clean_%/: FORCE $(MAKE) -f $(BASEDIR)/Rules.mk -C $* clean +ifeq ($(CONFIG_TRACE_PC),y) +$(objs-need-tracing): CFLAGS += -fsanitize-coverage=trace-pc +endif + %.o: %.c Makefile $(CC) $(CFLAGS) -c $< -o $@ diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index c07999b518..247a68c964 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -1419,6 +1419,7 @@ static arm_hypercall_t arm_hypercall_table[] = { HYPERCALL(platform_op, 1), HYPERCALL_ARM(vcpu_op, 3), HYPERCALL(vm_assist, 2), + HYPERCALL(trace_pc, 4), }; #ifndef NDEBUG diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile index 93ead6e5dd..b283c3e22c 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -74,6 +74,8 @@ efi-y := $(shell if [ ! -r $(BASEDIR)/include/xen/compile.h -o \ -O $(BASEDIR)/include/xen/compile.h ]; then \ echo '$(TARGET).efi'; fi) +objs-need-tracing := cpuid.o hypercall.o + ifneq ($(build_id_linker),) notes_phdrs = --notes else diff --git a/xen/arch/x86/hvm/hypercall.c b/xen/arch/x86/hvm/hypercall.c index e7238ce293..b59d7d481e 100644 --- a/xen/arch/x86/hvm/hypercall.c +++ b/xen/arch/x86/hvm/hypercall.c @@ -132,6 +132,7 @@ static const hypercall_table_t hvm_hypercall_table[] = { COMPAT_CALL(mmuext_op), HYPERCALL(xenpmu_op), COMPAT_CALL(dm_op), + HYPERCALL(trace_pc), HYPERCALL(arch_1) }; diff --git a/xen/arch/x86/hypercall.c b/xen/arch/x86/hypercall.c index e30181817a..672ffe7ef5 100644 --- a/xen/arch/x86/hypercall.c +++ b/xen/arch/x86/hypercall.c @@ -68,6 +68,7 @@ const hypercall_args_t hypercall_args_table[NR_hypercalls] = ARGS(xenpmu_op, 2), ARGS(dm_op, 3), ARGS(mca, 1), + ARGS(trace_pc, 4), ARGS(arch_1, 1), }; diff --git a/xen/arch/x86/pv/Makefile b/xen/arch/x86/pv/Makefile index 4e15484471..8c3eccdfd7 100644 --- a/xen/arch/x86/pv/Makefile +++ b/xen/arch/x86/pv/Makefile @@ -11,3 +11,5 @@ obj-y += traps.o obj-bin-y += dom0_build.init.o obj-bin-y += gpr_switch.o + +objs-need-tracing += hypercall.o diff --git a/xen/arch/x86/pv/hypercall.c b/xen/arch/x86/pv/hypercall.c index f79f7eef62..13eb2e86a2 100644 --- a/xen/arch/x86/pv/hypercall.c +++ b/xen/arch/x86/pv/hypercall.c @@ -80,6 +80,7 @@ static const hypercall_table_t pv_hypercall_table[] = { HYPERCALL(xenpmu_op), COMPAT_CALL(dm_op), HYPERCALL(mca), + HYPERCALL(trace_pc), HYPERCALL(arch_1), }; diff --git a/xen/common/Makefile b/xen/common/Makefile index 26c5a64337..4e39dc66e0 100644 --- a/xen/common/Makefile +++ b/xen/common/Makefile @@ -55,6 +55,8 @@ obj-y += tasklet.o obj-y += time.o obj-y += timer.o obj-y += trace.o +obj-y += trace_pc.o +obj-$(CONFIG_TRACE_PC) += trace_pc_stub.o obj-y += version.o obj-y += virtual_region.o obj-y += vm_event.o @@ -80,3 +82,14 @@ subdir-$(CONFIG_GCOV) += gcov subdir-y += libelf subdir-$(CONFIG_HAS_DEVICE_TREE) += libfdt + +objs-need-tracing := bsearch.o \ + decompress.o device_tree.o domain.o domctl.o earlycpio.o grant_table.o \ + guestcopy.o gunzip.o inflate.o kernel.o kexec.o keyhandler.o kimage.o \ + lib.o livepatch.o lzo.o mem_access.o memory.o multicall.o notifier.o \ + page_alloc.o pdx.o perfc.o radix_tree.o rangeset.o \ + rbtree.o shutdown.o sort.o stop_machine.o \ + symbols.o symbols-dummy.o sysctl.o time.o tmem.o \ + tmem_control.o tmem_xen.o trace.o unlz4.o unlzo.o unxz.o version.o \ + virtual_region.o vmap.o vm_event.o warning.o xenoprof.o \ + xmalloc_tlsf.o diff --git a/xen/common/domain.c b/xen/common/domain.c index b22aacc57e..c98a0a94ec 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -874,6 +874,10 @@ void domain_destroy(struct domain *d) rcu_assign_pointer(*pd, d->next_in_hashbucket); spin_unlock(&domlist_update_lock); +#ifdef CONFIG_TRACE_PC + xfree(d->tracing_buffer); +#endif + /* Schedule RCU asynchronous completion of domain destroy. */ call_rcu(&d->rcu, complete_domain_destroy); } diff --git a/xen/common/trace_pc.c b/xen/common/trace_pc.c new file mode 100644 index 0000000000..722572c500 --- /dev/null +++ b/xen/common/trace_pc.c @@ -0,0 +1,96 @@ +/****************************************************************************** + * trace_pc.c + * + * Implementation of the program counter tracing hypercall. + * + * Copyright (c) 2017 Felix Schmoll + * + * This program is free software; you can redistribute it and/or + * modify it under the terms and conditions of the GNU General Public + * License, version 2, 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 +#include +#include +#include + +long do_trace_pc(domid_t dom, int mode, unsigned int size, + XEN_GUEST_HANDLE_PARAM(uint64_t) buf) +{ +#ifdef CONFIG_TRACE_PC + int ret = 0; + struct domain *d; + + if ( dom == DOMID_SELF ) + d = current->domain; + else + d = get_domain_by_id(dom); + + if ( !d ) + return -ESRCH; /* invalid domain */ + + switch ( mode ) + { + case XEN_TRACE_PC_START: + { + if ( d->tracing_buffer ) + { + ret = -EBUSY; /* domain already being traced */ + break; + } + + d->tracing_buffer_pos = 0; + d->tracing_buffer_size = size; + d->tracing_buffer = xmalloc_array(uint64_t, size); + + if ( !d->tracing_buffer ) + ret = -ENOMEM; + break; + } + + case XEN_TRACE_PC_STOP: + { + uint64_t *temp = d->tracing_buffer; + d->tracing_buffer = NULL; + + if ( copy_to_guest(buf, temp, d->tracing_buffer_pos) ) + ret = -EFAULT; + else + ret = d->tracing_buffer_pos; + + xfree(temp); + + break; + } + + default: + ret = -ENOSYS; + } + + if ( dom != DOMID_SELF ) + put_domain(d); + + return ret; +#else + return -EOPNOTSUPP; +#endif +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/common/trace_pc_stub.c b/xen/common/trace_pc_stub.c new file mode 100644 index 0000000000..4aba7dba9f --- /dev/null +++ b/xen/common/trace_pc_stub.c @@ -0,0 +1,39 @@ +/****************************************************************************** + * trace_pc_stub.c + * + * Edge function/stub for the program counter tracing hypercall. + * + * Copyright (c) 2017 Felix Schmoll + * + * This program is free software; you can redistribute it and/or + * modify it under the terms and conditions of the GNU General Public + * License, version 2, 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 +#include + +void __sanitizer_cov_trace_pc(void) +{ + struct domain *d; + + if ( system_state < SYS_STATE_active ) + return; + + d = current->domain; + + if ( d->tracing_buffer && + (d->tracing_buffer_pos < d->tracing_buffer_size) ) + { + d->tracing_buffer[d->tracing_buffer_pos++] = + (uint64_t) __builtin_return_address(0); + } +} diff --git a/xen/include/public/trace_pc.h b/xen/include/public/trace_pc.h new file mode 100644 index 0000000000..54e430a561 --- /dev/null +++ b/xen/include/public/trace_pc.h @@ -0,0 +1,38 @@ +/****************************************************************************** + * trace_pc.h + * + * Macros for program counter tracing hypercall. + * + * Copyright (C) 2017 Felix Schmoll + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef __XEN_PUBLIC_TRACE_PC_H__ +#define __XEN_PUBLIC_TRACE_PC_H__ + +#if defined(__XEN__) || defined(__XEN_TOOLS__) + +#define XEN_TRACE_PC_START 0 +#define XEN_TRACE_PC_STOP 1 + +#endif /* defined(__XEN__) || defined(__XEN_TOOLS__) */ + +#endif /* __XEN_PUBLIC_TRACE_PC_H__ */ diff --git a/xen/include/public/xen.h b/xen/include/public/xen.h index 2ac6b1e24d..95d83c21ce 100644 --- a/xen/include/public/xen.h +++ b/xen/include/public/xen.h @@ -121,6 +121,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_ulong_t); #define __HYPERVISOR_xc_reserved_op 39 /* reserved for XenClient */ #define __HYPERVISOR_xenpmu_op 40 #define __HYPERVISOR_dm_op 41 +#define __HYPERVISOR_trace_pc 42 /* Architecture-specific hypercall definitions. */ #define __HYPERVISOR_arch_0 48 diff --git a/xen/include/xen/hypercall.h b/xen/include/xen/hypercall.h index cc99aea57d..aa6269e7b7 100644 --- a/xen/include/xen/hypercall.h +++ b/xen/include/xen/hypercall.h @@ -83,6 +83,13 @@ do_xen_version( XEN_GUEST_HANDLE_PARAM(void) arg); extern long +do_trace_pc( + domid_t dom_id, + int mode, + unsigned int size, + XEN_GUEST_HANDLE_PARAM(uint64_t) buf); + +extern long do_console_io( int cmd, int count, diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 6673b27d88..4bd3fe2417 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -483,6 +483,12 @@ struct domain unsigned int guest_request_enabled : 1; unsigned int guest_request_sync : 1; } monitor; + +#ifdef CONFIG_TRACE_PC + uint64_t* tracing_buffer; + unsigned int tracing_buffer_pos; + unsigned int tracing_buffer_size; +#endif }; /* Protect updates/reads (resp.) of domain_list and domain_hash. */ diff --git a/xen/include/xen/trace_pc.h b/xen/include/xen/trace_pc.h new file mode 100644 index 0000000000..631815de30 --- /dev/null +++ b/xen/include/xen/trace_pc.h @@ -0,0 +1,31 @@ +/****************************************************************************** + * trace_pc.h + * + * Declarations for the program counter tracing hypercall + * + * Copyright (C) 2017 Felix Schmoll + * + * This program is free software; you can redistribute it and/or + * modify it under the terms and conditions of the GNU General Public + * License, version 2, 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 __TRACE_PC_H__ +#define __TRACE_PC_H__ + +#include +#include + +#include + +void __sanitizer_cov_trace_pc(void); + +#endif /* __TRACE_PC_H__ */