Skip to contentSkip to conversation

xtf/vpmu VPMU tests

PATCH Superseded Mohit Gambhir 3 participants 7 messages Apr 20, 2017 – Apr 24, 2017 x86

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

cover xtf/vpmu VPMU tests

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 |  11 +
 tests/vpmu/Makefile               |   9 +
 tests/vpmu/main.c                 | 502 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 522 insertions(+)
 create mode 100644 tests/vpmu/Makefile
 create mode 100644 tests/vpmu/main.c

--
2.9.3

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

#1 lore raw

PATCH 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 | 11 +++++++++++
 1 file changed, 11 insertions(+)
arch/x86/include/arch/msr-index.h +11 -0
index 2e90079..7df9097 100644
@@ -38,6 +38,17 @@
 #define MSR_GS_BASE                     0xc0000101
 #define MSR_SHADOW_GS_BASE              0xc0000102
 
+#define MSR_IA32_PMC(n)                 (0x000000c1 + (n))
+#define MSR_IA32_A_PMC(n)               (0x000004c1 + (n))
+#define MSR_IA32_PERFEVTSEL(n)          (0x00000186 + (n))
+#define MSR_IA32_FIXED_CTR(n)           (0x00000309 + (n))
+#define MSR_IA32_FIXED_CTR_CTRL         0x0000038d
+#define MSR_IA32_PERF_GLOBAL_CTRL       0x0000038f
+#define MSR_IA32_PERF_GLOBAL_STATUS     0x0000038e
+#define MSR_IA32_PERF_GLOBAL_OVF_CTRL   0x00000390
+#define MSR_IA32_DEBUGCTL               0x000001d9
+#define MSR_IA32_PERF_CAPABILITIES      0x00000345
+
 #endif /* XFT_X86_MSR_INDEX_H */
 
 /*
Signature · 7 lines
2.9.3


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

Re: [PATCH 1/2][XTF] xtf/vpmu: Add Intel PMU MSR addresses

Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 20.04.17 at 22:40, <[email protected]> wrote:
arch/x86/include/arch/msr-index.h +0 -0
@@ -38,6 +38,17 @@
 #define MSR_GS_BASE                     0xc0000101
 #define MSR_SHADOW_GS_BASE              0xc0000102

arch/x86/include/arch/msr-index.h line 49

Quoted 10 lines
arch/x86/include/arch/msr-index.h +9 -0
 
+#define MSR_IA32_PMC(n)                 (0x000000c1 + (n))
+#define MSR_IA32_A_PMC(n)               (0x000004c1 + (n))
+#define MSR_IA32_PERFEVTSEL(n)          (0x00000186 + (n))
+#define MSR_IA32_FIXED_CTR(n)           (0x00000309 + (n))
+#define MSR_IA32_FIXED_CTR_CTRL         0x0000038d
+#define MSR_IA32_PERF_GLOBAL_CTRL       0x0000038f
+#define MSR_IA32_PERF_GLOBAL_STATUS     0x0000038e
+#define MSR_IA32_PERF_GLOBAL_OVF_CTRL   0x00000390
+#define MSR_IA32_DEBUGCTL               0x000001d9

Imo this should be put in the middle of PMU MSRs.

arch/x86/include/arch/msr-index.h line 50

Quoted 1 line
arch/x86/include/arch/msr-index.h +1 -0
+#define MSR_IA32_PERF_CAPABILITIES      0x00000345

Overall I also think it would be nice for things to be sorted in some way at least inside this block (perhaps numerically).

Jan

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

#3 lore raw

Re: [PATCH 1/2][XTF] xtf/vpmu: Add Intel PMU MSR addresses

Quoted 18 lines · Jan Beulich
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 20.04.17 at 22:40, <[email protected]> wrote:
arch/x86/include/arch/msr-index.h +0 -0
@@ -38,6 +38,17 @@
  #define MSR_GS_BASE                     0xc0000101
  #define MSR_SHADOW_GS_BASE              0xc0000102

arch/x86/include/arch/msr-index.h line 49

Quoted 10 lines
arch/x86/include/arch/msr-index.h +9 -0
 
+#define MSR_IA32_PMC(n)                 (0x000000c1 + (n))
+#define MSR_IA32_A_PMC(n)               (0x000004c1 + (n))
+#define MSR_IA32_PERFEVTSEL(n)          (0x00000186 + (n))
+#define MSR_IA32_FIXED_CTR(n)           (0x00000309 + (n))
+#define MSR_IA32_FIXED_CTR_CTRL         0x0000038d
+#define MSR_IA32_PERF_GLOBAL_CTRL       0x0000038f
+#define MSR_IA32_PERF_GLOBAL_STATUS     0x0000038e
+#define MSR_IA32_PERF_GLOBAL_OVF_CTRL   0x00000390
+#define MSR_IA32_DEBUGCTL               0x000001d9

Imo this should be put in the middle of PMU MSRs.

Quoted 3 lines

arch/x86/include/arch/msr-index.h line 50

Quoted 1 line
arch/x86/include/arch/msr-index.h +1 -0
+#define MSR_IA32_PERF_CAPABILITIES      0x00000345

Overall I also think it would be nice for things to be sorted in some way at least inside this block (perhaps numerically).

Fixed in v2

Quoted 7 lines

Jan

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

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

#4 lore raw

PATCH 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   | 502 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 511 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..1eaf436
@@ -0,0 +1,9 @@
+include $(ROOT)/build/common.mk
+
+NAME      := vpmu
+CATEGORY  := utility
+TEST-ENVS := $(ALL_ENVIRONMENTS)
+
+obj-perenv += main.o
+
+include $(ROOT)/build/gen.mk
tests/vpmu/main.c new file +502 -0

502 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
#5 lore raw

Re: [PATCH 2/2][XTF] xtf/vpmu: MSR read/write tests for VPMU

Quoted 8 lines · 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.

[...]

Quoted 15 lines
tests/vpmu/main.c new file +15 -0
+void test_main(void)
+{
+    /* Architectural Performance Monitoring Version */
+    uint8_t ver;
+
+    /* Number of general purpose counter registers */
+    uint8_t ngregs;
+
+    /* Number of fixed function counter registers */
+    uint8_t nfregs;
+
+    /* Bit width of general-purpose, performance monitoring counter */
+    uint8_t ngbits;
+
+    if ( IS_DEFINED(CONFIG_PV) )

