github.com/jlmucb/cloudproxy@v0.0.0-20170830161738-b5aa0b619bc4/cpvmm/vmm/arch/efer_msr_abstraction.c (about)

     1  /*
     2   * Copyright (c) 2013 Intel Corporation
     3   *
     4   * Licensed under the Apache License, Version 2.0 (the "License");
     5   * you may not use this file except in compliance with the License.
     6   * You may obtain a copy of the License at
     7   *     http://www.apache.org/licenses/LICENSE-2.0
     8   * Unless required by applicable law or agreed to in writing, software
     9   * distributed under the License is distributed on an "AS IS" BASIS,
    10   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    11   * See the License for the specific language governing permissions and
    12   * limitations under the License.
    13   */
    14  
    15  #include <vmm_defs.h>
    16  #include <hw_utils.h>
    17  #include <efer_msr_abstraction.h>
    18  #include <em64t_defs.h>
    19  #ifdef JLMDEBUG
    20  #include "jlmdebug.h"
    21  #endif
    22  
    23  #pragma warning( disable : 4214 )
    24  
    25  void efer_msr_set_nxe(void) {
    26      IA32_EFER_S efer_reg;
    27      efer_reg.Uint64 = hw_read_msr(IA32_MSR_EFER);
    28      if (efer_reg.Bits.NXE == 0) {
    29          efer_reg.Bits.NXE = 1;
    30          hw_write_msr(IA32_MSR_EFER, efer_reg.Uint64);
    31      }
    32  }
    33  
    34  BOOLEAN efer_msr_is_nxe_bit_set(IN UINT64 efer_msr_value) {
    35      IA32_EFER_S efer_reg;
    36      efer_reg.Uint64 = efer_msr_value;
    37      return (efer_reg.Bits.NXE != 0);
    38  }
    39  
    40  UINT64 efer_msr_read_reg(void) {
    41      return hw_read_msr(IA32_MSR_EFER);
    42  }