diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2007-07-17 09:32:55 -0400 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2007-10-13 04:18:18 -0400 |
commit | f802a307cb2cabdd0c6b48067dbe901d6fe27246 (patch) | |
tree | 57c5faaada33142fff92be62a78555716feb597a /drivers/kvm/kvm_main.c | |
parent | 707d92fa72b425bc919a84670c01402e81505c58 (diff) |
KVM: Use standard CR3 flags, tighten checking
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@rustcorp.com.au>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm/kvm_main.c')
-rw-r--r-- | drivers/kvm/kvm_main.c | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c index 5d8febe580de..34a571dee514 100644 --- a/drivers/kvm/kvm_main.c +++ b/drivers/kvm/kvm_main.c | |||
@@ -571,23 +571,32 @@ EXPORT_SYMBOL_GPL(set_cr4); | |||
571 | void set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3) | 571 | void set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3) |
572 | { | 572 | { |
573 | if (is_long_mode(vcpu)) { | 573 | if (is_long_mode(vcpu)) { |
574 | if (cr3 & CR3_L_MODE_RESEVED_BITS) { | 574 | if (cr3 & CR3_L_MODE_RESERVED_BITS) { |
575 | printk(KERN_DEBUG "set_cr3: #GP, reserved bits\n"); | 575 | printk(KERN_DEBUG "set_cr3: #GP, reserved bits\n"); |
576 | inject_gp(vcpu); | 576 | inject_gp(vcpu); |
577 | return; | 577 | return; |
578 | } | 578 | } |
579 | } else { | 579 | } else { |
580 | if (cr3 & CR3_RESEVED_BITS) { | 580 | if (is_pae(vcpu)) { |
581 | printk(KERN_DEBUG "set_cr3: #GP, reserved bits\n"); | 581 | if (cr3 & CR3_PAE_RESERVED_BITS) { |
582 | inject_gp(vcpu); | 582 | printk(KERN_DEBUG |
583 | return; | 583 | "set_cr3: #GP, reserved bits\n"); |
584 | } | 584 | inject_gp(vcpu); |
585 | if (is_paging(vcpu) && is_pae(vcpu) && | 585 | return; |
586 | !load_pdptrs(vcpu, cr3)) { | 586 | } |
587 | printk(KERN_DEBUG "set_cr3: #GP, pdptrs " | 587 | if (is_paging(vcpu) && !load_pdptrs(vcpu, cr3)) { |
588 | "reserved bits\n"); | 588 | printk(KERN_DEBUG "set_cr3: #GP, pdptrs " |
589 | inject_gp(vcpu); | 589 | "reserved bits\n"); |
590 | return; | 590 | inject_gp(vcpu); |
591 | return; | ||
592 | } | ||
593 | } else { | ||
594 | if (cr3 & CR3_NONPAE_RESERVED_BITS) { | ||
595 | printk(KERN_DEBUG | ||
596 | "set_cr3: #GP, reserved bits\n"); | ||
597 | inject_gp(vcpu); | ||
598 | return; | ||
599 | } | ||
591 | } | 600 | } |
592 | } | 601 | } |
593 | 602 | ||