[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v2 01/10] x86: add an flag to enable Intel Processor Trace in guest



This patch add a new flag to enable Intel Processor Trace
in HVM guest by add parameter 'ipt = guest' in XEN
command line. Intel Processor Trace is disabled
in default.

Signed-off-by: Luwei Kang <luwei.kang@xxxxxxxxx>
---
 docs/misc/xen-command-line.markdown | 10 +++++++++
 xen/arch/x86/cpu/Makefile           |  1 +
 xen/arch/x86/cpu/ipt.c              | 42 +++++++++++++++++++++++++++++++++++++
 xen/include/asm-x86/ipt.h           | 29 +++++++++++++++++++++++++
 4 files changed, 82 insertions(+)
 create mode 100644 xen/arch/x86/cpu/ipt.c
 create mode 100644 xen/include/asm-x86/ipt.h

diff --git a/docs/misc/xen-command-line.markdown 
b/docs/misc/xen-command-line.markdown
index 8712a83..bf8f89a 100644
--- a/docs/misc/xen-command-line.markdown
+++ b/docs/misc/xen-command-line.markdown
@@ -1215,6 +1215,16 @@ Rather than only mapping RAM pages for IOMMU accesses 
for Dom0, with this
 option all pages not marked as unusable in the E820 table will get a mapping
 established.
 
+### ipt
+> `= guest`
+
+> Default: `off`
+
+This option is use for switch on the Intel Processor Trace feature
+in HVM guest when 'ipt=guest'. By default, this feature is disabled
+in guest. Intel Processor Trace virtualization depend on
+EPT, so it can only enabled in HVM guest at present.
+
 ### irq\_ratelimit (x86)
 > `= <integer>`
 
diff --git a/xen/arch/x86/cpu/Makefile b/xen/arch/x86/cpu/Makefile
index 74f23ae..af60277 100644
--- a/xen/arch/x86/cpu/Makefile
+++ b/xen/arch/x86/cpu/Makefile
@@ -6,5 +6,6 @@ obj-y += centaur.o
 obj-y += common.o
 obj-y += intel.o
 obj-y += intel_cacheinfo.o
+obj-y += ipt.o
 obj-y += mwait-idle.o
 obj-y += vpmu.o vpmu_amd.o vpmu_intel.o
diff --git a/xen/arch/x86/cpu/ipt.c b/xen/arch/x86/cpu/ipt.c
new file mode 100644
index 0000000..1fd7f51
--- /dev/null
+++ b/xen/arch/x86/cpu/ipt.c
@@ -0,0 +1,42 @@
+/*
+ * ipt.c: Support for Intel Processor Trace Virtualization.
+ *
+ * Copyright (c) 2018, Intel Corporation.
+ *
+ * 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 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 <http://www.gnu.org/licenses/>.
+ *
+ * Author: Luwei Kang <luwei.kang@xxxxxxxxx>
+ */
+#include <xen/errno.h>
+#include <xen/init.h>
+#include <xen/lib.h>
+#include <xen/string.h>
+#include <asm/ipt.h>
+
+/* ipt: Flag to enable Intel Processor Trace (default off). */
+unsigned int __read_mostly ipt_mode = IPT_MODE_OFF;
+static int parse_ipt_params(const char *str);
+custom_param("ipt", parse_ipt_params);
+
+static int __init parse_ipt_params(const char *str)
+{
+    if ( !strcmp("guest", str) )
+        ipt_mode = IPT_MODE_GUEST;
+    else if ( str )
+    {
+        printk("Unknown Intel Processor Trace mode specified: '%s'\n", str);
+        return -EINVAL;
+    }
+
+    return 0;
+}
diff --git a/xen/include/asm-x86/ipt.h b/xen/include/asm-x86/ipt.h
new file mode 100644
index 0000000..c46b9fc
--- /dev/null
+++ b/xen/include/asm-x86/ipt.h
@@ -0,0 +1,29 @@
+/*
+ * ipt.h: Intel Processor Trace virtualization for HVM domain.
+ *
+ * Copyright (c) 2018, Intel Corporation.
+ *
+ * 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 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 <http://www.gnu.org/licenses/>.
+ *
+ * Author: Luwei Kang <luwei.kang@xxxxxxxxx>
+ */
+
+#ifndef __ASM_X86_HVM_IPT_H_
+#define __ASM_X86_HVM_IPT_H_
+
+#define IPT_MODE_OFF        0
+#define IPT_MODE_GUEST      (1<<0)
+
+extern unsigned int ipt_mode;
+
+#endif /* __ASM_X86_HVM_IPT_H_ */
-- 
1.8.3.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.