2005-10-14 10:58:59 +02:00
|
|
|
/* The kernel call implemented in this file:
|
2005-04-21 16:53:53 +02:00
|
|
|
* m_type: SYS_GETINFO
|
|
|
|
*
|
2005-10-14 10:58:59 +02:00
|
|
|
* The parameters for this kernel call are:
|
2005-04-21 16:53:53 +02:00
|
|
|
* m1_i3: I_REQUEST (what info to get)
|
|
|
|
* m1_p1: I_VAL_PTR (where to put it)
|
|
|
|
* m1_i1: I_VAL_LEN (maximum length expected, optional)
|
2005-07-19 14:21:36 +02:00
|
|
|
* m1_p2: I_VAL_PTR2 (second, optional pointer)
|
'proc number' is process slot, 'endpoint' are generation-aware process
instance numbers, encoded and decoded using macros in <minix/endpoint.h>.
proc number -> endpoint migration
. proc_nr in the interrupt hook is now an endpoint, proc_nr_e.
. m_source for messages and notifies is now an endpoint, instead of
proc number.
. isokendpt() converts an endpoint to a process number, returns
success (but fails if the process number is out of range, the
process slot is not a living process, or the given endpoint
number does not match the endpoint number in the process slot,
indicating an old process).
. okendpt() is the same as isokendpt(), but panic()s if the conversion
fails. This is mainly used for decoding message.m_source endpoints,
and other endpoint numbers in kernel data structures, which should
always be correct.
. if DEBUG_ENABLE_IPC_WARNINGS is enabled, isokendpt() and okendpt()
get passed the __FILE__ and __LINE__ of the calling lines, and
print messages about what is wrong with the endpoint number
(out of range proc, empty proc, or inconsistent endpoint number),
with the caller, making finding where the conversion failed easy
without having to include code for every call to print where things
went wrong. Sometimes this is harmless (wrong arg to a kernel call),
sometimes it's a fatal internal inconsistency (bogus m_source).
. some process table fields have been appended an _e to indicate it's
become and endpoint.
. process endpoint is stored in p_endpoint, without generation number.
it turns out the kernel never needs the generation number, except
when fork()ing, so it's decoded then.
. kernel calls all take endpoints as arguments, not proc numbers.
the one exception is sys_fork(), which needs to know in which slot
to put the child.
2006-03-03 11:00:02 +01:00
|
|
|
* m1_i2: I_VAL_LEN2_E (second length or process nr)
|
2005-04-21 16:53:53 +02:00
|
|
|
*/
|
|
|
|
|
2009-02-05 14:00:03 +01:00
|
|
|
#include <string.h>
|
|
|
|
|
2010-04-02 00:22:33 +02:00
|
|
|
#include "kernel/system.h"
|
Split of architecture-dependent and -independent functions for i386,
mainly in the kernel and headers. This split based on work by
Ingmar Alting <iaalting@cs.vu.nl> done for his Minix PowerPC architecture
port.
. kernel does not program the interrupt controller directly, do any
other architecture-dependent operations, or contain assembly any more,
but uses architecture-dependent functions in arch/$(ARCH)/.
. architecture-dependent constants and types defined in arch/$(ARCH)/include.
. <ibm/portio.h> moved to <minix/portio.h>, as they have become, for now,
architecture-independent functions.
. int86, sdevio, readbios, and iopenable are now i386-specific kernel calls
and live in arch/i386/do_* now.
. i386 arch now supports even less 86 code; e.g. mpx86.s and klib86.s have
gone, and 'machine.protected' is gone (and always taken to be 1 in i386).
If 86 support is to return, it should be a new architecture.
. prototypes for the architecture-dependent functions defined in
kernel/arch/$(ARCH)/*.c but used in kernel/ are in kernel/proto.h
. /etc/make.conf included in makefiles and shell scripts that need to
know the building architecture; it defines ARCH=<arch>, currently only
i386.
. some basic per-architecture build support outside of the kernel (lib)
. in clock.c, only dequeue a process if it was ready
. fixes for new include files
files deleted:
. mpx/klib.s - only for choosing between mpx/klib86 and -386
. klib86.s - only for 86
i386-specific files files moved (or arch-dependent stuff moved) to arch/i386/:
. mpx386.s (entry point)
. klib386.s
. sconst.h
. exception.c
. protect.c
. protect.h
. i8269.c
2006-12-22 16:22:27 +01:00
|
|
|
|
|
|
|
|
2005-07-14 17:12:12 +02:00
|
|
|
#if USE_GETINFO
|
|
|
|
|
2010-09-15 16:10:21 +02:00
|
|
|
#include <minix/u64.h>
|
2013-06-25 14:41:01 +02:00
|
|
|
#include <sys/resource.h>
|
2010-09-15 16:10:21 +02:00
|
|
|
|
2011-12-16 17:06:09 +01:00
|
|
|
/*===========================================================================*
|
|
|
|
* update_idle_time *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
static void update_idle_time(void)
|
2010-09-15 16:10:21 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct proc * idl = proc_addr(IDLE);
|
|
|
|
|
2010-10-04 21:12:55 +02:00
|
|
|
idl->p_cycles = make64(0, 0);
|
|
|
|
|
2010-09-15 16:10:21 +02:00
|
|
|
for (i = 0; i < CONFIG_MAX_CPUS ; i++) {
|
2013-11-11 19:17:03 +01:00
|
|
|
idl->p_cycles += get_cpu_var(i, idle_proc).p_cycles;
|
2010-09-15 16:10:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
/*===========================================================================*
|
|
|
|
* do_getinfo *
|
|
|
|
*===========================================================================*/
|
2012-03-25 20:25:53 +02:00
|
|
|
int do_getinfo(struct proc * caller, message * m_ptr)
|
2005-04-21 16:53:53 +02:00
|
|
|
{
|
2005-07-21 20:36:40 +02:00
|
|
|
/* Request system information to be copied to caller's address space. This
|
|
|
|
* call simply copies entire data structures to the caller.
|
|
|
|
*/
|
2005-04-21 16:53:53 +02:00
|
|
|
size_t length;
|
2008-11-19 13:26:10 +01:00
|
|
|
vir_bytes src_vir;
|
2010-01-22 23:01:08 +01:00
|
|
|
int nr_e, nr, r;
|
2009-04-02 17:24:44 +02:00
|
|
|
int wipe_rnd_bin = -1;
|
2011-11-22 02:07:33 +01:00
|
|
|
struct proc *p;
|
2013-06-25 14:41:01 +02:00
|
|
|
struct rusage r_usage;
|
2008-11-19 13:26:10 +01:00
|
|
|
|
2005-07-19 14:21:36 +02:00
|
|
|
/* Set source address and length based on request type. */
|
2007-04-23 15:28:14 +02:00
|
|
|
switch (m_ptr->I_REQUEST) {
|
2005-04-29 17:36:43 +02:00
|
|
|
case GET_MACHINE: {
|
2005-07-19 14:21:36 +02:00
|
|
|
length = sizeof(struct machine);
|
2008-11-19 13:26:10 +01:00
|
|
|
src_vir = (vir_bytes) &machine;
|
2005-07-19 14:21:36 +02:00
|
|
|
break;
|
2005-04-29 17:36:43 +02:00
|
|
|
}
|
|
|
|
case GET_KINFO: {
|
2005-07-19 14:21:36 +02:00
|
|
|
length = sizeof(struct kinfo);
|
2008-11-19 13:26:10 +01:00
|
|
|
src_vir = (vir_bytes) &kinfo;
|
2005-07-19 14:21:36 +02:00
|
|
|
break;
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
2005-11-14 16:50:46 +01:00
|
|
|
case GET_LOADINFO: {
|
|
|
|
length = sizeof(struct loadinfo);
|
2008-11-19 13:26:10 +01:00
|
|
|
src_vir = (vir_bytes) &kloadinfo;
|
|
|
|
break;
|
|
|
|
}
|
2010-10-26 23:07:50 +02:00
|
|
|
case GET_CPUINFO: {
|
|
|
|
length = sizeof(cpu_info);
|
|
|
|
src_vir = (vir_bytes) &cpu_info;
|
|
|
|
break;
|
|
|
|
}
|
2008-11-19 13:26:10 +01:00
|
|
|
case GET_HZ: {
|
2008-12-11 15:15:23 +01:00
|
|
|
length = sizeof(system_hz);
|
|
|
|
src_vir = (vir_bytes) &system_hz;
|
2005-11-14 16:50:46 +01:00
|
|
|
break;
|
|
|
|
}
|
2005-04-21 16:53:53 +02:00
|
|
|
case GET_IMAGE: {
|
2005-07-29 17:26:23 +02:00
|
|
|
length = sizeof(struct boot_image) * NR_BOOT_PROCS;
|
2008-11-19 13:26:10 +01:00
|
|
|
src_vir = (vir_bytes) image;
|
2005-04-21 16:53:53 +02:00
|
|
|
break;
|
|
|
|
}
|
2005-05-02 16:30:04 +02:00
|
|
|
case GET_IRQHOOKS: {
|
2005-07-19 14:21:36 +02:00
|
|
|
length = sizeof(struct irq_hook) * NR_IRQ_HOOKS;
|
2008-11-19 13:26:10 +01:00
|
|
|
src_vir = (vir_bytes) irq_hooks;
|
2005-04-21 16:53:53 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GET_PROCTAB: {
|
2010-09-15 16:10:21 +02:00
|
|
|
update_idle_time();
|
2005-07-19 14:21:36 +02:00
|
|
|
length = sizeof(struct proc) * (NR_PROCS + NR_TASKS);
|
2008-11-19 13:26:10 +01:00
|
|
|
src_vir = (vir_bytes) proc;
|
2005-04-21 16:53:53 +02:00
|
|
|
break;
|
|
|
|
}
|
2005-07-14 17:12:12 +02:00
|
|
|
case GET_PRIVTAB: {
|
2005-07-19 14:21:36 +02:00
|
|
|
length = sizeof(struct priv) * (NR_SYS_PROCS);
|
2008-11-19 13:26:10 +01:00
|
|
|
src_vir = (vir_bytes) priv;
|
2005-07-14 17:12:12 +02:00
|
|
|
break;
|
|
|
|
}
|
2005-04-21 16:53:53 +02:00
|
|
|
case GET_PROC: {
|
'proc number' is process slot, 'endpoint' are generation-aware process
instance numbers, encoded and decoded using macros in <minix/endpoint.h>.
proc number -> endpoint migration
. proc_nr in the interrupt hook is now an endpoint, proc_nr_e.
. m_source for messages and notifies is now an endpoint, instead of
proc number.
. isokendpt() converts an endpoint to a process number, returns
success (but fails if the process number is out of range, the
process slot is not a living process, or the given endpoint
number does not match the endpoint number in the process slot,
indicating an old process).
. okendpt() is the same as isokendpt(), but panic()s if the conversion
fails. This is mainly used for decoding message.m_source endpoints,
and other endpoint numbers in kernel data structures, which should
always be correct.
. if DEBUG_ENABLE_IPC_WARNINGS is enabled, isokendpt() and okendpt()
get passed the __FILE__ and __LINE__ of the calling lines, and
print messages about what is wrong with the endpoint number
(out of range proc, empty proc, or inconsistent endpoint number),
with the caller, making finding where the conversion failed easy
without having to include code for every call to print where things
went wrong. Sometimes this is harmless (wrong arg to a kernel call),
sometimes it's a fatal internal inconsistency (bogus m_source).
. some process table fields have been appended an _e to indicate it's
become and endpoint.
. process endpoint is stored in p_endpoint, without generation number.
it turns out the kernel never needs the generation number, except
when fork()ing, so it's decoded then.
. kernel calls all take endpoints as arguments, not proc numbers.
the one exception is sys_fork(), which needs to know in which slot
to put the child.
2006-03-03 11:00:02 +01:00
|
|
|
nr_e = (m_ptr->I_VAL_LEN2_E == SELF) ?
|
2010-02-03 10:04:48 +01:00
|
|
|
caller->p_endpoint : m_ptr->I_VAL_LEN2_E;
|
'proc number' is process slot, 'endpoint' are generation-aware process
instance numbers, encoded and decoded using macros in <minix/endpoint.h>.
proc number -> endpoint migration
. proc_nr in the interrupt hook is now an endpoint, proc_nr_e.
. m_source for messages and notifies is now an endpoint, instead of
proc number.
. isokendpt() converts an endpoint to a process number, returns
success (but fails if the process number is out of range, the
process slot is not a living process, or the given endpoint
number does not match the endpoint number in the process slot,
indicating an old process).
. okendpt() is the same as isokendpt(), but panic()s if the conversion
fails. This is mainly used for decoding message.m_source endpoints,
and other endpoint numbers in kernel data structures, which should
always be correct.
. if DEBUG_ENABLE_IPC_WARNINGS is enabled, isokendpt() and okendpt()
get passed the __FILE__ and __LINE__ of the calling lines, and
print messages about what is wrong with the endpoint number
(out of range proc, empty proc, or inconsistent endpoint number),
with the caller, making finding where the conversion failed easy
without having to include code for every call to print where things
went wrong. Sometimes this is harmless (wrong arg to a kernel call),
sometimes it's a fatal internal inconsistency (bogus m_source).
. some process table fields have been appended an _e to indicate it's
become and endpoint.
. process endpoint is stored in p_endpoint, without generation number.
it turns out the kernel never needs the generation number, except
when fork()ing, so it's decoded then.
. kernel calls all take endpoints as arguments, not proc numbers.
the one exception is sys_fork(), which needs to know in which slot
to put the child.
2006-03-03 11:00:02 +01:00
|
|
|
if(!isokendpt(nr_e, &nr)) return EINVAL; /* validate request */
|
2005-07-19 14:21:36 +02:00
|
|
|
length = sizeof(struct proc);
|
2008-11-19 13:26:10 +01:00
|
|
|
src_vir = (vir_bytes) proc_addr(nr);
|
2005-04-21 16:53:53 +02:00
|
|
|
break;
|
|
|
|
}
|
2009-12-11 01:08:19 +01:00
|
|
|
case GET_PRIV: {
|
|
|
|
nr_e = (m_ptr->I_VAL_LEN2_E == SELF) ?
|
2010-02-03 10:04:48 +01:00
|
|
|
caller->p_endpoint : m_ptr->I_VAL_LEN2_E;
|
2009-12-11 01:08:19 +01:00
|
|
|
if(!isokendpt(nr_e, &nr)) return EINVAL; /* validate request */
|
|
|
|
length = sizeof(struct priv);
|
|
|
|
src_vir = (vir_bytes) priv_addr(nr_to_id(nr));
|
|
|
|
break;
|
|
|
|
}
|
2011-11-22 02:07:33 +01:00
|
|
|
case GET_REGS: {
|
|
|
|
nr_e = (m_ptr->I_VAL_LEN2_E == SELF) ?
|
|
|
|
caller->p_endpoint : m_ptr->I_VAL_LEN2_E;
|
|
|
|
if(!isokendpt(nr_e, &nr)) return EINVAL; /* validate request */
|
|
|
|
p = proc_addr(nr);
|
|
|
|
length = sizeof(p->p_reg);
|
|
|
|
src_vir = (vir_bytes) &p->p_reg;
|
|
|
|
break;
|
|
|
|
}
|
2008-11-19 13:26:10 +01:00
|
|
|
case GET_WHOAMI: {
|
|
|
|
int len;
|
|
|
|
/* GET_WHOAMI uses m3 and only uses the message contents for info. */
|
2008-12-11 15:15:23 +01:00
|
|
|
m_ptr->GIWHO_EP = caller->p_endpoint;
|
2008-11-19 13:26:10 +01:00
|
|
|
len = MIN(sizeof(m_ptr->GIWHO_NAME), sizeof(caller->p_name))-1;
|
|
|
|
strncpy(m_ptr->GIWHO_NAME, caller->p_name, len);
|
|
|
|
m_ptr->GIWHO_NAME[len] = '\0';
|
2010-07-07 00:05:21 +02:00
|
|
|
m_ptr->GIWHO_PRIVFLAGS = priv(caller)->s_flags;
|
2008-11-19 13:26:10 +01:00
|
|
|
return OK;
|
|
|
|
}
|
2005-04-21 16:53:53 +02:00
|
|
|
case GET_MONPARAMS: {
|
No more intel/minix segments.
This commit removes all traces of Minix segments (the text/data/stack
memory map abstraction in the kernel) and significance of Intel segments
(hardware segments like CS, DS that add offsets to all addressing before
page table translation). This ultimately simplifies the memory layout
and addressing and makes the same layout possible on non-Intel
architectures.
There are only two types of addresses in the world now: virtual
and physical; even the kernel and processes have the same virtual
address space. Kernel and user processes can be distinguished at a
glance as processes won't use 0xF0000000 and above.
No static pre-allocated memory sizes exist any more.
Changes to booting:
. The pre_init.c leaves the kernel and modules exactly as
they were left by the bootloader in physical memory
. The kernel starts running using physical addressing,
loaded at a fixed location given in its linker script by the
bootloader. All code and data in this phase are linked to
this fixed low location.
. It makes a bootstrap pagetable to map itself to a
fixed high location (also in linker script) and jumps to
the high address. All code and data then use this high addressing.
. All code/data symbols linked at the low addresses is prefixed by
an objcopy step with __k_unpaged_*, so that that code cannot
reference highly-linked symbols (which aren't valid yet) or vice
versa (symbols that aren't valid any more).
. The two addressing modes are separated in the linker script by
collecting the unpaged_*.o objects and linking them with low
addresses, and linking the rest high. Some objects are linked
twice, once low and once high.
. The bootstrap phase passes a lot of information (e.g. free memory
list, physical location of the modules, etc.) using the kinfo
struct.
. After this bootstrap the low-linked part is freed.
. The kernel maps in VM into the bootstrap page table so that VM can
begin executing. Its first job is to make page tables for all other
boot processes. So VM runs before RS, and RS gets a fully dynamic,
VM-managed address space. VM gets its privilege info from RS as usual
but that happens after RS starts running.
. Both the kernel loading VM and VM organizing boot processes happen
using the libexec logic. This removes the last reason for VM to
still know much about exec() and vm/exec.c is gone.
Further Implementation:
. All segments are based at 0 and have a 4 GB limit.
. The kernel is mapped in at the top of the virtual address
space so as not to constrain the user processes.
. Processes do not use segments from the LDT at all; there are
no segments in the LDT any more, so no LLDT is needed.
. The Minix segments T/D/S are gone and so none of the
user-space or in-kernel copy functions use them. The copy
functions use a process endpoint of NONE to realize it's
a physical address, virtual otherwise.
. The umap call only makes sense to translate a virtual address
to a physical address now.
. Segments-related calls like newmap and alloc_segments are gone.
. All segments-related translation in VM is gone (vir2map etc).
. Initialization in VM is simpler as no moving around is necessary.
. VM and all other boot processes can be linked wherever they wish
and will be mapped in at the right location by the kernel and VM
respectively.
Other changes:
. The multiboot code is less special: it does not use mb_print
for its diagnostics any more but uses printf() as normal, saving
the output into the diagnostics buffer, only printing to the
screen using the direct print functions if a panic() occurs.
. The multiboot code uses the flexible 'free memory map list'
style to receive the list of free memory if available.
. The kernel determines the memory layout of the processes to
a degree: it tells VM where the kernel starts and ends and
where the kernel wants the top of the process to be. VM then
uses this entire range, i.e. the stack is right at the top,
and mmap()ped bits of memory are placed below that downwards,
and the break grows upwards.
Other Consequences:
. Every process gets its own page table as address spaces
can't be separated any more by segments.
. As all segments are 0-based, there is no distinction between
virtual and linear addresses, nor between userspace and
kernel addresses.
. Less work is done when context switching, leading to a net
performance increase. (8% faster on my machine for 'make servers'.)
. The layout and configuration of the GDT makes sysenter and syscall
possible.
2012-05-07 16:03:35 +02:00
|
|
|
src_vir = (vir_bytes) kinfo.param_buf;
|
|
|
|
length = sizeof(kinfo.param_buf);
|
2005-07-19 14:21:36 +02:00
|
|
|
break;
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
2005-06-03 15:55:06 +02:00
|
|
|
case GET_RANDOMNESS: {
|
2009-04-02 17:24:44 +02:00
|
|
|
static struct k_randomness copy; /* copy to keep counters */
|
2005-07-18 17:40:24 +02:00
|
|
|
int i;
|
|
|
|
|
|
|
|
copy = krandom;
|
|
|
|
for (i= 0; i<RANDOM_SOURCES; i++) {
|
|
|
|
krandom.bin[i].r_size = 0; /* invalidate random data */
|
|
|
|
krandom.bin[i].r_next = 0;
|
|
|
|
}
|
2009-04-02 17:24:44 +02:00
|
|
|
length = sizeof(copy);
|
2008-11-19 13:26:10 +01:00
|
|
|
src_vir = (vir_bytes) ©
|
2005-06-03 15:55:06 +02:00
|
|
|
break;
|
2005-04-21 16:53:53 +02:00
|
|
|
}
|
2009-04-02 17:24:44 +02:00
|
|
|
case GET_RANDOMNESS_BIN: {
|
2010-01-22 23:01:08 +01:00
|
|
|
int bin = m_ptr->I_VAL_LEN2_E;
|
2009-04-02 17:24:44 +02:00
|
|
|
|
|
|
|
if(bin < 0 || bin >= RANDOM_SOURCES) {
|
2010-03-03 16:45:01 +01:00
|
|
|
printf("SYSTEM: GET_RANDOMNESS_BIN: %d out of range\n", bin);
|
2009-04-02 17:24:44 +02:00
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(krandom.bin[bin].r_size < RANDOM_ELEMENTS)
|
|
|
|
return ENOENT;
|
|
|
|
|
|
|
|
length = sizeof(krandom.bin[bin]);
|
|
|
|
src_vir = (vir_bytes) &krandom.bin[bin];
|
|
|
|
|
|
|
|
wipe_rnd_bin = bin;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2006-01-12 15:38:51 +01:00
|
|
|
case GET_IRQACTIDS: {
|
|
|
|
length = sizeof(irq_actids);
|
2008-11-19 13:26:10 +01:00
|
|
|
src_vir = (vir_bytes) irq_actids;
|
2006-01-12 15:38:51 +01:00
|
|
|
break;
|
|
|
|
}
|
2009-12-02 12:52:26 +01:00
|
|
|
case GET_IDLETSC: {
|
2010-02-10 16:36:54 +01:00
|
|
|
struct proc * idl;
|
2011-12-16 17:06:09 +01:00
|
|
|
update_idle_time();
|
2010-02-10 16:36:54 +01:00
|
|
|
idl = proc_addr(IDLE);
|
|
|
|
length = sizeof(idl->p_cycles);
|
|
|
|
src_vir = (vir_bytes) &idl->p_cycles;
|
2009-12-02 12:52:26 +01:00
|
|
|
break;
|
|
|
|
}
|
2013-06-25 14:41:01 +02:00
|
|
|
case GET_RUSAGE: {
|
|
|
|
struct proc *target = NULL;
|
|
|
|
int target_slot = 0;
|
|
|
|
u64_t usec;
|
|
|
|
nr_e = (m_ptr->I_VAL_LEN2_E == SELF) ?
|
|
|
|
caller->p_endpoint : m_ptr->I_VAL_LEN2_E;
|
|
|
|
|
|
|
|
if (!isokendpt(nr_e, &target_slot))
|
|
|
|
return EINVAL;
|
|
|
|
|
|
|
|
target = proc_addr(target_slot);
|
|
|
|
if (isemptyp(target))
|
|
|
|
return EINVAL;
|
|
|
|
|
|
|
|
length = sizeof(r_usage);
|
|
|
|
memset(&r_usage, 0, sizeof(r_usage));
|
|
|
|
usec = target->p_user_time * 1000000 / system_hz;
|
|
|
|
r_usage.ru_utime.tv_sec = usec / 1000000;
|
|
|
|
r_usage.ru_utime.tv_usec = usec % 100000;
|
|
|
|
usec = target->p_sys_time * 1000000 / system_hz;
|
|
|
|
r_usage.ru_stime.tv_sec = usec / 1000000;
|
|
|
|
r_usage.ru_stime.tv_usec = usec % 100000;
|
|
|
|
r_usage.ru_nsignals = target->p_signal_received;
|
|
|
|
src_vir = (vir_bytes) &r_usage;
|
|
|
|
break;
|
|
|
|
}
|
2005-04-21 16:53:53 +02:00
|
|
|
default:
|
2010-03-03 16:45:01 +01:00
|
|
|
printf("do_getinfo: invalid request %d\n", m_ptr->I_REQUEST);
|
2005-04-21 16:53:53 +02:00
|
|
|
return(EINVAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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);
|
2010-02-09 16:20:09 +01:00
|
|
|
r = data_copy_vmcheck(caller, KERNEL, src_vir, caller->p_endpoint,
|
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
2009-09-21 16:31:52 +02:00
|
|
|
(vir_bytes) m_ptr->I_VAL_PTR, length);
|
|
|
|
|
|
|
|
if(r != OK) return r;
|
|
|
|
|
2009-04-02 17:24:44 +02:00
|
|
|
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;
|
|
|
|
}
|
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
2009-09-21 16:31:52 +02:00
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
return(OK);
|
|
|
|
}
|
|
|
|
|
2005-07-14 17:12:12 +02:00
|
|
|
#endif /* USE_GETINFO */
|
2005-04-21 16:53:53 +02:00
|
|
|
|