minix/lib/libsys/sys_vmctl.c
Tomas Hruby f51eea4b32 Changed pagefault delivery to VM
this patch changes the way pagefaults are delivered to VM. It adopts
the same model as the out-of-quantum messages sent by kernel to a
scheduler.

- everytime a userspace pagefault occurs, kernel creates a message
  which is sent to VM on behalf of the faulting process

- the process is blocked on delivery to VM in the standard IPC code
  instead of waiting in a spacial in-kernel queue (stack) and is not
  runnable until VM tell kernel that the pagefault is resolved and is
  free to clear the RTS_PAGEFAULT flag.

- VM does not need call kernel and poll the pagefault information
  which saves many (1/2?) calls and kernel calls that return "no more
  data"

- VM notification by kernel does not need to use signals

- each entry in proc table is by 12 bytes smaller (~3k save)
2010-04-26 23:21:26 +00:00

92 lines
1.8 KiB
C

#include "syslib.h"
PUBLIC int sys_vmctl(endpoint_t who, int param, u32_t value)
{
message m;
int r;
m.SVMCTL_WHO = who;
m.SVMCTL_PARAM = param;
m.SVMCTL_VALUE = value;
r = _kernel_call(SYS_VMCTL, &m);
return(r);
}
PUBLIC int sys_vmctl_get_cr3_i386(endpoint_t who, u32_t *cr3)
{
message m;
int r;
m.SVMCTL_WHO = who;
m.SVMCTL_PARAM = VMCTL_I386_GETCR3;
r = _kernel_call(SYS_VMCTL, &m);
if(r == OK) {
*cr3 = m.SVMCTL_VALUE;
}
return(r);
}
PUBLIC int sys_vmctl_get_memreq(endpoint_t *who, vir_bytes *mem,
vir_bytes *len, int *wrflag, endpoint_t *who_s, vir_bytes *mem_s,
endpoint_t *requestor)
{
message m;
int r;
m.SVMCTL_WHO = SELF;
m.SVMCTL_PARAM = VMCTL_MEMREQ_GET;
r = _kernel_call(SYS_VMCTL, &m);
if(r >= 0) {
*who = m.SVMCTL_MRG_TARGET;
*mem = m.SVMCTL_MRG_ADDR;
*len = m.SVMCTL_MRG_LENGTH;
*wrflag = m.SVMCTL_MRG_FLAG;
*who_s = m.SVMCTL_MRG_EP2;
*mem_s = m.SVMCTL_MRG_ADDR2;
*requestor = (endpoint_t) m.SVMCTL_MRG_REQUESTOR;
}
return r;
}
PUBLIC int sys_vmctl_enable_paging(void * data)
{
message m;
m.SVMCTL_WHO = SELF;
m.SVMCTL_PARAM = VMCTL_ENABLE_PAGING;
m.SVMCTL_VALUE = (u32_t) data;
return _kernel_call(SYS_VMCTL, &m);
}
PUBLIC int sys_vmctl_get_mapping(int index,
phys_bytes *addr, phys_bytes *len, int *flags)
{
int r;
message m;
m.SVMCTL_WHO = SELF;
m.SVMCTL_PARAM = VMCTL_KERN_PHYSMAP;
m.SVMCTL_VALUE = (int) index;
r = _kernel_call(SYS_VMCTL, &m);
if(r != OK)
return r;
*addr = m.SVMCTL_MAP_PHYS_ADDR;
*len = m.SVMCTL_MAP_PHYS_LEN;
*flags = m.SVMCTL_MAP_FLAGS;
return OK;
}
PUBLIC int sys_vmctl_reply_mapping(int index, vir_bytes addr)
{
message m;
m.SVMCTL_WHO = SELF;
m.SVMCTL_PARAM = VMCTL_KERN_MAP_REPLY;
m.SVMCTL_VALUE = index;
m.SVMCTL_MAP_VIR_ADDR = (char *) addr;
return _kernel_call(SYS_VMCTL, &m);
}