From patchwork Wed May 12 08:00:10 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 98929 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4C80IbF011867 for ; Wed, 12 May 2010 08:00:19 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750894Ab0ELIAQ (ORCPT ); Wed, 12 May 2010 04:00:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:28790 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752344Ab0ELIAO (ORCPT ); Wed, 12 May 2010 04:00:14 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o4C80DrC017608 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 12 May 2010 04:00:13 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o4C80B09020995 for ; Wed, 12 May 2010 04:00:11 -0400 Received: from localhost.localdomain (file.tlv.redhat.com [10.35.255.8]) by cleopatra.tlv.redhat.com (Postfix) with ESMTP id D779B250059; Wed, 12 May 2010 11:00:10 +0300 (IDT) From: Avi Kivity To: Marcelo Tosatti , kvm@vger.kernel.org Subject: [PATCH] test: emulator: lmsw may not clear cr0.pe Date: Wed, 12 May 2010 11:00:10 +0300 Message-Id: <1273651210-29007-1-git-send-email-avi@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 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]); Wed, 12 May 2010 08:00:19 +0000 (UTC) diff --git a/kvm/user/test/x86/emulator.c b/kvm/user/test/x86/emulator.c index 5406062..e677e3a 100644 --- a/kvm/user/test/x86/emulator.c +++ b/kvm/user/test/x86/emulator.c @@ -267,6 +267,15 @@ void test_lmsw(void) asm("lmsw %0" : : "m"(*pmsw)); printf("before %lx after %lx\n", cr0, read_cr0()); report("lmsw (2)", cr0 == read_cr0()); + + /* lmsw can't clear cr0.pe */ + msw = (cr0 & ~1ul) ^ 4; /* change EM to force trap */ + asm("lmsw %0" : : "r"(msw)); + report("lmsw (3)", (cr0 ^ read_cr0()) == 4 && (cr0 & 1)); + + /* back to normal */ + msw = cr0; + asm("lmsw %0" : : "r"(msw)); } int main()