From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gleb Natapov Subject: [PATCH] kvm-unit-test: fix cpuid test Date: Mon, 4 Nov 2013 16:04:30 +0200 Message-ID: <20131104140430.GF7513@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: pbonzini@redhat.com To: kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:13762 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751590Ab3KDOEd (ORCPT ); Mon, 4 Nov 2013 09:04:33 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rA4E4Vuk014390 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 4 Nov 2013 09:04:32 -0500 Content-Disposition: inline Sender: kvm-owner@vger.kernel.org List-ID: If cpuid is called with function value greater than max supported one max supported value is used instead and index parameter is honored. That is why we need to initialize index to same value in the test to get same result from both cpuid invocations. diff --git a/x86/realmode.c b/x86/realmode.c index c57e033..0e1cd37 100644 --- a/x86/realmode.c +++ b/x86/realmode.c @@ -1375,6 +1375,7 @@ static void test_cpuid(void) unsigned eax, ebx, ecx, edx; inregs.eax = eax = function; + inregs.ecx = ecx = 0; asm("cpuid" : "+a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx)); exec_in_big_real_mode(&insn_cpuid); report("cpuid", R_AX|R_BX|R_CX|R_DX, -- Gleb.