github.com/jlmucb/cloudproxy@v0.0.0-20170830161738-b5aa0b619bc4/cpvmm/vmm/include/page_walker.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 PAGE_WALKER_H
    16  
    17  #include <vmm_defs.h>
    18  #include <guest_cpu.h>
    19  
    20  typedef enum {
    21      PW_RETVAL_SUCCESS,
    22      PW_RETVAL_PF,
    23      PW_RETVAL_PHYS_MEM_VIOLATION,
    24      PW_RETVAL_FAIL,
    25  } PW_RETVAL;
    26  
    27  #define PW_INVALID_GPA (~((UINT64)0))
    28  #define PW_NUM_OF_PDPT_ENTRIES_IN_32_BIT_MODE 4
    29  #define PW_SIZE_OF_PAE_ENTRY 8
    30  
    31  /* Function: pw_perform_page_walk
    32   * Description: The function performes page walk over guest page tables
    33   *              for specific virtual address
    34   * Input:
    35   *       gcpu - gcpu handle
    36   *       virt_addr - virtual address to perform page walk for
    37   *       is_write - indicates whether it is write access
    38   *       is_user - indicates whether it is a user access
    39   *       is_fetch - indicates whether it is a fetch access
    40   *       set_ad_bits - if TRUE, A/D bits will be set in guest table
    41   * Output:
    42   *       gpa - final guest physical addres, see "Ret. value" description
    43   *             for detailed information about this value.
    44   *       pfec - page fault error code in case when page walk will return "PW_RETVAL_PF".
    45   * Ret. value:
    46   *       PW_RETVAL_SUCCESS - the page walk succeeded, "gpa" output variable
    47   *                           contains the final physical address, "pfec" output variable contains "garbage".
    48   *       PW_RETVAL_PF - the page fault exception should occur, "pfec" output variable contains
    49   *                      error code, "gpa" output variable contains "PW_INVALID_GPA" value in case
    50   *                      when page walk could not calculate the final address. In case when this is
    51   *                      a "protection fault" (the permissions are inconsistent), "gpa" variable will
    52   *                      contain the target guest physical address.
    53   *       PW_RETVAL_PHYS_MEM_VIOLATION - the page walker could not retrieve "host physical address" for
    54   *                                      inner tables and thus could not retrieve the pointer and could not
    55   *                                      read the content of the entries. In this case "gpa" variable will
    56   *                                      contain "PW_INVALID_GPA" and "pfec" will contain "garbage".
    57   *       PW_RETVAL_FAIL - some internal error has occurred, must assert.
    58   * Note:
    59   *       If access attributes (WRITE, USER, FETCH) are not important, use "FALSE" value for "is_write",
    60   *       "is_user" and "is_fetch" varables.
    61   */
    62  PW_RETVAL pw_perform_page_walk(IN GUEST_CPU_HANDLE gcpu,
    63                   IN UINT64 virt_addr, IN BOOLEAN is_write,
    64                   IN BOOLEAN is_user, IN BOOLEAN is_fetch,
    65                   IN BOOLEAN set_ad_bits, OUT UINT64* gpa, OUT UINT64* pfec);
    66  
    67  /* Function: pw_is_pdpt_in_32_bit_pae_mode_valid
    68   * Description: The function performes page walk over guest page tables
    69   *              for specific virtual address
    70   * Input:
    71   *       gcpu - gcpu handle
    72   *       pdpt_ptr - pointer (HVA) to PDPT
    73   * Ret.value: TRUE in case no reserved bits are set in PDPT, FALSE otherwise
    74   */
    75  BOOLEAN pw_is_pdpt_in_32_bit_pae_mode_valid(IN GUEST_CPU_HANDLE gcpu,
    76                                              IN void* pdpt_ptr);
    77  
    78  #endif