From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH] test: Add XSAVE unit test Date: Tue, 01 Jun 2010 11:51:05 +0300 Message-ID: <4C04C9F9.3080703@redhat.com> References: <1275304621-29668-1-git-send-email-sheng@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Marcelo Tosatti , kvm@vger.kernel.org To: Sheng Yang Return-path: Received: from mx1.redhat.com ([209.132.183.28]:40129 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754167Ab0FAIvI (ORCPT ); Tue, 1 Jun 2010 04:51:08 -0400 In-Reply-To: <1275304621-29668-1-git-send-email-sheng@linux.intel.com> Sender: kvm-owner@vger.kernel.org List-ID: On 05/31/2010 02:17 PM, Sheng Yang wrote: > 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. > + > +void test_xsave() > +{ > + 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. > + > +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. > +} > + > -- error compiling committee.c: too many arguments to function