xtf/vpmu VPMU tests
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
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
@@ -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
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
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 0xc0000102arch/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 0x000001d9Imo 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 0x00000345Overall 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
PATCH 2/2 xtf/vpmu: MSR read/write tests for VPMU
In reply to Mohit GambhirThis 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
@@ -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
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.
Signed-off-by Mohit Gambhir <[email protected]>
[...]
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
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.
Signed-off-by Mohit Gambhir <[email protected]>[...]
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