From patchwork Wed Dec 22 15:06:24 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gleb Natapov X-Patchwork-Id: 427951 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oBMF7VsU014364 for ; Wed, 22 Dec 2010 15:07:32 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753568Ab0LVPHF (ORCPT ); Wed, 22 Dec 2010 10:07:05 -0500 Received: from mx1.redhat.com ([209.132.183.28]:14405 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753248Ab0LVPGc (ORCPT ); Wed, 22 Dec 2010 10:06:32 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oBMF6Won013048 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 22 Dec 2010 10:06:32 -0500 Received: from dhcp-1-237.tlv.redhat.com (dhcp-1-237.tlv.redhat.com [10.35.1.237]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id oBMF6V1w003730; Wed, 22 Dec 2010 10:06:32 -0500 Received: by dhcp-1-237.tlv.redhat.com (Postfix, from userid 13519) id B9CF218D3F8; Wed, 22 Dec 2010 17:06:29 +0200 (IST) From: Gleb Natapov To: avi@redhat.com, mtosatti@redhat.com Cc: kvm@vger.kernel.org Subject: [PATCH unit-tests 11/16] Set WP bit in CR0 to make write protection work. Date: Wed, 22 Dec 2010 17:06:24 +0200 Message-Id: <1293030389-1143-12-git-send-email-gleb@redhat.com> In-Reply-To: <1293030389-1143-1-git-send-email-gleb@redhat.com> References: <1293030389-1143-1-git-send-email-gleb@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 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 (demeter1.kernel.org [140.211.167.41]); Wed, 22 Dec 2010 15:07:32 +0000 (UTC) diff --git a/lib/x86/vm.c b/lib/x86/vm.c index 4d0a955..1ca8a05 100644 --- a/lib/x86/vm.c +++ b/lib/x86/vm.c @@ -9,6 +9,7 @@ #endif #define X86_CR0_PE 0x00000001 +#define X86_CR0_WP 0x00010000 #define X86_CR0_PG 0x80000000 #define X86_CR4_PSE 0x00000010 static void *free = 0; @@ -176,7 +177,7 @@ static void setup_mmu(unsigned long len) #ifndef __x86_64__ write_cr4(X86_CR4_PSE); #endif - write_cr0(X86_CR0_PG |X86_CR0_PE); + write_cr0(X86_CR0_PG |X86_CR0_PE | X86_CR0_WP); printf("paging enabled\n"); printf("cr0 = %x\n", read_cr0());