Bochs/bochs/plex86/kernel/include/monitor.h
Kevin Lawton 0768d01522 Added plex86 directory to bochs. This directory contains the
new experimental stripped-down version of plex86, which is now
  a user-code-only VM.  I ripped out all the fancy stuff in plex86,
  such that under that right conditions, user-code (protection level 3)
  can run at near native speeds inside the plex86 VM.
The general idea is that bochs emulates all the initial real-mode code,
  and guest kernel code (protection level 0).  When it senses the
  right conditions (like the context switches to user-code), a shim
  is called to execute the guest inside the plex86 VM.  All guest-generated
  faults/exceptions are then forwarded back to bochs to be handled in
  the emulator.
Actually, I'm not yet adding the mods to the bochs code (other than
  the shim code which is in a separate file), until I hear that we're
  back in a more development mode with bochs after the 2.0 release.
The plex86 subdirectory is really a separate project.  It's just more
  convenient to co-develop it with bochs for now.  Both projects are
  currently LGPL, but each should be taken to be a separate project,
  and have their own license file.  Plex86 (it's only a kernel driver
  now) could ultimately be used with other projects, as it's modular.
  I talked with Bryce, and we both agreed it's OK to keep plex86 as
  a subdir in bochs for now.
2003-01-01 17:32:06 +00:00

718 lines
23 KiB
C

