Skip to content

Commit 2db1324

Browse files
mgcaojren1
authored andcommitted
add vmx msr ops protection from guest OS
1.it doesn't support VMX for guest OS 2.for MSR out of control, inject GP to guest OS. Signed-off-by: Minggui Cao <minggui.cao@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent 86f3948 commit 2db1324

File tree

1 file changed

+10
-2
lines changed
  • hypervisor/arch/x86/guest

1 file changed

+10
-2
lines changed

hypervisor/arch/x86/guest/vmsr.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,11 @@ void init_msr_emulation(struct vcpu *vcpu)
152152
i <= MSR_IA32_MTRR_FIX4K_F8000; i++) {
153153
enable_msr_interception(msr_bitmap, i);
154154
}
155+
156+
for (i = MSR_IA32_VMX_BASIC;
157+
i <= MSR_IA32_VMX_TRUE_ENTRY_CTLS; i++) {
158+
enable_msr_interception(msr_bitmap, i);
159+
}
155160
}
156161

157162
/* Set up MSR bitmap - pg 2904 24.6.9 */
@@ -192,6 +197,7 @@ int rdmsr_handler(struct vcpu *vcpu)
192197
case MSR_IA32_MTRR_DEF_TYPE:
193198
case MSR_IA32_MTRR_PHYSBASE_0 ... MSR_IA32_MTRR_PHYSMASK_9:
194199
case MSR_IA32_MTRR_FIX64K_00000 ... MSR_IA32_MTRR_FIX4K_F8000:
200+
case MSR_IA32_VMX_BASIC ... MSR_IA32_VMX_TRUE_ENTRY_CTLS:
195201
{
196202
vcpu_inject_gp(vcpu);
197203
break;
@@ -232,6 +238,7 @@ int rdmsr_handler(struct vcpu *vcpu)
232238
default:
233239
{
234240
pr_warn("rdmsr: %lx should not come here!", msr);
241+
vcpu_inject_gp(vcpu);
235242
v = 0;
236243
break;
237244
}
@@ -280,6 +287,7 @@ int wrmsr_handler(struct vcpu *vcpu)
280287
case MSR_IA32_MTRR_DEF_TYPE:
281288
case MSR_IA32_MTRR_PHYSBASE_0 ... MSR_IA32_MTRR_PHYSMASK_9:
282289
case MSR_IA32_MTRR_FIX64K_00000 ... MSR_IA32_MTRR_FIX4K_F8000:
290+
case MSR_IA32_VMX_BASIC ... MSR_IA32_VMX_TRUE_ENTRY_CTLS:
283291
{
284292
vcpu_inject_gp(vcpu);
285293
break;
@@ -329,8 +337,8 @@ int wrmsr_handler(struct vcpu *vcpu)
329337
}
330338
default:
331339
{
332-
ASSERT(0, "wrmsr: %lx should not come here!", msr);
333-
msr_write(msr, v);
340+
pr_warn(0, "wrmsr: %lx should not come here!", msr);
341+
vcpu_inject_gp(vcpu);
334342
break;
335343
}
336344
}

0 commit comments

Comments
 (0)