From: Rusty Russell <rusty-8n+1lVoiYb80n/F98K4Iww@public.gmane.org>
To: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
Cc: kvm-devel <kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Subject: [PATCH 8/10] Use standard CR3 flags, tighten checking
Date: Tue, 17 Jul 2007 23:32:55 +1000 [thread overview]
Message-ID: <1184679175.10380.25.camel@localhost.localdomain> (raw)
In-Reply-To: <1184678348.10380.19.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
The kernel now has asm/cpu-features.h: use those macros instead of inventing our own.
Also spell out definition of CR3_RESEVED_BITS, fix spelling and
tighten it for the non-PAE case.
Signed-off-by: Rusty Russell <rusty-8n+1lVoiYb80n/F98K4Iww@public.gmane.org>
diff -r a253a0af3da6 drivers/kvm/kvm.h
--- a/drivers/kvm/kvm.h Tue Jul 17 19:39:18 2007 +1000
+++ b/drivers/kvm/kvm.h Tue Jul 17 23:21:14 2007 +1000
@@ -19,12 +19,9 @@
#include <linux/kvm.h>
#include <linux/kvm_para.h>
-#define CR3_WPT_MASK (1ULL << 3)
-#define CR3_PCD_MASK (1ULL << 4)
-
-#define CR3_RESEVED_BITS 0x07ULL
-#define CR3_L_MODE_RESEVED_BITS (~((1ULL << 40) - 1) | 0x0fe7ULL)
-#define CR3_FLAGS_MASK ((1ULL << 5) - 1)
+#define CR3_PAE_RESERVED_BITS ((X86_CR3_PWT | X86_CR3_PCD) - 1)
+#define CR3_NONPAE_RESERVED_BITS ((PAGE_SIZE-1) & ~(X86_CR3_PWT | X86_CR3_PCD))
+#define CR3_L_MODE_RESERVED_BITS (CR3_NONPAE_RESERVED_BITS|0xFFFFFF0000000000ULL)
#define CR4_VME_MASK (1ULL << 0)
#define CR4_PSE_MASK (1ULL << 4)
diff -r a253a0af3da6 drivers/kvm/kvm_main.c
--- a/drivers/kvm/kvm_main.c Tue Jul 17 19:39:18 2007 +1000
+++ b/drivers/kvm/kvm_main.c Tue Jul 17 23:26:07 2007 +1000
@@ -588,23 +588,32 @@ void set_cr3(struct kvm_vcpu *vcpu, unsi
void set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3)
{
if (is_long_mode(vcpu)) {
- if (cr3 & CR3_L_MODE_RESEVED_BITS) {
+ if (cr3 & CR3_L_MODE_RESERVED_BITS) {
printk(KERN_DEBUG "set_cr3: #GP, reserved bits\n");
inject_gp(vcpu);
return;
}
} else {
- if (cr3 & CR3_RESEVED_BITS) {
- printk(KERN_DEBUG "set_cr3: #GP, reserved bits\n");
- inject_gp(vcpu);
- return;
- }
- if (is_paging(vcpu) && is_pae(vcpu) &&
- !load_pdptrs(vcpu, cr3)) {
- printk(KERN_DEBUG "set_cr3: #GP, pdptrs "
- "reserved bits\n");
- inject_gp(vcpu);
- return;
+ if (is_pae(vcpu)) {
+ if (cr3 & CR3_PAE_RESERVED_BITS) {
+ printk(KERN_DEBUG
+ "set_cr3: #GP, reserved bits\n");
+ inject_gp(vcpu);
+ return;
+ }
+ if (is_paging(vcpu) && !load_pdptrs(vcpu, cr3)) {
+ printk(KERN_DEBUG "set_cr3: #GP, pdptrs "
+ "reserved bits\n");
+ inject_gp(vcpu);
+ return;
+ }
+ } else {
+ if (cr3 & CR3_NONPAE_RESERVED_BITS) {
+ printk(KERN_DEBUG
+ "set_cr3: #GP, reserved bits\n");
+ inject_gp(vcpu);
+ return;
+ }
}
}
diff -r a253a0af3da6 drivers/kvm/paging_tmpl.h
--- a/drivers/kvm/paging_tmpl.h Tue Jul 17 19:39:18 2007 +1000
+++ b/drivers/kvm/paging_tmpl.h Tue Jul 17 23:23:19 2007 +1000
@@ -99,7 +99,7 @@ static int FNAME(walk_addr)(struct guest
walker->table = kmap_atomic(pfn_to_page(hpa >> PAGE_SHIFT), KM_USER0);
ASSERT((!is_long_mode(vcpu) && is_pae(vcpu)) ||
- (vcpu->cr3 & ~(PAGE_MASK | CR3_FLAGS_MASK)) == 0);
+ (vcpu->cr3 & CR3_NONPAE_RESERVED_BITS) == 0);
walker->inherited_ar = PT_USER_MASK | PT_WRITABLE_MASK;
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
next prev parent reply other threads:[~2007-07-17 13:32 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-17 13:12 [PATCH 1/10] Trivial: /dev/kvm interface is no longer experimental Rusty Russell
[not found] ` <1184677946.10380.4.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-07-17 13:14 ` [PATCH 2/10] Trivial: Remove KVM_IRQ_BITMAP macro Rusty Russell
[not found] ` <1184678060.10380.7.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-07-17 13:15 ` [PATCH 3/10] Trivial: Remove unused struct cpu_user_regs declaration Rusty Russell
[not found] ` <1184678129.10380.10.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-07-17 13:16 ` [PATCH 4/10] Trivial: Make decode_register() static Rusty Russell
[not found] ` <1184678171.10380.12.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-07-17 13:16 ` [PATCH 5/10] Trivial: Comment spelling may escape grep Rusty Russell
[not found] ` <1184678216.10380.14.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-07-17 13:17 ` [PATCH 6/10] Trivial: Avoid hardware_disable predeclaration Rusty Russell
[not found] ` <1184678275.10380.16.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-07-17 13:19 ` [PATCH 7/10] Trivial: Use standard CR0 flags macros from asm/cpu-features.h Rusty Russell
[not found] ` <1184678348.10380.19.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-07-17 13:32 ` Rusty Russell [this message]
[not found] ` <1184679175.10380.25.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-07-17 13:34 ` [PATCH 9/10] Use standard CR4 flags, tighten checking Rusty Russell
2007-07-17 13:37 ` [PATCH 10/10] Use standard CR8 flags, and fix TPR definition Rusty Russell
2007-07-17 13:37 ` Rusty Russell
2007-07-17 13:44 ` Avi Kivity
2007-07-17 13:44 ` Avi Kivity
2007-07-17 16:01 ` H. Peter Anvin
2007-07-17 16:01 ` H. Peter Anvin
2007-07-17 16:00 ` H. Peter Anvin
2007-07-17 16:00 ` H. Peter Anvin
2007-07-18 18:09 ` Avi Kivity
2007-07-18 18:09 ` Avi Kivity
[not found] ` <1184679256.10380.27.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-07-17 13:40 ` [PATCH 9/10] Use standard CR4 flags, tighten checking Avi Kivity
2007-07-17 13:36 ` [PATCH 8/10] Use standard CR3 " Avi Kivity
2007-07-17 13:33 ` [PATCH 7/10] Trivial: Use standard CR0 flags macros from asm/cpu-features.h Avi Kivity
2007-07-17 13:32 ` [PATCH 6/10] Trivial: Avoid hardware_disable predeclaration Avi Kivity
2007-07-17 13:29 ` [PATCH 5/10] Trivial: Comment spelling may escape grep Avi Kivity
2007-07-17 13:29 ` [PATCH 4/10] Trivial: Make decode_register() static Avi Kivity
2007-07-17 13:28 ` [PATCH 3/10] Trivial: Remove unused struct cpu_user_regs declaration Avi Kivity
2007-07-17 13:25 ` [PATCH 2/10] Trivial: Remove KVM_IRQ_BITMAP macro Avi Kivity
[not found] ` <469CC367.1000107-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-07-18 3:05 ` Rusty Russell
[not found] ` <1184727958.10380.54.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-07-18 9:12 ` Avi Kivity
2007-07-17 13:28 ` [PATCH 1/10] Trivial: /dev/kvm interface is no longer experimental Avi Kivity
2007-07-17 16:35 ` Arnd Bergmann
[not found] ` <200707171835.53092.arnd-r2nGTMty4D4@public.gmane.org>
2007-07-17 23:49 ` Rusty Russell
[not found] ` <1184716197.10380.45.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-07-18 9:23 ` Avi Kivity
2007-07-18 9:31 ` Avi Kivity
[not found] ` <469DDDEB.9070009-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-07-18 23:43 ` Arnd Bergmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1184679175.10380.25.camel@localhost.localdomain \
--to=rusty-8n+1lvoiyb80n/f98k4iww@public.gmane.org \
--cc=avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org \
--cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.