MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vmx_setup_cr_shadow

Function vmx_setup_cr_shadow

freebsd/amd64/vmm/intel/vmx.c:987–1015  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

985}
986
987static int
988vmx_setup_cr_shadow(int which, struct vmcs *vmcs, uint32_t initial)
989{
990 int error, mask_ident, shadow_ident;
991 uint64_t mask_value;
992
993 if (which != 0 && which != 4)
994 panic("vmx_setup_cr_shadow: unknown cr%d", which);
995
996 if (which == 0) {
997 mask_ident = VMCS_CR0_MASK;
998 mask_value = cr0_ones_mask | cr0_zeros_mask;
999 shadow_ident = VMCS_CR0_SHADOW;
1000 } else {
1001 mask_ident = VMCS_CR4_MASK;
1002 mask_value = cr4_ones_mask | cr4_zeros_mask;
1003 shadow_ident = VMCS_CR4_SHADOW;
1004 }
1005
1006 error = vmcs_setreg(vmcs, 0, VMCS_IDENT(mask_ident), mask_value);
1007 if (error)
1008 return (error);
1009
1010 error = vmcs_setreg(vmcs, 0, VMCS_IDENT(shadow_ident), initial);
1011 if (error)
1012 return (error);
1013
1014 return (0);
1015}
1016#define vmx_setup_cr0_shadow(vmcs,init) vmx_setup_cr_shadow(0, (vmcs), (init))
1017#define vmx_setup_cr4_shadow(vmcs,init) vmx_setup_cr_shadow(4, (vmcs), (init))
1018

Callers

nothing calls this directly

Calls 2

vmcs_setregFunction · 0.85
panicFunction · 0.50

Tested by

no test coverage detected