| 33 |
/* MMU emulation, Shadow Page Tables (SPT) */ |
/* MMU emulation, Shadow Page Tables (SPT) */ |
| 34 |
|
|
| 35 |
#include <common/list.h> |
#include <common/list.h> |
|
#include <core/assert.h> |
|
| 36 |
#include <core/initfunc.h> |
#include <core/initfunc.h> |
| 37 |
#include <core/printf.h> |
#include <core/printf.h> |
| 38 |
#include <core/spinlock.h> |
#include <core/spinlock.h> |
| 44 |
#include "current.h" |
#include "current.h" |
| 45 |
#include "mm.h" |
#include "mm.h" |
| 46 |
#include "mmio.h" |
#include "mmio.h" |
| 47 |
|
#include "msr_pass.h" |
| 48 |
#include "panic.h" |
#include "panic.h" |
| 49 |
#include "pcpu.h" |
#include "pcpu.h" |
| 50 |
#include "vmmcall_status.h" |
#include "vmmcall_status.h" |
| 224 |
current->spt.spt_page[i].pte_virt = NULL; |
current->spt.spt_page[i].pte_virt = NULL; |
| 225 |
LIST2_ADD(current->spt.shadow_free, list, ¤t->spt.spt_page[i]); |
LIST2_ADD(current->spt.shadow_free, list, ¤t->spt.spt_page[i]); |
| 226 |
} |
} |
|
current->spt.initialized = true; |
|
| 227 |
} |
} |
| 228 |
|
|
| 229 |
static bool |
static bool |
| 242 |
bool |
bool |
| 243 |
cpu_mmu_spt_tlbflush (void) |
cpu_mmu_spt_tlbflush (void) |
| 244 |
{ |
{ |
|
if (current->spt.initialized == false) { |
|
|
return false; |
|
|
} |
|
| 245 |
return spt_tlbflush (); |
return spt_tlbflush (); |
| 246 |
} |
} |
| 247 |
|
|
| 249 |
void |
void |
| 250 |
cpu_mmu_spt_updatecr3 (void) |
cpu_mmu_spt_updatecr3 (void) |
| 251 |
{ |
{ |
|
if (current->spt.initialized == false) { |
|
|
return; |
|
|
} |
|
| 252 |
update_cr3 (); |
update_cr3 (); |
| 253 |
} |
} |
| 254 |
|
|
| 257 |
void |
void |
| 258 |
cpu_mmu_spt_invalidate (ulong virtual_addr) |
cpu_mmu_spt_invalidate (ulong virtual_addr) |
| 259 |
{ |
{ |
|
ASSERT(current->spt.initialized); |
|
|
|
|
| 260 |
invalidate_page (virtual_addr); |
invalidate_page (virtual_addr); |
| 261 |
} |
} |
| 262 |
|
|
| 266 |
m1->write = write; |
m1->write = write; |
| 267 |
m1->user = user; |
m1->user = user; |
| 268 |
m1->wp = wp; |
m1->wp = wp; |
| 269 |
m1->cache_flag = current->msr.pte_to_cache_flag(entry0); |
m1->cache_flag = msr_pte_to_cache_flag(entry0); |
| 270 |
} |
} |
| 271 |
|
|
| 272 |
static void |
static void |
| 324 |
u64 efer, gfns[5], entries[5]; |
u64 efer, gfns[5], entries[5]; |
| 325 |
phys_t hphys; |
phys_t hphys; |
| 326 |
|
|
|
ASSERT(current->spt.initialized); |
|
|
|
|
| 327 |
current->vmctl.read_control_reg(CONTROL_REG_CR0, &cr0); |
current->vmctl.read_control_reg(CONTROL_REG_CR0, &cr0); |
| 328 |
current->vmctl.read_control_reg(CONTROL_REG_CR3, &cr3); |
current->vmctl.read_control_reg(CONTROL_REG_CR3, &cr3); |
| 329 |
current->vmctl.read_control_reg(CONTROL_REG_CR4, &cr4); |
current->vmctl.read_control_reg(CONTROL_REG_CR4, &cr4); |