github.com/jlmucb/cloudproxy@v0.0.0-20170830161738-b5aa0b619bc4/cpvmm/vmm/include/vmexit_msr.h (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  #ifndef _VMEXIT_MSR_H_
    16  #define _VMEXIT_MSR_H_
    17  
    18  #include "list.h"
    19  
    20  // return TRUE if instruction was executed, FAULSE in case of exception
    21  typedef BOOLEAN (*MSR_ACCESS_HANDLER)(GUEST_CPU_HANDLE  gcpu,
    22                                        MSR_ID            msr_id,
    23                                        UINT64           *p_value,
    24                                        void             *context);
    25  
    26  typedef struct _MSR_VMEXIT_CONTROL
    27  {
    28      UINT8          *msr_bitmap;
    29      LIST_ELEMENT    msr_list[1];
    30  } MSR_VMEXIT_CONTROL;
    31  
    32  
    33  // FUNCTION : msr_vmexit_on_all()
    34  // PURPOSE  : Turns VMEXIT on all ON/OFF
    35  // ARGUMENTS: GUEST_CPU_HANDLE gcpu
    36  //          : BOOLEAN enable
    37  // RETURNS  : none, must succeed.
    38  void msr_vmexit_on_all(GUEST_CPU_HANDLE gcpu, BOOLEAN enable) ;
    39  
    40  // FUNCTION : msr_vmexit_guest_setup()
    41  // PURPOSE  : Allocates structures for MSR virtualization
    42  //          : Must be called prior any other function from the package on this gcpu,
    43  //          : but after gcpu VMCS was loaded
    44  // ARGUMENTS: GUEST_HANDLE guest
    45  // RETURNS  : none, must succeed.
    46  void msr_vmexit_guest_setup(GUEST_HANDLE guest);
    47  
    48  // FUNCTION : msr_vmexit_activate()
    49  // PURPOSE  : Register MSR related structures with HW (VMCS)
    50  // ARGUMENTS: GUEST_CPU_HANDLE gcpu
    51  // RETURNS  : none, must succeed.
    52  void msr_vmexit_activate(GUEST_CPU_HANDLE gcpu);
    53  
    54  // FUNCTION : msr_vmexit_handler_register()
    55  // PURPOSE  : Register specific MSR handler with VMEXIT
    56  // ARGUMENTS: GUEST_HANDLE        guest
    57  //          : MSR_ID              msr_id
    58  //          : MSR_ACCESS_HANDLER  msr_handler,
    59  //          : RW_ACCESS           access
    60  //          : void               *context
    61  // RETURNS  : VMM_OK if succeeded
    62  VMM_STATUS msr_vmexit_handler_register( GUEST_HANDLE guest,
    63      MSR_ID msr_id, MSR_ACCESS_HANDLER  msr_handler,
    64      RW_ACCESS access, void *context);
    65  
    66  // FUNCTION : msr_vmexit_handler_unregister()
    67  // PURPOSE  : Unregister specific MSR VMEXIT handler
    68  // ARGUMENTS: GUEST_HANDLE  guest
    69  //          : MSR_ID        msr_id
    70  // RETURNS  : VMM_OK if succeeded
    71  VMM_STATUS msr_vmexit_handler_unregister( GUEST_HANDLE guest,
    72      MSR_ID msr_id, RW_ACCESS access);
    73  
    74  // FUNCTION : msr_guest_access_inhibit()
    75  // PURPOSE  : Install handler which prevents access to MSR from the guest space
    76  // ARGUMENTS: GUEST_HANDLE  guest
    77  //          : MSR_ID        msr_id
    78  // RETURNS  : VMM_OK if succeeded
    79  VMM_STATUS msr_guest_access_inhibit( GUEST_HANDLE guest,
    80      MSR_ID msr_id);
    81  
    82  // FUNCTION : msr_trial_access()
    83  // PURPOSE  : Try to execute real MSR read/write
    84  //          : If exception was generated, inject it into guest
    85  // ARGUMENTS: GUEST_CPU_HANDLE    gcpu
    86  //          : MSR_ID              msr_id
    87  //          : RW_ACCESS           access
    88  // RETURNS  : TRUE if instruction was executed, FALSE otherwise (fault occured)
    89  BOOLEAN msr_trial_access( GUEST_CPU_HANDLE gcpu,
    90      MSR_ID msr_id, RW_ACCESS access, UINT64 *msr_value);
    91  
    92  // FUNCTION : vmexit_enable_disable_for_msr_in_exclude_list()
    93  // PURPOSE  : enable/disable msr read/write vmexit for msrs in the exclude list
    94  // ARGUMENTS: GUEST_CPU_HANDLE    gcpu
    95  //          : MSR_ID              msr_id
    96  //          : RW_ACCESS           access
    97  //          : BOOLEAN      TRUE to enable write/read vmexit, FALSE to disable vmexit
    98  // RETURNS  : TRUE if parameters are correct.
    99  BOOLEAN vmexit_register_unregister_for_efer( GUEST_HANDLE guest,
   100      MSR_ID msr_id, RW_ACCESS access, BOOLEAN  reg_dereg);
   101  
   102  #endif // _VMEXIT_MSR_H_
   103