Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 197633
b: refs/heads/master
c: 4a81018
h: refs/heads/master
i:
  197631: 25ce0b3
v: v3
  • Loading branch information
Joerg Roedel authored and Avi Kivity committed Apr 25, 2010
1 parent 0633a28 commit b56839f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2e554e8d67926024b01e97d2fe652810165354e2
refs/heads/master: 4a810181c8bcd73112f5c62b205b5583fd4a197f
4 changes: 4 additions & 0 deletions trunk/arch/x86/include/asm/svm.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ struct __attribute__ ((__packed__)) vmcb_control_area {
#define SVM_IOIO_SIZE_MASK (7 << SVM_IOIO_SIZE_SHIFT)
#define SVM_IOIO_ASIZE_MASK (7 << SVM_IOIO_ASIZE_SHIFT)

#define SVM_VM_CR_VALID_MASK 0x001fULL
#define SVM_VM_CR_SVM_LOCK_MASK 0x0008ULL
#define SVM_VM_CR_SVM_DIS_MASK 0x0010ULL

struct __attribute__ ((__packed__)) vmcb_seg {
u16 selector;
u16 attrib;
Expand Down
29 changes: 28 additions & 1 deletion trunk/arch/x86/kvm/svm.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ struct kvm_vcpu;
struct nested_state {
struct vmcb *hsave;
u64 hsave_msr;
u64 vm_cr_msr;
u64 vmcb;

/* These are the merged vectors */
Expand Down Expand Up @@ -2280,7 +2281,7 @@ static int svm_get_msr(struct kvm_vcpu *vcpu, unsigned ecx, u64 *data)
*data = svm->nested.hsave_msr;
break;
case MSR_VM_CR:
*data = 0;
*data = svm->nested.vm_cr_msr;
break;
case MSR_IA32_UCODE_REV:
*data = 0x01000065;
Expand Down Expand Up @@ -2310,6 +2311,31 @@ static int rdmsr_interception(struct vcpu_svm *svm)
return 1;
}

static int svm_set_vm_cr(struct kvm_vcpu *vcpu, u64 data)
{
struct vcpu_svm *svm = to_svm(vcpu);
int svm_dis, chg_mask;

if (data & ~SVM_VM_CR_VALID_MASK)
return 1;

chg_mask = SVM_VM_CR_VALID_MASK;

if (svm->nested.vm_cr_msr & SVM_VM_CR_SVM_DIS_MASK)
chg_mask &= ~(SVM_VM_CR_SVM_LOCK_MASK | SVM_VM_CR_SVM_DIS_MASK);

svm->nested.vm_cr_msr &= ~chg_mask;
svm->nested.vm_cr_msr |= (data & chg_mask);

svm_dis = svm->nested.vm_cr_msr & SVM_VM_CR_SVM_DIS_MASK;

/* check for svm_disable while efer.svme is set */
if (svm_dis && (vcpu->arch.efer & EFER_SVME))
return 1;

return 0;
}

static int svm_set_msr(struct kvm_vcpu *vcpu, unsigned ecx, u64 data)
{
struct vcpu_svm *svm = to_svm(vcpu);
Expand Down Expand Up @@ -2376,6 +2402,7 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, unsigned ecx, u64 data)
svm->nested.hsave_msr = data;
break;
case MSR_VM_CR:
return svm_set_vm_cr(vcpu, data);
case MSR_VM_IGNNE:
pr_unimpl(vcpu, "unimplemented wrmsr: 0x%x data 0x%llx\n", ecx, data);
break;
Expand Down

0 comments on commit b56839f

Please sign in to comment.