diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2007-07-17 09:19:08 -0400 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2007-10-13 04:18:18 -0400 |
commit | 707d92fa72b425bc919a84670c01402e81505c58 (patch) | |
tree | 9e3a55293e867e499fd625ebac45db565ff0fc38 /drivers/kvm/kvm_main.c | |
parent | 9a2b85c620b9779360c7726de4caeda78cac38d4 (diff) |
KVM: Trivial: Use standard CR0 flags macros from asm/cpu-features.h
The kernel now has asm/cpu-features.h: use those macros instead of
inventing our own.
Also spell out definition of CR0_RESEVED_BITS (no code change) and fix typo.
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 | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c index 326fa79fbebf..5d8febe580de 100644 --- a/drivers/kvm/kvm_main.c +++ b/drivers/kvm/kvm_main.c | |||
@@ -82,7 +82,10 @@ static struct dentry *debugfs_dir; | |||
82 | 82 | ||
83 | #define MAX_IO_MSRS 256 | 83 | #define MAX_IO_MSRS 256 |
84 | 84 | ||
85 | #define CR0_RESEVED_BITS 0xffffffff1ffaffc0ULL | 85 | #define CR0_RESERVED_BITS \ |
86 | (~(unsigned long)(X86_CR0_PE | X86_CR0_MP | X86_CR0_EM | X86_CR0_TS \ | ||
87 | | X86_CR0_ET | X86_CR0_NE | X86_CR0_WP | X86_CR0_AM \ | ||
88 | | X86_CR0_NW | X86_CR0_CD | X86_CR0_PG)) | ||
86 | #define LMSW_GUEST_MASK 0x0eULL | 89 | #define LMSW_GUEST_MASK 0x0eULL |
87 | #define CR4_RESEVED_BITS (~((1ULL << 11) - 1)) | 90 | #define CR4_RESEVED_BITS (~((1ULL << 11) - 1)) |
88 | #define CR8_RESEVED_BITS (~0x0fULL) | 91 | #define CR8_RESEVED_BITS (~0x0fULL) |
@@ -466,27 +469,27 @@ out: | |||
466 | 469 | ||
467 | void set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0) | 470 | void set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0) |
468 | { | 471 | { |
469 | if (cr0 & CR0_RESEVED_BITS) { | 472 | if (cr0 & CR0_RESERVED_BITS) { |
470 | printk(KERN_DEBUG "set_cr0: 0x%lx #GP, reserved bits 0x%lx\n", | 473 | printk(KERN_DEBUG "set_cr0: 0x%lx #GP, reserved bits 0x%lx\n", |
471 | cr0, vcpu->cr0); | 474 | cr0, vcpu->cr0); |
472 | inject_gp(vcpu); | 475 | inject_gp(vcpu); |
473 | return; | 476 | return; |
474 | } | 477 | } |
475 | 478 | ||
476 | if ((cr0 & CR0_NW_MASK) && !(cr0 & CR0_CD_MASK)) { | 479 | if ((cr0 & X86_CR0_NW) && !(cr0 & X86_CR0_CD)) { |
477 | printk(KERN_DEBUG "set_cr0: #GP, CD == 0 && NW == 1\n"); | 480 | printk(KERN_DEBUG "set_cr0: #GP, CD == 0 && NW == 1\n"); |
478 | inject_gp(vcpu); | 481 | inject_gp(vcpu); |
479 | return; | 482 | return; |
480 | } | 483 | } |
481 | 484 | ||
482 | if ((cr0 & CR0_PG_MASK) && !(cr0 & CR0_PE_MASK)) { | 485 | if ((cr0 & X86_CR0_PG) && !(cr0 & X86_CR0_PE)) { |
483 | printk(KERN_DEBUG "set_cr0: #GP, set PG flag " | 486 | printk(KERN_DEBUG "set_cr0: #GP, set PG flag " |
484 | "and a clear PE flag\n"); | 487 | "and a clear PE flag\n"); |
485 | inject_gp(vcpu); | 488 | inject_gp(vcpu); |
486 | return; | 489 | return; |
487 | } | 490 | } |
488 | 491 | ||
489 | if (!is_paging(vcpu) && (cr0 & CR0_PG_MASK)) { | 492 | if (!is_paging(vcpu) && (cr0 & X86_CR0_PG)) { |
490 | #ifdef CONFIG_X86_64 | 493 | #ifdef CONFIG_X86_64 |
491 | if ((vcpu->shadow_efer & EFER_LME)) { | 494 | if ((vcpu->shadow_efer & EFER_LME)) { |
492 | int cs_db, cs_l; | 495 | int cs_db, cs_l; |
@@ -1158,7 +1161,7 @@ int emulate_clts(struct kvm_vcpu *vcpu) | |||
1158 | { | 1161 | { |
1159 | unsigned long cr0; | 1162 | unsigned long cr0; |
1160 | 1163 | ||
1161 | cr0 = vcpu->cr0 & ~CR0_TS_MASK; | 1164 | cr0 = vcpu->cr0 & ~X86_CR0_TS; |
1162 | kvm_arch_ops->set_cr0(vcpu, cr0); | 1165 | kvm_arch_ops->set_cr0(vcpu, cr0); |
1163 | return X86EMUL_CONTINUE; | 1166 | return X86EMUL_CONTINUE; |
1164 | } | 1167 | } |