tests/vpmu/main.c line 447

Quoted 10 lines
tests/vpmu/main.c new file +10 -0
+    {
+        printk("VPMU testing for PV guests currently unsupported\n");
+        goto out;
+    }
+
+    if ( vendor_is_amd )
+    {
+        printk("VPMU testing for AMD currently unsupported\n");
+        goto out;
+    }

These two cases should probably return SKIP instead of SUCCESS.

Wei.

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

#6 lore raw

Re: [PATCH 2/2][XTF] xtf/vpmu: MSR read/write tests for VPMU

Quoted 28 lines · Wei Liu
Quoted 8 lines · 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.

[...]

Quoted 18 lines
tests/vpmu/main.c new file +18 -0
+void test_main(void)
+{
+    /* Architectural Performance Monitoring Version */
+    uint8_t ver;
+
+    /* Number of general purpose counter registers */
+    uint8_t ngregs;
+
+    /* Number of fixed function counter registers */
+    uint8_t nfregs;
+
+    /* Bit width of general-purpose, performance monitoring counter */
+    uint8_t ngbits;
+
+    if ( IS_DEFINED(CONFIG_PV) )
+    {
+        printk("VPMU testing for PV guests currently unsupported\n");
+        goto out;
Quoted 8 lines

tests/vpmu/main.c line 447

Quoted 7 lines
tests/vpmu/main.c new file +7 -0
+    }
+
+    if ( vendor_is_amd )
+    {
+        printk("VPMU testing for AMD currently unsupported\n");
+        goto out;
+    }

These two cases should probably return SKIP instead of SUCCESS.

Fixed in v2

Quoted 1 line

Wei.

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