Skip to content

Commit c5d4365

Browse files
lifeixacrnsi
authored andcommitted
hv: vmcs: don't trap when setting reserved bit in cr0/cr4
According to Chap 23.8 RESTRICTIONS ON VMX OPERATION, Vol 3, SDM: "Any attempt to set one of these bits to an unsupported value while in VMX operation (including VMX root operation) using any of the CLTS, LMSW, or MOV CR instructions causes a general-protection exception." So we don't need to trap them out then inject the GP in hypervisor. Tracked-On: #2561 Signed-off-by: Li, Fei1 <fei1.li@intel.com> Acked-by: Anthony Xu <anthony.xu@intel.com>
1 parent f2c53a9 commit c5d4365

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

hypervisor/arch/x86/guest/virtual_cr.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ void init_cr0_cr4_host_mask(void)
311311
cr0_host_owned_bits = ~(fixed0 ^ fixed1);
312312
/* Add the bit hv wants to trap */
313313
cr0_host_owned_bits |= CR0_TRAP_MASK;
314+
cr0_host_owned_bits &= ~CR0_RESERVED_MASK;
314315
/* CR0 clear PE/PG from always on bits due to "unrestructed guest" feature */
315316
cr0_always_on_mask = fixed0 & (~(CR0_PE | CR0_PG));
316317
cr0_always_off_mask = ~fixed1;
@@ -327,6 +328,7 @@ void init_cr0_cr4_host_mask(void)
327328
cr4_host_owned_bits = ~(fixed0 ^ fixed1);
328329
/* Add the bit hv wants to trap */
329330
cr4_host_owned_bits |= CR4_TRAP_MASK;
331+
cr4_host_owned_bits &= ~CR4_RESERVED_MASK;
330332
cr4_always_on_mask = fixed0;
331333
/* Record the bit fixed to 0 for CR4, including reserved bits */
332334
cr4_always_off_mask = ~fixed1;

0 commit comments

Comments
 (0)