/*
* plex86: run multiple x86 operating systems concurrently
* Copyright (C) 1999-2003 Kevin P. Lawton
*
* monitor.h: main VM monitor defines
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __MONITOR_H__
#define __MONITOR_H__
#if defined(__NetBSD__) || defined(__FreeBSD__)
#include <machine/stdarg.h>
#else
#include <stdarg.h>
#endif
#include "descriptor.h"
#include "descriptor2.h"
#include "tss.h"
#include "paging.h"
#include "eflags.h"
#include "guest_context.h"
/* Method1: push event info (CPU pushes error code before) */
typedef struct
{
Bit8u pushl; /* Always 0x68 == pushl */
Bit32u vector; /* Interrupt vector number */
Bit8u jmp; /* Always 0xe9 == jmp */
Bit32u reloc; /* Relative offset of destination */
} __attribute__ ((packed)) idt_method1_t;
/* Method2: push a dummy error first, then event info */
typedef struct
{
Bit8u pushla; /* Always 0x68 == pushl */
Bit32u dummy; /* Dummy error code */
Bit8u pushlb; /* Always 0x68 == pushl */
Bit32u vector; /* Interrupt vector number */
Bit8u jmp; /* Always 0xe9 == jmp */
Bit32u reloc; /* Relative offset of destination */
} __attribute__ ((packed)) idt_method2_t;
typedef union
{
idt_method1_t m1;
idt_method2_t m2;
} idt_stub_t;
/* Nexus fields. This C structure maps to identical assembly */
/* fields in nexus.S. Make sure to update both! These fields */
/* are accessible to the nexus code during the transition from */
/* host<->guest and are stored in a single page. */
typedef struct {
/* guest pointer to vm_t structure. */
void *vm;
/* These fields are only used by the transition code. */
/* They hold all info necessary to switch back to the host. */
gdt_info_t host_gdt_info;
gdt_info_t host_idt_info;
far_jmp_info_t host_jmp_info;
far_jmp_info_t host_stack_info;
Bit16u host_ldt_sel;
Bit16u host_tss_sel;
Bit32u host_cr0;
Bit32u host_cr2;
Bit32u host_cr3;
Bit32u host_cr4;
/* These fields are filled by the host-side code, and used */
/* by the transition code. They contain all info necessary */
/* to switch to the monitor/guest address space. */
/* This info changes whenever the monitor migrates. */
gdt_info_t mon_gdt_info;
gdt_info_t mon_idt_info;
far_jmp_info_t mon_jmp_info;
far_jmp_info_t mon_stack_info;
Bit16u mon_ldt_sel;
Bit16u mon_tss_sel;
Bit32u mon_base;
Bit32u mon_cr0;
Bit32u mon_cr3;
Bit32u mon_cr4;
Bit32u mon_eflags;
/* These fields contain info used by the transition code to */
/* create the temporary identity mapping. They never change. */
pageEntry_t transition_pde;
pageEntry_t *transition_pde_p_host;
pageEntry_t *transition_pde_p_mon;
Bit32u transition_laddr;
} __attribute__ ((packed)) nexus_t;
/* For reference, the following describes where bits from the guest */
/* eflags register are stored/managed. */
/* */
/* Key: */
/* g: Flag value as requested by guest */
/* V: Virtualized flag value, as loaded in eflags when guest is executing */
/* ?: Unhandled yet, request of set bit causes panic for now */
/* */
/* === ======= ====== ======= ======= ======= */
/* |I|V|V|A|V|R|0|N|IO|O|D|I|T|S|Z|0|A|0|P|1|C| flag */
/* |D|I|I|C|M|F| |T|PL|F|F|F|F|F|F| |F| |F| |F| */
/* | |P|F| | | | | | | | | | | | | | | | | | | */
/* |g|?|?|g|V|g|g|g|VV|g|g|V|g|g|g|g|g|g|g|g|g| context->eflags */
/* | |?|?| |g| | | |gg| | |g| | | | | | | | | | veflags */
/* #define VirtualizedEflags 0x001a3200 */
#define VirtualizedEflags 0x001a3300
/* I define the 'nexus' as the set of data structures which */
/* must exist in the current linear guest address space. The */
/* host linear address space is not available while the current */
/* guest code is running, since we are using a completely */
/* different set of page mappings for the guest. However, */
/* at some point an exception/interrupt will occur. The */
/* interrupt mechanisms require that several structures exist in */
/* the current linear address space in order to service such */
/* an event. These data structures make up part of our VM, */
/* a thin layer which exists in the guest. Following is a */
/* list of what data structures compose this 'nexus': */
/* */
/* - IDT (max 2048 bytes) */
/* - GDT (max 65536 bytes) */
/* - LDT (max 65536 bytes) */
/* - TSS (max 8328 = 104 + 32 int redir + 8192 I/O permissions) */
/* - kernel stack page */
/* - transition code (host <--> guest) */
/* - interrupt handler stubs */
/* - Page Tables; PDE & PTE pages. */
/*
* Sizes of various nexus data structures used by the monitor
*/
#define PLEX86_MAX_PHY_MEGS 32
#define PAGESIZE 4096
#define IDT_STUB_SIZE 15
#define BytesToPages(b) ( ((b)+4095) >> 12 )
#define MON_IDT_SIZE (8*256)
#define MON_GDT_SIZE (8*512)
#define MON_LDT_SIZE (8*1)
#define MON_IDT_STUBS_SIZE (IDT_STUB_SIZE*256)
#define MON_TSS_SIZE (104)
#define MON_IDT_PAGES BytesToPages(MON_IDT_SIZE)
#define MON_GDT_PAGES BytesToPages(MON_GDT_SIZE)
#define MON_LDT_PAGES BytesToPages(MON_LDT_SIZE)
#define MON_IDT_STUBS_PAGES BytesToPages(MON_IDT_STUBS_SIZE)
#define MON_TSS_PAGES BytesToPages(MON_TSS_SIZE)
#define MON_GUEST_PAGES (PLEX86_MAX_PHY_MEGS * 256)
/* +++ MON_PAGE_TABLES is kind of random */
#define MON_PAGE_TABLES (10*((PLEX86_MAX_PHY_MEGS+3) >> 2))
#define MAX_VM_STRUCT_PAGES (68)
#define LOG_BUFF_PAGES 1
#define LOG_BUFF_SIZE ((LOG_BUFF_PAGES)*4096)
/*
* Pages allocated for the VM by the host kernel driver.
* N Megs of physical memory are allocated, per the user's
* request, for the guest OS/application code.
* Additionally, some other overhead pages are allocated
* for structures such as the page directory, page tables,
* and other virtualized facilities.
*/
typedef struct {
/* requested size of the guest[] array in megs and pages */
unsigned guest_n_megs;
unsigned guest_n_pages;
unsigned guest_n_bytes;
/* pages comprising the vm_t struct itself. */
Bit32u vm[MAX_VM_STRUCT_PAGES];
/* for the guest OS/app code */
Bit32u guest[MON_GUEST_PAGES];
/* for the monitor's page directory */
Bit32u page_dir;
/* for the monitor's page table */
Bit32u page_tbl[MON_PAGE_TABLES];
/* Map of the linear addresses of page tables currently */
/* mapped into the monitor space. */
Bit32u page_tbl_laddr_map;
/* for the extra page table that maps our nexus code and structures */
Bit32u nexus_page_tbl;
/* For the CPU state passed between user and kernel/monitor space. */
Bit32u guest_cpu;
/* We need a Page Table for identity mapping the transition code */
/* between host and monitor spaces. */
Bit32u transition_PT;
Bit32u log_buffer[LOG_BUFF_PAGES];
/* Physical addresses of host pages which comprise the actual */
/* monitor structures. These will be mapped into the current */
/* guest task's linear address space as well. */
Bit32u nexus;
Bit32u idt[MON_IDT_PAGES];
Bit32u gdt[MON_GDT_PAGES];
Bit32u ldt[MON_LDT_PAGES];
Bit32u tss[MON_TSS_PAGES];
Bit32u idt_stubs[MON_IDT_STUBS_PAGES];
} vm_pages_t;
typedef struct {
void *guest;
pageEntry_t *page_dir;
page_t *page_tbl;
unsigned *page_tbl_laddr_map;
page_t *nexus_page_tbl;
guest_cpu_t *guest_cpu;
page_t *transition_PT;
unsigned char *log_buffer;
Bit8u *code_phy_page; /* only use in mon space */
Bit8u *tmp_phy_page0; /* only use in mon space */
Bit8u *tmp_phy_page1; /* only use in mon space */
nexus_t *nexus;
/* Pointer into the monitor stack, so we can easily retrieve the */
/* stack snapshot upon interrupt/exception. */
guest_context_t *guest_context;
gate_t *idt;
descriptor_t *gdt;
descriptor_t *ldt;
tss_t *tss;
idt_stub_t *idt_stubs;
} vm_addr_t;
/* These bits define the possible usage and attributes assigned */
/* to a particular guest physical page. These are useful for keeping */
/* track of what kinds of system structures are contained in a page */
/* at a given time, and if the page has associated cached code */
/* information in the prescan logic. We can also tag particular */
/* pages with other more static attributes. */
typedef union {
struct {
Bit32u access_perm:2; /* */
Bit32u lmap_count:2; /* */
Bit32u ptbl:1; /* page table */
Bit32u pdir:1; /* page directory */
Bit32u vcode:1; /* vcode */
Bit32u memMapIO:1; /* MemMapIO */
Bit32u RO:1; /* RO */
Bit32u allocated:1; /* Allocated */
Bit32u swappable:1; /* Swappable */
Bit32u spare:1; /* (spare) */
Bit32u laddr_backlink:20; /* 1st unvirtualized laddr backlink */
} __attribute__ ((packed)) fields;
Bit32u raw;
} __attribute__ ((packed)) phy_page_attr_t;
typedef struct {
phy_page_attr_t attr;
Bit64u tsc; /* for comparing to CR3 timestamp counter */
} __attribute__ ((packed)) phy_page_usage_t;
/* Possible values of the access_perm field above. */
#define PagePermRW 0
#define PagePermRO 1
#define PagePermEmulate 2
#define PagePermNA PagePermEmulate /* No Access is synomym */
/* Bitmasks to access fields in structure above. */
#define PageUsagePTbl 0x010
#define PageUsagePDir 0x020
#define PageUsageMemMapIO 0x080
#define PageUsageRO 0x100
#define PageUsageAllocated 0x200
#define PageUsageSwappable 0x400
/* Group of attributes which retain their value, even when CR3 */
/* is reloaded and the page mappings are flushed. */
#define PageUsageSticky \
( PageUsageMemMapIO | PageUsageRO | \
PageUsageAllocated | PageUsageSwappable )
/* Group of attributes which are not compatible with a Page Table */
/* occupying a physical page. */
#define PageBadUsage4PTbl \
( PageUsagePDir | PageUsageMemMapIO | PageUsageRO )
/* Group of attributes which are not compatible with a Page Directory */
/* occupying a physical page. Keep in mind, when the PDir is marked, */
/* no other dynamic bits will be set. */
#define PageBadUsage4PDir \
( PageUsageMemMapIO | PageUsageRO )
#define PageUsageCausesNA \
( PageUsagePTbl | PageUsagePDir | PageUsageMemMapIO )
#define PageUsageCausesRO \
( PageUsageRO )
#define PDEUnhandled 0x000001d8
#define PTEUnhandled 0x00000198
#define ExceptionDE 0 /* Divide Error (fault) */
#define ExceptionDB 1 /* Debug (fault/trap) */
#define ExceptionBP 3 /* Breakpoint (trap) */
#define ExceptionOF 4 /* Overflow (trap) */
#define ExceptionBR 5 /* BOUND (fault) */
#define ExceptionUD 6
#define ExceptionNM 7
#define ExceptionDF 8
#define ExceptionTS 10
#define ExceptionNP 11
#define ExceptionSS 12
#define ExceptionGP 13
#define ExceptionPF 14
#define ExceptionMF 16
#define ExceptionAC 17
#define CR0_PE (1<<0)
#define CR0_MP (1<<1)
#define CR0_EM (1<<2)
#define CR0_TS (1<<3)
#define CR0_ET (1<<4)
#define CR0_NE (1<<5)
#define CR0_WP (1<<16)
#define CR0_AM (1<<18)
#define CR0_NW (1<<29)
#define CR0_CD (1<<30)
#define CR0_PG (1<<31)
/*
* Complete state of the VM (Virtual Machine).
*/
typedef struct {
/* Store eflags values of the guest which are virtualized to
* run in the monitor
*/
eflags_t veflags;
unsigned executeMethod;
unsigned vmState;
unsigned mon_request;
unsigned guestFaultNo;
unsigned redirect_vector;
Bit32u kernel_offset;
#define MonitorSpace 0
#define UserSpace 1
#define HostSpace 2
volatile unsigned inMonFault;
/* Extra info on aborts, especially when a message can't
* be printed out
*/
unsigned abort_code;
struct {
Bit64u t0; /* TSC before excecution of guest code */
Bit64u cyclesElapsed; /* Cycles of guest execution */
unsigned a20; /* address 20 line enabled */
Bit32u a20AddrMask; /* mask to apply to phy address */
Bit32u a20IndexMask; /* mask to apply to phy address */
} system;
cpuid_info_t guestCPUIDInfo;
/* This macro yields a physical address after applying the A20 line
* enable mask to the original physical address.
*/
#define A20Addr(vm, paddr) ( (paddr) & ((vm)->system.a20AddrMask) )
#define A20PageIndex(vm, pi) ( (pi) & ((vm)->system.a20IndexMask) )
/* Keep an index of the next available Page Table */
unsigned ptbl_laddr_map_i;
Bit32u mon_pde_mask; /* Upper 10 bits of monitor lin addr space */
Bit32u mon_pdi; /* Same value shifted down 22 bits. */
Bit64u vpaging_tsc; /* time stamp of last page mappings flush */
/* We need to keep track of what each of the guest's physical */
/* pages contains, and maintain some additional attributes. */
/* We determine which kinds of information reside in the page, */
/* dynamically. */
phy_page_usage_t page_usage[MON_GUEST_PAGES];
struct {
volatile unsigned event; /* Any log event occurred. */
/* Inactive, OK to dump to host and change */
volatile unsigned locked;
/* Number of times buffer wrapped since last print to kernel */
/* debug facility */
volatile unsigned offset; /* Current index within buffer */
volatile unsigned error; /* Error printing. (ex. string too long) */
} log_buffer_info;
vm_addr_t *addr;
vm_pages_t pages; /* memory pages allocated by the host */
/* Host specific fields. These fields should NOT be accessed */
/* from code which may execute in either host or monitor/guest */
/* spaces, unless you need to _specifically_ manipulate a */
/* host-specific field. */
struct {
vm_addr_t addr; /* addresses of data structures in host space */
void (*__host2mon)(void); /* Host to guest nexus entry point */
pageEntry_t nexus_pde; /* PDE pointing to nexus page table */
} host;
/* Guest specific fields. These fields should NOT be accessed */
/* from code which may execute in either host or monitor/guest */
/* spaces, unless you need to _specifically_ manipulate a */
/* guest-specific field. */
struct {
vm_addr_t addr; /* addresses of data structures in guest space */
void (*__mon2host)(void); /* monitor to host entry point */
} guest;
} vm_t;
extern char __nexus_start, __nexus_end, __mon_cs;
extern char __host2mon, __mon2host, __handle_fault, __handle_int;
extern char __ret_to_guest;
/*
* This structure describes the pages containing the code/data
* of the monitor itself (inside the kernel module)
*/
#define PLEX86_MAX_MONITOR_PAGES 128
typedef struct {
/* virtual address space occupied by the module */
Bit32u startOffset;
Bit32u startOffsetPageAligned;
/* number of pages */
unsigned n_pages;
/* the pages themselves */
Bit32u page[PLEX86_MAX_MONITOR_PAGES];
} monitor_pages_t;
extern monitor_pages_t monitor_pages;
extern cpuid_info_t cpuid_info;
#if !defined(IN_HOST_SPACE) && !defined(IN_MONITOR_SPACE) && \
!defined(IN_NEXUS_SPACE) && !defined(IN_R3_SPACE)
#error "No space defined for this file"
#endif
#if defined(IN_NEXUS_SPACE) || defined(IN_MONITOR_SPACE)
void sysFlushPrintBuf(vm_t *);
#endif /* {NEXUS, MONITOR} */
#if defined(IN_HOST_SPACE) || defined(IN_MONITOR_SPACE) || \
defined(IN_NEXUS_SPACE)
int monprint(vm_t *, char *fmt, ...);
int mon_vsnprintf(char *str, unsigned size, const char *fmt,
va_list args);
void resetPrintBuf(vm_t *);
void setINTR(vm_t *, unsigned val);
Bit8u picIAC(vm_t *);
#define cache_sreg(vm, sreg) ({})
#define cache_selector(vm, sreg) ({})
void mon_memzero(void *ptr, int size);
void mon_memcpy(void *dst, void *src, int size);
void *mon_memset(void *s, unsigned c, unsigned n);
#define MON_BASE_FROM_LADDR(laddr) \
((laddr) - monitor_pages.startOffsetPageAligned)
/* IO logic functions. */
unsigned ioInit(vm_t *vm);
int registerIORHandler(vm_t *vm, unsigned space, void *thisPtr,void *callback,
Bit32u base, unsigned len, char *name);
int registerIOWHandler(vm_t *vm, unsigned space, void *thisPtr, void *callback,
Bit32u base, unsigned len, char *name);
int registerIRQ(vm_t *vm, unsigned space, unsigned irq,
const char *name);
int unregisterIRQ(vm_t *vm, unsigned space, unsigned irq,
const char *name);
#if 0
void dtInitialize(vm_t *vm);
void dtInitHashTables(vm_t *vm);
void dtInitG2THashTable(vm_t *vm);
unsigned isPMR3NativeCompatible(vm_t *);
#define DoZero (1<<0)
#define DontZero (0<<0)
#define AtHead (1<<1)
#define AtTail (0<<1)
Bit32u
dtTranslateG2T(vm_t *vm, Bit32u guestOff, Bit32u guestLinAddr,
Bit32u guestPhyAddr);
#endif
#endif /* {HOST, MONITOR, NEXUS} */
#if defined(IN_HOST_SPACE) || defined(IN_MONITOR_SPACE)
/* ============================================================
* These are the functions which are available in either of the
* host or monitor/guest spaces.
*/
/* Access to label offsets in nexus.S... From the host address perspective */
#define HOST_NEXUS_OFFSET(vm, field) \
( ((Bit32u)vm->host.addr.nexus) + \
(((Bit32u) &field) - ((Bit32u) &__nexus_start)) )
/* From the monitor/guest address perspective. */
#define MON_NEXUS_OFFSET(vm, field) \
( ((Bit32u)vm->guest.addr.nexus) + \
(((Bit32u) &field) - ((Bit32u) &__nexus_start)) )
/* Translate from guest laddr to monitor laddr */
#define Guest2Monitor(vm, laddr) ( ((Bit32u) (laddr)) - \
vm->addr->nexus->mon_base )
#define MonOff2Lin(vm, off) ( ((Bit32u) (off)) + \
vm->addr->nexus->mon_base )
static __inline__ Bit64u
vm_rdtsc(void) {
Bit64u ret;
asm volatile (
"rdtsc"
: "=A" (ret)
);
return ret;
}
#endif /* {HOST, MONITOR} */
#ifdef IN_HOST_SPACE
/* ==========================================================
* These are the functions which are available to the monitor
* running in the host space.
*/
/*
* Generate a software interrupt
*/
#define soft_int(n) \
asm volatile ( \
" movb %b0, __soft_int_vector \n\t" \
" jmp __soft_int_n \n\t" \
"__soft_int_n: \n\t" \
" sti \n\t" \
" .byte 0xcd \n\t" \
"__soft_int_vector: \n\t" \
" .byte 0x00 \n\t" \
: \
: "r" ((Bit8u) (n) ) \
: "memory" \
)
int initMonitor(vm_t *);
unsigned mapMonitor(vm_t *);
unsigned initGuestPhyMem(vm_t *);
void set_guest_context(vm_t *, guest_context_t *context);
void get_guest_context(vm_t *, guest_context_t *context);
int runGuestLoop(vm_t *);
void unallocVmPages(vm_t *);
int allocVmPages(vm_t *, unsigned nmegs);
void initShadowPaging(vm_t *vm);
void genericDeviceOpen(vm_t *);
unsigned genericModuleInit(void);
unsigned hostIdle(void);
void *hostAllocZeroedMem(unsigned long size);
void hostFreeMem(void *ptr);
void *hostAllocZeroedPage(void);
void hostFreePage(void *ptr);
unsigned hostGetAllocedMemPhyPages(Bit32u *page, int max_pages, void *ptr,
unsigned size);
Bit32u hostGetAllocedPagePhyPage(void *ptr);
void hostPrint(char *fmt, ...);
Bit32u hostKernelOffset(void);
unsigned getCpuCapabilities(void);
#define Plex86ErrnoEBUSY 1
#define Plex86ErrnoENOMEM 2
#define Plex86ErrnoEFAULT 3
#define Plex86ErrnoEINVAL 4
int ioctlGeneric(vm_t *vm, void *inode, void *filp,
unsigned int cmd, unsigned long arg);
int ioctlExecute(vm_t *vm, plex86IoctlExecute_t *executeMsg);
unsigned ioctlAllocVPhys(vm_t *vm, unsigned long arg);
void copyGuestStateToUserSpace(vm_t *vm);
void reserve_guest_pages(vm_t *vm);
void unreserve_guest_pages(vm_t *vm);
int hostConvertPlex86Errno(unsigned ret);
unsigned hostMMapCheck(void *i, void *f);
void hostModuleCountReset(vm_t *vm, void *inode, void *filp);
unsigned long hostCopyFromUser(void *to, void *from, unsigned long len);
unsigned long hostCopyToUser(void *to, void *from, unsigned long len);
#define vm_save_flags(x) \
asm volatile("pushfl ; popl %0": "=g" (x): :"memory")
#define vm_restore_flags(x) \
asm volatile("pushl %0 ; popfl": :"g" (x): "memory", "cc")
#endif /* HOST Space */
#ifdef IN_MONITOR_SPACE
/* ==========================================================
* These are the functions which are available to the monitor
* running in the monitor/guest space.
*/
void monpanic(vm_t *, char *fmt, ...) __attribute__ ((noreturn));
void monpanic_nomess(vm_t *);
void sysRemapMonitor(vm_t *);
void toHostGuestFault(vm_t *, unsigned fault);
void guestPageFault(vm_t *, guest_context_t *context, Bit32u cr2);
void *open_guest_phy_page(vm_t *, Bit32u ppage_index, Bit8u *mon_offset);
void close_guest_phy_page(vm_t *, Bit32u ppage_index);
#define MapLinOK 0
#define MapLinMonConflict 1
#define MapLinAlreadyMapped 2
#define MapLinPPageOOB 3
#define MapLinException 4
#define MapLinEmulate 5
unsigned mapGuestLinAddr(vm_t *, Bit32u guest_laddr,
Bit32u *guest_ppage_index, unsigned us,
unsigned rw, Bit32u attr, Bit32u *error);
unsigned addPageAttributes(vm_t *, Bit32u ppi, Bit32u attr);
phy_page_usage_t *getPageUsage(vm_t *, Bit32u ppage_index);
void virtualize_lconstruct(vm_t *, Bit32u l0, Bit32u l1, unsigned perm);
unsigned getMonPTi(vm_t *, unsigned pdi, unsigned source);
#define invlpg_mon_offset(mon_offset) \
asm volatile ("invlpg (%0)": :"r" (mon_offset): "memory")
/* For now nothing, but we should conditionally compile in code
* to panic when the expression is not true.
*/
#define VM_ASSERT(vm, expression) \
if ( !(expression) ) \
monpanic(vm, "Assertion (%s) failed at %s:%u", \
#expression, __FILE__, __LINE__)
#define CLI() asm volatile ("cli": : : "memory")
#define STI() asm volatile ("sti": : : "memory")
extern const selector_t nullSelector;
extern const descriptor_t nullDescriptor;
#endif /* MONITOR Space. */
#endif /* __MONITOR_H__ */