test: Add XSAVE unit test
PATCH 1/1 test: Add XSAVE unit test
Only test legal action so far, we can extend it later.
--- kvm/test/config-x86-common.mak | 5 +- kvm/test/x86/xsave.c | 173 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 177 insertions(+), 1 deletions(-) create mode 100644 kvm/test/x86/xsave.c
kvm/test/config-x86-common.mak +4 -1
@@ -24,7 +24,8 @@ FLATLIBS = lib/libcflat.a $(libgcc) tests-common = $(TEST_DIR)/vmexit.flat $(TEST_DIR)/tsc.flat \ $(TEST_DIR)/smptest.flat $(TEST_DIR)/port80.flat \ - $(TEST_DIR)/realmode.flat $(TEST_DIR)/msr.flat + $(TEST_DIR)/realmode.flat $(TEST_DIR)/msr.flat \ + $(TEST_DIR)/xsave.flat test_cases: $(tests-common) $(tests)
@@ -58,6 +59,8 @@ $(TEST_DIR)/realmode.o: bits = 32 $(TEST_DIR)/msr.flat: $(cstart.o) $(TEST_DIR)/msr.o +$(TEST_DIR)/xsave.flat: $(cstart.o) $(TEST_DIR)/xsave.o + arch_clean: $(RM) $(TEST_DIR)/*.o $(TEST_DIR)/*.flat \ $(TEST_DIR)/.*.d $(TEST_DIR)/lib/.*.d $(TEST_DIR)/lib/*.o
kvm/test/x86/xsave.c new file +173 -0
173 lines not on this page · raw message
Signature · 1 line
1.7.0.1
Quoted 2 lines · Sheng Yang
Only test legal action so far, we can extend it later.
The legal actions are tested by guests, so it's more important for unit tests to check illegal (and potentially subversive) actions.
Quoted 4 lines
kvm/test/x86/xsave.c new file +3
-0+ +void test_xsave () +{
kvm/test/x86/xsave.c
Quoted 10 lines
kvm/test/x86/xsave.c new file +10
-0+unsigned int cr4; +uint64_t supported_xcr0; +uint64_t test_bits; + + supported_xcr0 =get_supported_xcr0 (); +printf ("Supported XCR0 bits: 0x%x\n" , supported_xcr0); + +printf ("Check minimal XSAVE required bits: " ); + test_bits =XSTATE_FP |XSTATE_SSE |XSTATE_YMM ; +pass_if ((supported_xcr0& test_bits) == test_bits);
This will fail on a cpu without YMM but with xsave.
kvm/test/x86/xsave.c line 171
Quoted 13 lines
kvm/test/x86/xsave.c new file +12
-0+ +int main () +{ +int cpuid_has_xsave; + + cpuid_has_xsave =check_xsave (); +if (cpuid_has_xsave) { +printf ("CPU has XSAVE feature\n" ); +test_xsave (); + }else +printf ("CPU don't has XSAVE feature\n" ); +return 0 ;
Should return 1 if any failure for autotest integration.
Quoted 3 lines
(quoted diff) +2
-0+} +
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 5 lines · On Tuesday 01 June 2010 16:51:05 Avi Kivity wrote:
Quoted 1 line · Sheng Yang
Only test legal action so far, we can extend it later.
The legal actions are tested by guests, so it's more important for unit tests to check illegal (and potentially subversive) actions.
Yes. This is just the first step. I think we need construct IDT and use something similar to fixup exception table. That's not a quick work, and we need some base for it.
Quoted 16 lines
Quoted 4 lines
kvm/test/x86/xsave.c new file +3
-0+ +void test_xsave () +{kvm/test/x86/xsave.c
Quoted 10 lines
kvm/test/x86/xsave.c new file +10
-0+unsigned int cr4; +uint64_t supported_xcr0; +uint64_t test_bits; + + supported_xcr0 =get_supported_xcr0 (); +printf ("Supported XCR0 bits: 0x%x\n" , supported_xcr0); + +printf ("Check minimal XSAVE required bits: " ); + test_bits =XSTATE_FP |XSTATE_SSE |XSTATE_YMM ; +pass_if ((supported_xcr0& test_bits) == test_bits);This will fail on a cpu without YMM but with xsave.
Yes, would discard this...
Quoted 15 lines
kvm/test/x86/xsave.c line 171
Quoted 13 lines
kvm/test/x86/xsave.c new file +12
-0+ +int main () +{ +int cpuid_has_xsave; + + cpuid_has_xsave =check_xsave (); +if (cpuid_has_xsave) { +printf ("CPU has XSAVE feature\n" ); +test_xsave (); + }else +printf ("CPU don't has XSAVE feature\n" ); +return 0 ;Should return 1 if any failure for autotest integration.
OK
Quoted 3 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+} +
--
regards
Yang, Sheng
Quoted 4 lines · Sheng Yang
Quoted 2 lines · On Tuesday 01 June 2010 16:51:05 Avi Kivity wrote:
On 05/31/2010 02:17 PM, Sheng Yang wrote:
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
Only test legal action so far, we can extend it later.
The legal actions are tested by guests, so it's more important for unit tests to check illegal (and potentially subversive) actions.
Yes. This is just the first step. I think we need construct IDT and use something similar to fixup exception table. That's not a quick work, and we need some base for it.
Sure, it's fine to proceed in steps. We do need a framework for trapping exceptions. There's a bit in access.flat (also for running code from cpl 3), we could generalize it.
Signature · 1 line
error compiling committee.c: too many arguments to function