From patchwork Tue Aug 24 13:47:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 126601 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o7ODlubA030294 for ; Tue, 24 Aug 2010 13:47:56 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755303Ab0HXNry (ORCPT ); Tue, 24 Aug 2010 09:47:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:29155 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755237Ab0HXNrx (ORCPT ); Tue, 24 Aug 2010 09:47:53 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o7ODlrqM025823 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 24 Aug 2010 09:47:53 -0400 Received: from [127.0.1.1] (dhcp-65-37.nay.redhat.com [10.66.65.37]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o7ODlphv010896; Tue, 24 Aug 2010 09:47:51 -0400 Subject: [PATCH kvm-unit-tests 08/10] Check whether in long mode before testing vmexit caused by cr8 access To: jasowang@redhat.com, mtosatti@redhat.com, avi@redhat.com, kvm@vger.kernel.org From: Jason Wang Date: Tue, 24 Aug 2010 21:47:51 +0800 Message-ID: <20100824134751.17082.29122.stgit@FreeLancer> In-Reply-To: <20100824134523.17082.8727.stgit@FreeLancer> References: <20100824134523.17082.8727.stgit@FreeLancer> User-Agent: StGit/0.15 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 24 Aug 2010 13:47:56 +0000 (UTC) diff --git a/x86/vmexit.c b/x86/vmexit.c index 819c24b..34b0af4 100644 --- a/x86/vmexit.c +++ b/x86/vmexit.c @@ -48,6 +48,7 @@ static void vmcall(void) #define MSR_EFER 0xc0000080 #define EFER_NX_MASK (1ull << 11) +#define EFER_LMA_MASK (1ull << 10) static void mov_from_cr8(void) { @@ -68,6 +69,15 @@ static int is_smp(void) return cpu_count() > 1; } +static int is_long_mode(void) +{ +#ifdef __i386__ + return 0; +#else + return rdmsr(MSR_EFER) | EFER_LMA_MASK; +#endif +} + static void nop(void *junk) { } @@ -100,8 +110,8 @@ static struct test { } tests[] = { { cpuid_test, "cpuid", .parallel = 1, }, { vmcall, "vmcall", .parallel = 1, }, - { mov_from_cr8, "mov_from_cr8", .parallel = 1, }, - { mov_to_cr8, "mov_to_cr8" , .parallel = 1, }, + { mov_from_cr8, "mov_from_cr8", is_long_mode, .parallel = 1, }, + { mov_to_cr8, "mov_to_cr8" , is_long_mode, .parallel = 1, }, { inl_pmtimer, "inl_from_pmtimer", .parallel = 1, }, { ipi, "ipi", is_smp, .parallel = 0, }, { ipi_halt, "ipi+halt", is_smp, .parallel = 0, },