ept.h 3.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
/*
 * ept.h
 *
 * Functions for modifying an LCD's guest physical
 * address space.
 *
 * Copyright: University of Utah
 */
#ifndef ASM_X86_LCD_DOMAINS_EPT_H
#define ASM_X86_LCD_DOMAINS_EPT_H

12
#include <lcd_domains/microkernel.h>
13 14 15 16 17 18 19 20 21 22 23 24 25
#include <asm/lcd_domains/types.h>

/**
 * Lookup ept entry for guest physical address a.
 *
 * Set create = 1 to allocate ept page table data structures
 * along the path as needed.
 */
int lcd_arch_ept_walk(struct lcd_arch *lcd, gpa_t a, int create,
		lcd_arch_epte_t **epte_out);
/**
 * Set the guest physical => host physical mapping in the ept entry.
 */
26
void lcd_arch_ept_set(lcd_arch_epte_t *epte, gpa_t gpa, hpa_t hpa);
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
/**
 * Read the host physical address stored in epte.
 */
hpa_t lcd_arch_ept_hpa(lcd_arch_epte_t *epte);
/**
 * Clears guest physical => host physical mapping in the ept.
 *
 * (This is not going to free up potentially empty paging structures
 * higher up in the ept hierarchy; but, for now, unset is used when
 * we're tearing down the lcd -- due to an error -- so the paging
 * structures will be freed up when the ept is torn down.)
 */
int lcd_arch_ept_unset(lcd_arch_epte_t *epte);
/**
 * Simple routine combining ept walk and set.
 *
 * overwrite = 0  => do not overwrite if ept entry is already present
 * overwrite = 1  => overwrite any existing ept entry
 */
int lcd_arch_ept_map(struct lcd_arch *lcd, gpa_t ga, hpa_t ha,
		int create, int overwrite);
/**
 * Maps 
 *
 *    ga_start --> ga_start + npages * PAGE_SIZE
 *
 * to
 *
 *    ha_start --> ha_start + npages * PAGE_SIZE
 *
 * in lcd's ept.
 */
int lcd_arch_ept_map_range(struct lcd_arch *lcd, gpa_t ga_start, 
			hpa_t ha_start, unsigned long npages);
/**
 * Simple routine combining ept walk and unset.
 */
int lcd_arch_ept_unmap(struct lcd_arch *lcd, gpa_t a);
/**
 * Like unmpa, but returns old hpa in hpa_out if it is non-NULL.
 */
int lcd_arch_ept_unmap2(struct lcd_arch *lcd, gpa_t a, hpa_t *hpa_out);
/**
 * Unmaps 
 *
 *    ga_start --> ga_start + npages * PAGE_SIZE
 *
 * in lcd's ept.
 */
int lcd_arch_ept_unmap_range(struct lcd_arch *lcd, gpa_t ga_start, 
			unsigned long npages);
/**
 * Simple routine combinding ept walk and get.
 */
81
int lcd_arch_ept_gpa_to_hpa(struct lcd_arch *lcd, gpa_t ga, hpa_t *ha_out, bool verbose);
82 83 84 85 86 87 88 89
/**
 * Translate guest physical address to host virtual.
 */
static inline int lcd_arch_ept_gpa_to_hva(struct lcd_arch *lcd, gpa_t gpa,
			hva_t *hva_out)
{
	hpa_t hpa;
	int ret;
90
	ret = lcd_arch_ept_gpa_to_hpa(lcd, gpa, &hpa, true);
91 92 93 94 95 96 97 98
	if (ret)
		return ret;
	*hva_out = hpa2hva(hpa);
	return 0;
}
/**
 * Invalidate all EPT mappings.
 */
99 100 101 102 103 104 105 106 107
void lcd_arch_ept_global_invalidate(void);
/**
 * Invalidate mappings for VPID only
 */
void lcd_arch_ept_invvpid(u16 vpid);
/**
 * Invalidate mappings for EPT pointer only.
 */
void lcd_arch_ept_invept(u64 eptp);
108 109 110 111 112
/**
 * Initializes the EPT's root global page directory page, the
 * VMCS pointer, and the spinlock.
 */
int lcd_arch_ept_init(struct lcd_arch *lcd_arch);
113 114 115
#ifdef CONFIG_LCD_SINGLE_EPT
int lcd_arch_ept_child_init(struct lcd_arch *lcd_arch);
#endif
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
/**
 * Free an LCD's EPT tables.
 *
 * Frees all memory associated with ept structures
 * (but not the mapped memory itself! -- this can
 * lead to memory leaks, but is better than potential
 * double frees that crash the machine or scrog the disk!).
 */
void lcd_arch_ept_free(struct lcd_arch *lcd);
/**
 * Dump EPTs to console.
 */
void lcd_arch_ept_dump(struct lcd_arch *lcd);

#endif /* ASM_X86_LCD_DOMAINS_EPT_H */