Primary goal for these changes is:
- no longer have kernel have its own page table that is loaded
on every kernel entry (trap, interrupt, exception). the primary
purpose is to reduce the number of required reloads.
Result:
- kernel can only access memory of process that was running when
kernel was entered
- kernel must be mapped into every process page table, so traps to
kernel keep working
Problem:
- kernel must often access memory of arbitrary processes (e.g. send
arbitrary processes messages); this can't happen directly any more;
usually because that process' page table isn't loaded at all, sometimes
because that memory isn't mapped in at all, sometimes because it isn't
mapped in read-write.
So:
- kernel must be able to map in memory of any process, in its own
address space.
Implementation:
- VM and kernel share a range of memory in which addresses of
all page tables of all processes are available. This has two purposes:
. Kernel has to know what data to copy in order to map in a range
. Kernel has to know where to write the data in order to map it in
That last point is because kernel has to write in the currently loaded
page table.
- Processes and kernel are separated through segments; kernel segments
haven't changed.
- The kernel keeps the process whose page table is currently loaded
in 'ptproc.'
- If it wants to map in a range of memory, it writes the value of the
page directory entry for that range into the page directory entry
in the currently loaded map. There is a slot reserved for such
purposes. The kernel can then access this memory directly.
- In order to do this, its segment has been increased (and the
segments of processes start where it ends).
- In the pagefault handler, detect if the kernel is doing
'trappable' memory access (i.e. a pagefault isn't a fatal
error) and if so,
- set the saved instruction pointer to phys_copy_fault,
breaking out of phys_copy
- set the saved eax register to the address of the page
fault, both for sanity checking and for checking in
which of the two ranges that phys_copy was called
with the fault occured
- Some boot-time processes do not have their own page table,
and are mapped in with the kernel, and separated with
segments. The kernel detects this using HASPT. If such a
process has to be scheduled, any page table will work and
no page table switch is done.
Major changes in kernel are
- When accessing user processes memory, kernel no longer
explicitly checks before it does so if that memory is OK.
It simply makes the mapping (if necessary), tries to do the
operation, and traps the pagefault if that memory isn't present;
if that happens, the copy function returns EFAULT.
So all of the CHECKRANGE_OR_SUSPEND macros are gone.
- Kernel no longer has to copy/read and parse page tables.
- A message copying optimisation: when messages are copied, and
the recipient isn't mapped in, they are copied into a buffer
in the kernel. This is done in QueueMess. The next time
the recipient is scheduled, this message is copied into
its memory. This happens in schedcheck().
This eliminates the mapping/copying step for messages, and makes
it easier to deliver messages. This eliminates soft_notify.
- Kernel no longer creates a page table at all, so the vm_setbuf
and pagetable writing in memory.c is gone.
Minor changes in kernel are
- ipc_stats thrown out, wasn't used
- misc flags all renamed to MF_*
- NOREC_* macros to enter and leave functions that should not
be called recursively; just sanity checks really
- code to fully decode segment selectors and descriptors
to print on exceptions
- lots of vmassert()s added, only executed if DEBUG_VMASSERT is 1
This commit is contained in:
@@ -52,7 +52,6 @@ OBJECTS = \
|
||||
$(SYSTEM)(do_sigreturn.o) \
|
||||
$(SYSTEM)(do_abort.o) \
|
||||
$(SYSTEM)(do_getinfo.o) \
|
||||
$(SYSTEM)(do_vm_setbuf.o) \
|
||||
$(SYSTEM)(do_sprofile.o) \
|
||||
$(SYSTEM)(do_cprofile.o) \
|
||||
$(SYSTEM)(do_profbuf.o) \
|
||||
@@ -166,9 +165,6 @@ $(SYSTEM)(do_vm.o): do_vm.o
|
||||
do_vm.o: do_vm.c
|
||||
$(CC) do_vm.c
|
||||
|
||||
$(SYSTEM)(do_vm_setbuf.o): do_vm_setbuf.c
|
||||
$(CC) do_vm_setbuf.c
|
||||
|
||||
$(SYSTEM)(do_sprofile.o): do_sprofile.c
|
||||
$(CC) do_sprofile.c
|
||||
|
||||
|
||||
@@ -63,19 +63,8 @@ register message *m_ptr; /* pointer to request message */
|
||||
}
|
||||
if (i >= nr_io_range)
|
||||
{
|
||||
static int curr= 0, limit= 100, extra= 20;
|
||||
|
||||
if (curr < limit+extra)
|
||||
{
|
||||
kprintf("do_devio: port 0x%x (size %d) not allowed\n",
|
||||
m_ptr->DIO_PORT, size);
|
||||
} else if (curr == limit+extra)
|
||||
{
|
||||
kprintf("do_devio: no debug output for a while\n");
|
||||
}
|
||||
else if (curr == 2*limit-1)
|
||||
limit *= 2;
|
||||
curr++;
|
||||
return EPERM;
|
||||
}
|
||||
}
|
||||
@@ -83,19 +72,8 @@ register message *m_ptr; /* pointer to request message */
|
||||
doit:
|
||||
if (m_ptr->DIO_PORT & (size-1))
|
||||
{
|
||||
static int curr= 0, limit= 100, extra= 20;
|
||||
|
||||
if (curr < limit+extra)
|
||||
{
|
||||
kprintf("do_devio: unaligned port 0x%x (size %d)\n",
|
||||
m_ptr->DIO_PORT, size);
|
||||
} else if (curr == limit+extra)
|
||||
{
|
||||
kprintf("do_devio: no debug output for a while\n");
|
||||
}
|
||||
else if (curr == 2*limit-1)
|
||||
limit *= 2;
|
||||
curr++;
|
||||
return EPERM;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,11 @@ register message *m_ptr; /* pointer to request message */
|
||||
|
||||
rp = proc_addr(proc_nr);
|
||||
|
||||
if(rp->p_misc_flags & MF_DELIVERMSG) {
|
||||
rp->p_misc_flags &= ~MF_DELIVERMSG;
|
||||
rp->p_delivermsg_lin = 0;
|
||||
}
|
||||
|
||||
/* Save command name for debugging, ps(1) output, etc. */
|
||||
if(data_copy(who_e, (vir_bytes) m_ptr->PR_NAME_PTR,
|
||||
SYSTEM, (vir_bytes) rp->p_name, (phys_bytes) P_NAME_LEN - 1) != OK)
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
|
||||
#include "../system.h"
|
||||
#include "../vm.h"
|
||||
#include <signal.h>
|
||||
|
||||
#include <minix/endpoint.h>
|
||||
@@ -33,10 +34,25 @@ register message *m_ptr; /* pointer to request message */
|
||||
|
||||
if(!isokendpt(m_ptr->PR_ENDPT, &p_proc))
|
||||
return EINVAL;
|
||||
|
||||
rpp = proc_addr(p_proc);
|
||||
rpc = proc_addr(m_ptr->PR_SLOT);
|
||||
if (isemptyp(rpp) || ! isemptyp(rpc)) return(EINVAL);
|
||||
|
||||
vmassert(!(rpp->p_misc_flags & MF_DELIVERMSG));
|
||||
|
||||
/* needs to be receiving so we know where the message buffer is */
|
||||
if(!RTS_ISSET(rpp, RECEIVING)) {
|
||||
printf("kernel: fork not done synchronously?\n");
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
/* memory becomes readonly */
|
||||
if (priv(rpp)->s_asynsize > 0) {
|
||||
printf("kernel: process with waiting asynsend table can't fork\n");
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
map_ptr= (struct mem_map *) m_ptr->PR_MEM_PTR;
|
||||
|
||||
/* Copy parent 'proc' struct to child. And reinitialize some fields. */
|
||||
@@ -59,7 +75,7 @@ register message *m_ptr; /* pointer to request message */
|
||||
|
||||
rpc->p_reg.psw &= ~TRACEBIT; /* clear trace bit */
|
||||
|
||||
rpc->p_misc_flags &= ~(VIRT_TIMER | PROF_TIMER);
|
||||
rpc->p_misc_flags &= ~(MF_VIRT_TIMER | MF_PROF_TIMER);
|
||||
rpc->p_virt_left = 0; /* disable, clear the process-virtual timers */
|
||||
rpc->p_prof_left = 0;
|
||||
|
||||
@@ -81,9 +97,11 @@ register message *m_ptr; /* pointer to request message */
|
||||
|
||||
/* Calculate endpoint identifier, so caller knows what it is. */
|
||||
m_ptr->PR_ENDPT = rpc->p_endpoint;
|
||||
m_ptr->PR_FORK_MSGADDR = (char *) rpp->p_delivermsg_vir;
|
||||
|
||||
/* Install new map */
|
||||
r = newmap(rpc, map_ptr);
|
||||
FIXLINMSG(rpc);
|
||||
|
||||
/* Don't schedule process in VM mode until it has a new pagetable. */
|
||||
if(m_ptr->PR_FORK_FLAGS & PFF_VMINHIBIT) {
|
||||
|
||||
@@ -28,9 +28,8 @@ register message *m_ptr; /* pointer to request message */
|
||||
*/
|
||||
size_t length;
|
||||
vir_bytes src_vir;
|
||||
int proc_nr, nr_e, nr;
|
||||
int proc_nr, nr_e, nr, r;
|
||||
struct proc *caller;
|
||||
phys_bytes ph;
|
||||
int wipe_rnd_bin = -1;
|
||||
|
||||
caller = proc_addr(who_p);
|
||||
@@ -67,19 +66,6 @@ register message *m_ptr; /* pointer to request message */
|
||||
src_vir = (vir_bytes) irq_hooks;
|
||||
break;
|
||||
}
|
||||
case GET_SCHEDINFO: {
|
||||
/* This is slightly complicated because we need two data structures
|
||||
* at once, otherwise the scheduling information may be incorrect.
|
||||
* Copy the queue heads and fall through to copy the process table.
|
||||
*/
|
||||
if((ph=umap_local(caller, D, (vir_bytes) m_ptr->I_VAL_PTR2,length)) == 0)
|
||||
return EFAULT;
|
||||
length = sizeof(struct proc *) * NR_SCHED_QUEUES;
|
||||
CHECKRANGE_OR_SUSPEND(proc_addr(who_p), ph, length, 1);
|
||||
data_copy(SYSTEM, (vir_bytes) rdy_head,
|
||||
who_e, (vir_bytes) m_ptr->I_VAL_PTR2, length);
|
||||
/* fall through to GET_PROCTAB */
|
||||
}
|
||||
case GET_PROCTAB: {
|
||||
length = sizeof(struct proc) * (NR_PROCS + NR_TASKS);
|
||||
src_vir = (vir_bytes) proc;
|
||||
@@ -174,15 +160,16 @@ register message *m_ptr; /* pointer to request message */
|
||||
|
||||
/* Try to make the actual copy for the requested data. */
|
||||
if (m_ptr->I_VAL_LEN > 0 && length > m_ptr->I_VAL_LEN) return (E2BIG);
|
||||
if((ph=umap_local(caller, D, (vir_bytes) m_ptr->I_VAL_PTR,length)) == 0)
|
||||
return EFAULT;
|
||||
CHECKRANGE_OR_SUSPEND(caller, ph, length, 1);
|
||||
if(data_copy(SYSTEM, src_vir, who_e, (vir_bytes) m_ptr->I_VAL_PTR, length) == OK) {
|
||||
r = data_copy_vmcheck(SYSTEM, src_vir, who_e,
|
||||
(vir_bytes) m_ptr->I_VAL_PTR, length);
|
||||
|
||||
if(r != OK) return r;
|
||||
|
||||
if(wipe_rnd_bin >= 0 && wipe_rnd_bin < RANDOM_SOURCES) {
|
||||
krandom.bin[wipe_rnd_bin].r_size = 0;
|
||||
krandom.bin[wipe_rnd_bin].r_next = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return(OK);
|
||||
}
|
||||
|
||||
|
||||
@@ -139,10 +139,16 @@ irq_hook_t *hook;
|
||||
*/
|
||||
int proc_nr;
|
||||
|
||||
vmassert(intr_disabled());
|
||||
|
||||
/* As a side-effect, the interrupt handler gathers random information by
|
||||
* timestamping the interrupt events. This is used for /dev/random.
|
||||
*/
|
||||
#if 0
|
||||
get_randomness(&krandom, hook->irq);
|
||||
#else
|
||||
FIXME("get_randomness disabled");
|
||||
#endif
|
||||
|
||||
/* Check if the handler is still alive.
|
||||
* If it's dead, this should never happen, as processes that die
|
||||
@@ -158,7 +164,8 @@ irq_hook_t *hook;
|
||||
priv(proc_addr(proc_nr))->s_int_pending |= (1 << hook->notify_id);
|
||||
|
||||
/* Build notification message and return. */
|
||||
lock_notify(HARDWARE, hook->proc_nr_e);
|
||||
vmassert(intr_disabled());
|
||||
mini_notify(proc_addr(HARDWARE), hook->proc_nr_e);
|
||||
return(hook->policy & IRQ_REENABLE);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
#include "../system.h"
|
||||
#include "../vm.h"
|
||||
|
||||
#if USE_MEMSET
|
||||
|
||||
@@ -18,10 +19,8 @@ PUBLIC int do_memset(m_ptr)
|
||||
register message *m_ptr;
|
||||
{
|
||||
/* Handle sys_memset(). This writes a pattern into the specified memory. */
|
||||
unsigned long p;
|
||||
unsigned char c = m_ptr->MEM_PATTERN;
|
||||
p = c | (c << 8) | (c << 16) | (c << 24);
|
||||
phys_memset((phys_bytes) m_ptr->MEM_PTR, p, (phys_bytes) m_ptr->MEM_COUNT);
|
||||
vm_phys_memset((phys_bytes) m_ptr->MEM_PTR, c, (phys_bytes) m_ptr->MEM_COUNT);
|
||||
return(OK);
|
||||
}
|
||||
|
||||
|
||||
@@ -61,22 +61,11 @@ endpoint_t *e_granter; /* new granter (magic grants) */
|
||||
if(!HASGRANTTABLE(granter_proc)) return EPERM;
|
||||
|
||||
if(priv(granter_proc)->s_grant_entries <= grant) {
|
||||
static int curr= 0, limit= 100, extra= 20;
|
||||
|
||||
if (curr < limit+extra)
|
||||
{
|
||||
kprintf(
|
||||
"verify_grant: grant verify failed in ep %d proc %d: "
|
||||
"grant %d out of range for table size %d\n",
|
||||
granter, proc_nr, grant,
|
||||
priv(granter_proc)->s_grant_entries);
|
||||
} else if (curr == limit+extra)
|
||||
{
|
||||
kprintf("verify_grant: no debug output for a while\n");
|
||||
}
|
||||
else if (curr == 2*limit-1)
|
||||
limit *= 2;
|
||||
curr++;
|
||||
return(EPERM);
|
||||
}
|
||||
|
||||
@@ -219,23 +208,9 @@ int access; /* CPF_READ for a copy from granter to grantee, CPF_WRITE
|
||||
/* Verify permission exists. */
|
||||
if((r=verify_grant(granter, grantee, grantid, bytes, access,
|
||||
g_offset, &v_offset, &new_granter)) != OK) {
|
||||
static int curr= 0, limit= 100, extra= 20;
|
||||
|
||||
if (curr < limit+extra)
|
||||
{
|
||||
#if 0
|
||||
kprintf(
|
||||
"grant %d verify to copy %d->%d by %d failed: err %d\n",
|
||||
grantid, *src, *dst, grantee, r);
|
||||
#endif
|
||||
} else if (curr == limit+extra)
|
||||
{
|
||||
kprintf(
|
||||
"do_safecopy`safecopy: no debug output for a while\n");
|
||||
}
|
||||
else if (curr == 2*limit-1)
|
||||
limit *= 2;
|
||||
curr++;
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,18 +29,13 @@ message *m_ptr; /* pointer to request message */
|
||||
struct sigcontext sc, *scp;
|
||||
struct sigframe fr, *frp;
|
||||
int proc_nr, r;
|
||||
phys_bytes ph;
|
||||
|
||||
if (!isokendpt(m_ptr->SIG_ENDPT, &proc_nr)) return(EINVAL);
|
||||
if (iskerneln(proc_nr)) return(EPERM);
|
||||
rp = proc_addr(proc_nr);
|
||||
|
||||
ph = umap_local(proc_addr(who_p), D, (vir_bytes) m_ptr->SIG_CTXT_PTR, sizeof(struct sigmsg));
|
||||
if(!ph) return EFAULT;
|
||||
CHECKRANGE_OR_SUSPEND(proc_addr(who_p), ph, sizeof(struct sigmsg), 1);
|
||||
|
||||
/* Get the sigmsg structure into our address space. */
|
||||
if((r=data_copy(who_e, (vir_bytes) m_ptr->SIG_CTXT_PTR,
|
||||
if((r=data_copy_vmcheck(who_e, (vir_bytes) m_ptr->SIG_CTXT_PTR,
|
||||
SYSTEM, (vir_bytes) &smsg, (phys_bytes) sizeof(struct sigmsg))) != OK)
|
||||
return r;
|
||||
|
||||
@@ -54,12 +49,9 @@ message *m_ptr; /* pointer to request message */
|
||||
sc.sc_flags = 0; /* unused at this time */
|
||||
sc.sc_mask = smsg.sm_mask;
|
||||
|
||||
ph = umap_local(rp, D, (vir_bytes) scp, sizeof(struct sigcontext));
|
||||
if(!ph) return EFAULT;
|
||||
CHECKRANGE_OR_SUSPEND(rp, ph, sizeof(struct sigcontext), 1);
|
||||
/* Copy the sigcontext structure to the user's stack. */
|
||||
if((r=data_copy(SYSTEM, (vir_bytes) &sc, m_ptr->SIG_ENDPT, (vir_bytes) scp,
|
||||
(vir_bytes) sizeof(struct sigcontext))) != OK)
|
||||
if((r=data_copy_vmcheck(SYSTEM, (vir_bytes) &sc, m_ptr->SIG_ENDPT,
|
||||
(vir_bytes) scp, (vir_bytes) sizeof(struct sigcontext))) != OK)
|
||||
return r;
|
||||
|
||||
/* Initialize the sigframe structure. */
|
||||
@@ -73,11 +65,9 @@ message *m_ptr; /* pointer to request message */
|
||||
fr.sf_signo = smsg.sm_signo;
|
||||
fr.sf_retadr = (void (*)()) smsg.sm_sigreturn;
|
||||
|
||||
ph = umap_local(rp, D, (vir_bytes) frp, sizeof(struct sigframe));
|
||||
if(!ph) return EFAULT;
|
||||
CHECKRANGE_OR_SUSPEND(rp, ph, sizeof(struct sigframe), 1);
|
||||
/* Copy the sigframe structure to the user's stack. */
|
||||
if((r=data_copy(SYSTEM, (vir_bytes) &fr, m_ptr->SIG_ENDPT, (vir_bytes) frp,
|
||||
if((r=data_copy_vmcheck(SYSTEM, (vir_bytes) &fr,
|
||||
m_ptr->SIG_ENDPT, (vir_bytes) frp,
|
||||
(vir_bytes) sizeof(struct sigframe))) != OK)
|
||||
return r;
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
PUBLIC int do_sysctl(m_ptr)
|
||||
register message *m_ptr; /* pointer to request message */
|
||||
{
|
||||
phys_bytes ph;
|
||||
vir_bytes len, buf;
|
||||
static char mybuf[DIAG_BUFSIZE];
|
||||
struct proc *caller, *target;
|
||||
@@ -33,10 +32,7 @@ register message *m_ptr; /* pointer to request message */
|
||||
caller->p_endpoint, len);
|
||||
return EINVAL;
|
||||
}
|
||||
if((ph=umap_local(caller, D, buf, len)) == 0)
|
||||
return EFAULT;
|
||||
CHECKRANGE_OR_SUSPEND(caller, ph, len, 1);
|
||||
if((s=data_copy(who_e, buf, SYSTEM, (vir_bytes) mybuf, len)) != OK) {
|
||||
if((s=data_copy_vmcheck(who_e, buf, SYSTEM, (vir_bytes) mybuf, len)) != OK) {
|
||||
kprintf("do_sysctl: diag for %d: len %d: copy failed: %d\n",
|
||||
caller->p_endpoint, len, s);
|
||||
return s;
|
||||
|
||||
@@ -48,19 +48,15 @@ register message *m_ptr; /* pointer to request message */
|
||||
case LOCAL_SEG:
|
||||
phys_addr = lin_addr = umap_local(targetpr, seg_index, offset, count);
|
||||
if(!lin_addr) return EFAULT;
|
||||
CHECKRANGE_OR_SUSPEND(targetpr, lin_addr, count, 1);
|
||||
naughty = 1;
|
||||
break;
|
||||
case REMOTE_SEG:
|
||||
phys_addr = lin_addr = umap_remote(targetpr, seg_index, offset, count);
|
||||
if(!lin_addr) return EFAULT;
|
||||
CHECKRANGE_OR_SUSPEND(targetpr, lin_addr, count, 1);
|
||||
naughty = 1;
|
||||
break;
|
||||
case GRANT_SEG:
|
||||
naughty = 1;
|
||||
case LOCAL_VM_SEG:
|
||||
if(seg_index == MEM_GRANT || seg_type == GRANT_SEG) {
|
||||
if(seg_index == MEM_GRANT) {
|
||||
vir_bytes newoffset;
|
||||
endpoint_t newep;
|
||||
int new_proc_nr;
|
||||
@@ -93,7 +89,6 @@ register message *m_ptr; /* pointer to request message */
|
||||
kprintf("SYSTEM:do_umap: umap_local failed\n");
|
||||
return EFAULT;
|
||||
}
|
||||
CHECKRANGE_OR_SUSPEND(targetpr, lin_addr, count, 1);
|
||||
if(vm_lookup(targetpr, lin_addr, &phys_addr, NULL) != OK) {
|
||||
kprintf("SYSTEM:do_umap: vm_lookup failed\n");
|
||||
return EFAULT;
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
/* The system call implemented in this file:
|
||||
* m_type: SYS_VM_SETBUF
|
||||
*
|
||||
* The parameters for this system call are:
|
||||
* m4_l1: Start of the buffer
|
||||
* m4_l2: Length of the buffer
|
||||
* m4_l3: End of main memory
|
||||
*/
|
||||
#include "../system.h"
|
||||
|
||||
#define VM_DEBUG 0 /* enable/ disable debug output */
|
||||
|
||||
/*===========================================================================*
|
||||
* do_vm_setbuf *
|
||||
*===========================================================================*/
|
||||
PUBLIC int do_vm_setbuf(m_ptr)
|
||||
message *m_ptr; /* pointer to request message */
|
||||
{
|
||||
vm_base= m_ptr->m4_l1;
|
||||
vm_size= m_ptr->m4_l2;
|
||||
vm_mem_high= m_ptr->m4_l3;
|
||||
|
||||
#if VM_DEBUG
|
||||
kprintf("do_vm_setbuf: got 0x%x @ 0x%x for 0x%x\n",
|
||||
vm_size, vm_base, vm_mem_high);
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
@@ -21,12 +21,10 @@ register message *m_ptr; /* pointer to request message */
|
||||
{
|
||||
int proc_nr, i;
|
||||
endpoint_t ep = m_ptr->SVMCTL_WHO;
|
||||
struct proc *p, *rp;
|
||||
struct proc *p, *rp, *target;
|
||||
|
||||
if(ep == SELF) { ep = m_ptr->m_source; }
|
||||
|
||||
vm_init();
|
||||
|
||||
if(!isokendpt(ep, &proc_nr)) {
|
||||
kprintf("do_vmctl: unexpected endpoint %d from VM\n", ep);
|
||||
return EINVAL;
|
||||
@@ -42,14 +40,35 @@ register message *m_ptr; /* pointer to request message */
|
||||
/* Send VM the information about the memory request. */
|
||||
if(!(rp = vmrequest))
|
||||
return ESRCH;
|
||||
if(!RTS_ISSET(rp, VMREQUEST))
|
||||
minix_panic("do_vmctl: no VMREQUEST set", NO_NUM);
|
||||
vmassert(RTS_ISSET(rp, VMREQUEST));
|
||||
|
||||
#if 0
|
||||
printf("kernel: vm request sent by: %s / %d about %d; 0x%lx-0x%lx, wr %d, stack: %s ",
|
||||
rp->p_name, rp->p_endpoint, rp->p_vmrequest.who,
|
||||
rp->p_vmrequest.start,
|
||||
rp->p_vmrequest.start + rp->p_vmrequest.length,
|
||||
rp->p_vmrequest.writeflag, rp->p_vmrequest.stacktrace);
|
||||
printf("type %d\n", rp->p_vmrequest.type);
|
||||
#endif
|
||||
|
||||
#if DEBUG_VMASSERT
|
||||
okendpt(rp->p_vmrequest.who, &proc_nr);
|
||||
target = proc_addr(proc_nr);
|
||||
#if 0
|
||||
if(!RTS_ISSET(target, VMREQTARGET)) {
|
||||
printf("set stack: %s\n", rp->p_vmrequest.stacktrace);
|
||||
minix_panic("VMREQTARGET not set for target",
|
||||
NO_NUM);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Reply with request fields. */
|
||||
m_ptr->SVMCTL_MRG_ADDR = (char *) rp->p_vmrequest.start;
|
||||
m_ptr->SVMCTL_MRG_LEN = rp->p_vmrequest.length;
|
||||
m_ptr->SVMCTL_MRG_WRITE = rp->p_vmrequest.writeflag;
|
||||
m_ptr->SVMCTL_MRG_EP = rp->p_vmrequest.who;
|
||||
m_ptr->SVMCTL_MRG_REQUESTOR = (void *) rp->p_endpoint;
|
||||
rp->p_vmrequest.vmresult = VMSUSPEND;
|
||||
|
||||
/* Remove from request chain. */
|
||||
@@ -57,46 +76,61 @@ register message *m_ptr; /* pointer to request message */
|
||||
|
||||
return OK;
|
||||
case VMCTL_MEMREQ_REPLY:
|
||||
if(!(rp = p->p_vmrequest.requestor))
|
||||
minix_panic("do_vmctl: no requestor set", ep);
|
||||
p->p_vmrequest.requestor = NULL;
|
||||
if(!RTS_ISSET(rp, VMREQUEST))
|
||||
minix_panic("do_vmctl: no VMREQUEST set", ep);
|
||||
if(rp->p_vmrequest.vmresult != VMSUSPEND)
|
||||
minix_panic("do_vmctl: result not VMSUSPEND set",
|
||||
rp->p_vmrequest.vmresult);
|
||||
rp->p_vmrequest.vmresult = m_ptr->SVMCTL_VALUE;
|
||||
if(rp->p_vmrequest.vmresult == VMSUSPEND)
|
||||
minix_panic("VM returned VMSUSPEND?", NO_NUM);
|
||||
if(rp->p_vmrequest.vmresult != OK)
|
||||
vmassert(RTS_ISSET(p, VMREQUEST));
|
||||
vmassert(p->p_vmrequest.vmresult == VMSUSPEND);
|
||||
okendpt(p->p_vmrequest.who, &proc_nr);
|
||||
target = proc_addr(proc_nr);
|
||||
p->p_vmrequest.vmresult = m_ptr->SVMCTL_VALUE;
|
||||
vmassert(p->p_vmrequest.vmresult != VMSUSPEND);
|
||||
if(p->p_vmrequest.vmresult != OK)
|
||||
kprintf("SYSTEM: VM replied %d to mem request\n",
|
||||
rp->p_vmrequest.vmresult);
|
||||
p->p_vmrequest.vmresult);
|
||||
|
||||
/* Put on restart chain. */
|
||||
rp->p_vmrequest.nextrestart = vmrestart;
|
||||
vmrestart = rp;
|
||||
|
||||
#if 0
|
||||
printf("memreq reply: vm request sent by: %s / %d about %d; 0x%lx-0x%lx, wr %d, stack: %s ",
|
||||
p->p_name, p->p_endpoint, p->p_vmrequest.who,
|
||||
p->p_vmrequest.start,
|
||||
p->p_vmrequest.start + p->p_vmrequest.length,
|
||||
p->p_vmrequest.writeflag, p->p_vmrequest.stacktrace);
|
||||
printf("type %d\n", p->p_vmrequest.type);
|
||||
|
||||
vmassert(RTS_ISSET(target, VMREQTARGET));
|
||||
RTS_LOCK_UNSET(target, VMREQTARGET);
|
||||
#endif
|
||||
|
||||
if(p->p_vmrequest.type == VMSTYPE_KERNELCALL) {
|
||||
/* Put on restart chain. */
|
||||
p->p_vmrequest.nextrestart = vmrestart;
|
||||
vmrestart = p;
|
||||
} else if(p->p_vmrequest.type == VMSTYPE_DELIVERMSG) {
|
||||
vmassert(p->p_misc_flags & MF_DELIVERMSG);
|
||||
vmassert(p == target);
|
||||
vmassert(RTS_ISSET(p, VMREQUEST));
|
||||
RTS_LOCK_UNSET(p, VMREQUEST);
|
||||
} else {
|
||||
#if DEBUG_VMASSERT
|
||||
/* Sanity check. */
|
||||
if(rp->p_vmrequest.vmresult == OK) {
|
||||
if(CHECKRANGE(p,
|
||||
rp->p_vmrequest.start,
|
||||
rp->p_vmrequest.length,
|
||||
rp->p_vmrequest.writeflag) != OK) {
|
||||
kprintf("SYSTEM: request %d:0x%lx-0x%lx, wrflag %d, failed\n",
|
||||
rp->p_endpoint,
|
||||
rp->p_vmrequest.start, rp->p_vmrequest.start + rp->p_vmrequest.length,
|
||||
rp->p_vmrequest.writeflag);
|
||||
|
||||
minix_panic("SYSTEM: fail but VM said OK", NO_NUM);
|
||||
}
|
||||
printf("suspended with stack: %s\n",
|
||||
p->p_vmrequest.stacktrace);
|
||||
#endif
|
||||
minix_panic("strange request type",
|
||||
p->p_vmrequest.type);
|
||||
}
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
#if VM_KERN_NOPAGEZERO
|
||||
case VMCTL_NOPAGEZERO:
|
||||
case VMCTL_ENABLE_PAGING:
|
||||
if(vm_running)
|
||||
minix_panic("do_vmctl: paging already enabled", NO_NUM);
|
||||
vm_init(p);
|
||||
if(!vm_running)
|
||||
minix_panic("do_vmctl: paging enabling failed", NO_NUM);
|
||||
vmassert(p->p_delivermsg_lin ==
|
||||
umap_local(p, D, p->p_delivermsg_vir, sizeof(message)));
|
||||
if(newmap(p, (struct mem_map *) m_ptr->SVMCTL_VALUE) != OK)
|
||||
minix_panic("do_vmctl: newmap failed", NO_NUM);
|
||||
FIXLINMSG(p);
|
||||
vmassert(p->p_delivermsg_lin);
|
||||
return OK;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Try architecture-specific vmctls. */
|
||||
|
||||
@@ -46,10 +46,10 @@ message *m_ptr; /* pointer to request message */
|
||||
* VT_VIRTUAL and VT_PROF multiple times below.
|
||||
*/
|
||||
if (m_ptr->VT_WHICH == VT_VIRTUAL) {
|
||||
pt_flag = VIRT_TIMER;
|
||||
pt_flag = MF_VIRT_TIMER;
|
||||
pt_left = &rp->p_virt_left;
|
||||
} else { /* VT_PROF */
|
||||
pt_flag = PROF_TIMER;
|
||||
pt_flag = MF_PROF_TIMER;
|
||||
pt_left = &rp->p_prof_left;
|
||||
}
|
||||
|
||||
@@ -101,15 +101,15 @@ struct proc *rp; /* pointer to the process */
|
||||
*/
|
||||
|
||||
/* Check if the virtual timer expired. If so, send a SIGVTALRM signal. */
|
||||
if ((rp->p_misc_flags & VIRT_TIMER) && rp->p_virt_left <= 0) {
|
||||
rp->p_misc_flags &= ~VIRT_TIMER;
|
||||
if ((rp->p_misc_flags & MF_VIRT_TIMER) && rp->p_virt_left <= 0) {
|
||||
rp->p_misc_flags &= ~MF_VIRT_TIMER;
|
||||
rp->p_virt_left = 0;
|
||||
cause_sig(rp->p_nr, SIGVTALRM);
|
||||
}
|
||||
|
||||
/* Check if the profile timer expired. If so, send a SIGPROF signal. */
|
||||
if ((rp->p_misc_flags & PROF_TIMER) && rp->p_prof_left <= 0) {
|
||||
rp->p_misc_flags &= ~PROF_TIMER;
|
||||
if ((rp->p_misc_flags & MF_PROF_TIMER) && rp->p_prof_left <= 0) {
|
||||
rp->p_misc_flags &= ~MF_PROF_TIMER;
|
||||
rp->p_prof_left = 0;
|
||||
cause_sig(rp->p_nr, SIGPROF);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user