Skip to contentSkip to conversation

xtf/vpmu VPMU tests

PATCH Superseded Mohit Gambhir 1 participant 3 messages Apr 28, 2017 x86

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 cover xtf/vpmu VPMU tests

v2:

Incorporated review comments received on patch v1.

+ Changed test type from utility to functional
+ Test is now defined only for hvm64 and hvm32 instead of ALL_ENVIRONMENTS
+ Several code styling and formatting changes
+ Expanded test description for doxygen
+ Added max_leaf check before cpuid_count
+ Addded PDCM bit check before reading MSR_PERF_CAPABILTIES

v1:

This patch series adds tests to validate VPMU functionality on x86. The tests write and read PMU MSRs to make sure that that they have been exposed correctly.

The ultimate goal is to address security vulnerabilities, if any, that are vaguely mentioned in XSA-163 and make VPMU available to guests with reasonable caveats.

Further testing is required to validate the MSR state save/restore functionality of the VPMU, concurrent usage of the counters by a number of guests and analyze if any other non-PMU MSRs have been exposed incorrectly.

Mohit Gambhir (2):
xtf/vpmu: Add Intel PMU MSR addresses
xtf/vpmu: MSR read/write tests for VPMU

 arch/x86/include/arch/msr-index.h |  12 ++
 tests/vpmu/Makefile               |   9 +
 tests/vpmu/main.c                 | 433 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 454 insertions(+)
 create mode 100644 tests/vpmu/Makefile
 create mode 100644 tests/vpmu/main.c
Signature · 7 lines
2.9.3


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#1 lore raw

PATCH v2 1/2 xtf/vpmu: Add Intel PMU MSR addresses

This patch adds Intel PMU MSR addresses as macros for VPMU testing

---
 arch/x86/include/arch/msr-index.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/x86/include/arch/msr-index.h +12 -0
index 72373c6..911d7f9 100644
@@ -3,6 +3,8 @@
 
 #include <xtf/numbers.h>
 
+#define MSR_PMC(n)                      (0x000000c1 + (n))
+
 #define MSR_INTEL_PLATFORM_INFO         0x000000ce
 #define _MSR_PLATFORM_INFO_CPUID_FAULTING       31
 #define MSR_PLATFORM_INFO_CPUID_FAULTING        (1ULL << _MSR_PLATFORM_INFO_CPUID_FAULTING)
@@ -11,10 +13,20 @@
 #define _MSR_MISC_FEATURES_CPUID_FAULTING        0
 #define MSR_MISC_FEATURES_CPUID_FAULTING         (1ULL << _MSR_MISC_FEATURES_CPUID_FAULTING)
 
+#define MSR_PERFEVTSEL(n)               (0x00000186 + (n))
+
 #define MSR_DEBUGCTL                    0x000001d9
 #define _MSR_DEBUGCTL_LBR               0 /* Last Branch Record. */
 #define MSR_DEBUGCTL_LBR                (_AC(1, L) << _MSR_DEBUGCTL_LBR)
 
+#define MSR_FIXED_CTR(n)                (0x00000309 + (n))
+#define MSR_PERF_CAPABILITIES           0x00000345
+#define MSR_FIXED_CTR_CTRL              0x0000038d
+#define MSR_PERF_GLOBAL_STATUS          0x0000038e
+#define MSR_PERF_GLOBAL_CTRL            0x0000038f
+#define MSR_PERF_GLOBAL_OVF_CTRL        0x00000390
+#define MSR_A_PMC(n)                    (0x000004c1 + (n))
+
 #define MSR_EFER                        0xc0000080 /* Extended Feature register. */
 #define _EFER_SCE                       0  /* SYSCALL Enable. */
 #define EFER_SCE                        (_AC(1, L) << _EFER_SCE)
Signature · 7 lines
2.9.3


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#2 lore raw

PATCH v2 2/2 xtf/vpmu: MSR read/write tests for VPMU

In reply to Mohit Gambhir

This patch tests VPMU functionality in the hypervisor on Intel machines. The tests write to all valid bits in the MSRs that get exposed to the guests when VPMU is enabled. The tests also write invalid values to the bits that should be masked and expect the wrmsr call to fault.

The tests are currently unsupported for AMD machines and PV guests.

---
 tests/vpmu/Makefile |   9 ++
 tests/vpmu/main.c   | 442 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 451 insertions(+)
 create mode 100644 tests/vpmu/Makefile
 create mode 100644 tests/vpmu/main.c
tests/vpmu/Makefile new file +9 -0
new file mode 100644
index 0000000..57eb29d
@@ -0,0 +1,9 @@
+include $(ROOT)/build/common.mk
+
+NAME      := vpmu
+CATEGORY  := functional
+TEST-ENVS := hvm64 hvm32
+
+obj-perenv += main.o
+
+include $(ROOT)/build/gen.mk
tests/vpmu/main.c new file +442 -0

442 lines not on this page · raw message

Signature · 7 lines
2.9.3


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel