Commit Graph

165 Commits

Author SHA1 Message Date
Jake Burkholder
06c4f91f00 Implement elf_reloc. This makes klds work.
Obtained from:	netbsd
2001-10-27 07:09:40 +00:00
Jake Burkholder
e754f9c7ef Handle instruction access mmu miss faults in kernel mode. These can only
be generated by non-preloaded klds.
2001-10-27 07:06:15 +00:00
John Baldwin
8e2e767b1f Add a per-thread ucred reference for syscalls and synchronous traps from
userland.  The per thread ucred reference is immutable and thus needs no
locks to be read.  However, until all the proc locking associated with
writes to p_ucred are completed, it is still not safe to use the per-thread
reference.

Tested on:	x86 (SMP), alpha, sparc64
2001-10-26 08:12:54 +00:00
Jonathan Lemon
b792b54c89 Remove call to cninit_finish(). 2001-10-24 17:42:01 +00:00
Mike Barcroft
3a72286480 Remove funky right justification.
Pointed out by:	bde
2001-10-23 00:42:15 +00:00
Dag-Erling Smørgrav
7c62990641 Move procfs_* from procfs_machdep.c into sys_process.c, and rename them to
proc_* in the process; procfs_machdep.c is no longer needed.

Run-tested on i386, build-tested on Alpha, untested on other platforms.
2001-10-21 23:57:24 +00:00
Dag-Erling Smørgrav
1f04261973 [partially forced commit due to pilot error in earlier commit attempt]
{set,fill}_{,fp,db}regs() fixup:

 - Add dummy {set,fill}_dbregs() on architectures that don't have them.

 - KSEfy the powerpc versions (struct proc -> struct thread).

 - Some architectures had the prototypes in md_var.h, some in reg.h, and
   some in both; for consistency, move them to reg.h on all platforms.

These functions aren't really MD (the implementation is MD, but the interface
is MI), so they should move to an MI header, but I haven't figured out which
one yet.

Run-tested on i386, build-tested on Alpha, untested on other platforms.
2001-10-21 22:16:48 +00:00
Jake Burkholder
226d92f1b0 Add missing include. 2001-10-20 20:57:58 +00:00
Jake Burkholder
6bbac2dd30 Add missing includes. 2001-10-20 18:52:44 +00:00
Jake Burkholder
ac7165deae Remove interrupt queue array. Its in globaldata now. 2001-10-20 18:51:45 +00:00
Jake Burkholder
58a822cfc2 Fix get_cyclecount. Wrap in ifdef _KERNEL. 2001-10-20 18:51:10 +00:00
Jake Burkholder
d620294863 Use KTR_PMAP instead of KTR_CT1. 2001-10-20 17:11:07 +00:00
Jake Burkholder
49d8e44385 Catch up to changing entry point names so traces through traps
mostly work right.  This catches recursive traps too early, but
generally such traps are fatal and we won't get this far anyway.
2001-10-20 17:10:34 +00:00
Jake Burkholder
e47e7481db Add a definition for normal kernel window state. 2001-10-20 17:08:33 +00:00
Jake Burkholder
cc0bc9ad21 Catch up to new assembly language code. 2001-10-20 17:07:18 +00:00
Jake Burkholder
140bf733a7 Fix a bug in the kernel entry window handling where the wrong register
was used.  This resulted in bogus bad window traps (invalid wstate).

Add a trace to sfsr traps (alignment among other things).

Use KTR_TRAP instead of KTR_CT1.

Use the right registers when storing the values of various
mmu registers into the trap frame.  This fixes a bug where sometimes
the context number reported by a fault would be garbage.  Sometimes
it would be zero for faults on user address space so the kernel would
wrongly think that it was a fault on kernel address space and fail.

Use the preloaded registers in the vectored interrupt trap instead
of reading pointers from memory.  Remove traces due to register
pressure and excess verbosity.  We can probably still sneak in one
trace.  Remove some debug code.

Go back to using the tsb register during kernel page table lookups.
This is the best way to not have to have the address of the kernel tsb be
a compile time constant.  We lie and say we have 1 page tsb when really
its much larger.  This way the hardware provides bits 13-22 of the
virtual address (the lower 9 bits of the virtual page number) in the
form of the address of the tte corresponding to the fault address in
the (1 page) kernel tsb.  With some clever arithmetic we can then get
bits 22 and up from the tte tag and add them to the tte address in
order to index massive tsbs (basically unlimited).

Add traps for physical address hardware watchpoints.

Don't try to pass the window state from the trap table entry point
all the way down to the common trap code.  Its too easy to clobber
and reading it again doesn't cost much.

Fixup some traces.

Fiddle the cwp bits on return from the kernel to user mode so that
the window we are returning to is always the same as the one we
restore to in the trap code.  Strictly speaking this is not necessary,
it only affects return from fork and exec, but setting up the windows
right would require hard coding the right cwp values in cpu_fork and
setregs, basically hard coding the number of frames between syscall and
tl0_ret.  The result of getting it wrong is usually a spill to an invalid
stack pointer; either 0 or pointing into kernel space.  This should also
alleviate the need to context switch the cwp.

Transfer the trap state from locals to alternate globals in the trap
return code so that we can do a restore and rotate the windows before
reloading the trap registers.  If the restore fails we'll trap back
into the kernel, so there's no point in loading the trap registers
before hand.  Its is crucial that the window trap recovery code not
clobber the alternate globals.
2001-10-20 17:06:04 +00:00
Jake Burkholder
2baa1ef450 Align the symbol that demarks the end of the signal code on a 16 byte
boundary.  It must be on at least an 8 byte boundary so that the length
of the signal code is a multiple of 8 (well aligned).  The size is used
in the calculation of the address of the argument and environment vectors
on the user stack; getting it wrong results in the string pointers being
misaligned and causes alignment faults in getenv() among other things.

Allocate a regular stack frame below the signal frame on the user stack
and join up the frame pointer to the previous frame.  This fixes longjmp-ing
out of signal handlers.  Longjmp traverses the stack upwards in order to
find the right frame to return to, so the frame pointers must join up
seamlessly.  I thought this would just work, but obviously the frame
needs to be below the signal frame, not above it like before.  Account
for the extra space in the signal code.

Preload pointers to interrupt data structures in interrupt globals.
This avoids the need to load the pointers from memory in the vectored
interrupt trap handler.

Transfer the first 2 out registers into td_retval in setregs.  We use
the same registers for system call arguments as return values, so these
registers got clobbered by the system call return values on return from
execve.  They now get clobbered by the right values.  We must put the values
in both the out registers in the trapframe and in td_retval because init
calls exec but fails to transfer the return value into the out registers.
This fixes a bug where the first exec after init would pass junk to the
c runtime, instead of a pointer to the argument strings.  A better solution
would be to return EJUSTRETURN on success from execve.

Adjust for change in pmap_bootstraps prototype.

Map the message buffer after the trap table is setup.  We will fault
on it immediately.
2001-10-20 16:36:08 +00:00
Jake Burkholder
6ef2d9a02d Parameterize the size of the kernel virtual address space on KVA_PAGES.
Don't use a hard coded address constant for the virtual address of the
kernel tsb.  Allocate kernel virtual address space for the kernel tsb
at runtime.
Remove unused parameter to pmap_bootstrap.
Adapt pmap.c to use KVA_PAGES.
Map the message buffer too.
Add some traces.
Implement pmap_protect.
2001-10-20 16:17:04 +00:00
Jake Burkholder
d37e05e1c4 Remove hardcoded cwp value. 2001-10-20 16:10:13 +00:00
Jake Burkholder
4daaec8bec Use KTR_PROC instead of KTR_CT1 in traces. 2001-10-20 16:09:50 +00:00
Jake Burkholder
7e16bdb39b Return zero on success from su*. Apparently no one checks the return
values.
Add traces to fubyte, subyte, etc.  These are useful for catching errors.
due to alignment since its usually not checked for by the caller.
2001-10-20 16:09:20 +00:00
Jake Burkholder
209cf80d43 Add support for physical address hardware watchpoints. 2001-10-20 16:04:39 +00:00
Jake Burkholder
6c3dcb9735 Change the stray count in struct intr_vector to a vector number that can
be used to index tables of counters.
Remove intr_dispatch() inline, it is implemented directly in tl*_intr now.
Count stray interrupts in a table of counters like intrcnt.
Disable interrupts briefly when setting up the interrupt vector table.
We must disable interrupts completely, not just raise the pil.
Pass pointers to the intr_vector structures rather than a vector number
to sched_ithd and intr_stray.
2001-10-20 16:03:41 +00:00
Jake Burkholder
44217f38a5 Remove traces that are loud and not that useful. Remove nested include
of ktr.h.
2001-10-20 15:58:31 +00:00
Jake Burkholder
c93b7ccb41 Remove an unused macro arg. 2001-10-20 15:57:39 +00:00
Jake Burkholder
4fd2757c37 Include a whole interrupt queue in struct globaldata instead of just a
pointer.  Minor style.
2001-10-20 15:57:09 +00:00
Jake Burkholder
3d6e05660a Add fields for boothowto and the kernel environment to boothowto. 2001-10-20 15:55:42 +00:00
David E. O'Brien
9f9bd82e15 Try two on the preprocessing logic.
Reviewed by:	ru
2001-10-19 20:01:01 +00:00
David E. O'Brien
4b16cf4f8a Blah, fix braino where ru had to remind me of proper preprocessor syntax.
Bad fingers, no cookie.
2001-10-19 19:17:11 +00:00
David E. O'Brien
e3ddd70789 My attempts at minimizing the number of #def's got me in trouble. 2001-10-18 16:07:21 +00:00
David E. O'Brien
4a3391b5a1 Add support for "__gnuc_va_list". Some overly "smart" libraries assume
the existence of the __gnuc_va_list type[*] because our compiler is GCC.

[*] __gnuc_va_list is defined in the GCC ginclude/stdarg.h replacement
headerwhich we don't use.
2001-10-18 00:27:39 +00:00
Thomas Moestl
84bcb99195 Add inthand_add() and inthand_remove() for use by the MD bus code and
some glue code.
2001-10-12 16:06:41 +00:00
Thomas Moestl
ccece9b5ff Fix some warnings. 2001-10-12 16:00:30 +00:00
Thomas Moestl
b6aaa482ef Save the floating point context to the right pcb in cpu_fork(), and add
an empty stub for is_physical_memory().
2001-10-12 15:58:48 +00:00
Thomas Moestl
c2f5c600c1 Make the NTOHL, NTOHS, HTONL and HTONS macros (which are nops on
sparc64) empty to avoid compiler warnings.
2001-10-12 15:55:45 +00:00
Thomas Moestl
5f19cf9309 Implement DELAY() using the %tick register. 2001-10-12 15:51:19 +00:00
Thomas Moestl
4bc38523ec Add pmap_kenter_flags(), which is used by MD bus code that will be
committed soon, add a stub form pmap_kenter_temporary(), and implement
pmap_extract() and pmap_kextract().
2001-10-12 15:49:51 +00:00
Paul Saab
cbc89bfbfe Make MAXTSIZ, DFLDSIZ, MAXDSIZ, DFLSSIZ, MAXSSIZ, SGROWSIZ loader
tunable.

Reviewed by:	peter
MFC after:	2 weeks
2001-10-10 23:06:54 +00:00
Dag-Erling Smørgrav
3da3249106 Dissociate ptrace from procfs.
Until now, the ptrace syscall was implemented as a wrapper that called
various functions in procfs depending on which ptrace operation was
requested.  Most of these functions were themselves wrappers around
procfs_{read,write}_{,db,fp}regs(), with only some extra error checks,
which weren't necessary in the ptrace case anyway.

This commit moves procfs_rwmem() from procfs_mem.c into sys_process.c
(renaming it to proc_rwmem() in the process), and implements ptrace()
directly in terms of procfs_{read,write}_{,db,fp}regs() instead of
having it fake up a struct uio and then call procfs_do{,db,fp}regs().

It also moves the prototypes for procfs_{read,write}_{,db,fp}regs()
and proc_rwmem() from proc.h to ptrace.h, and marks all procfs files
except procfs_machdep.c as "optional procfs" instead of "standard".
2001-10-07 20:08:42 +00:00
Jake Burkholder
fc67f24833 Add contents to struct *reg. 2001-09-30 19:59:07 +00:00
Jake Burkholder
fa753b0bcb Optimize bcopy and bzero etc to use 64 bit loads and stores if possible.
Handle overlap in bcopy.
Add routines for copying and zeroing pages using physical addresses
directly.
Remove all the hacks to account for calling the firmware on its own
trap table, we use the kernel trap table.  There is still a problem
with OF_exit().
2001-09-30 19:50:39 +00:00
Jake Burkholder
c4bc2cc714 Use %ver to identify the cpu instead of openfirmware.
Submitted by:	robert
2001-09-30 19:45:34 +00:00
Jake Burkholder
92767809a8 Remove some debug code, add traces. 2001-09-30 19:44:19 +00:00
Jake Burkholder
6b75800a1e Return EIO for procfs_*_dbregs. 2001-09-30 19:43:18 +00:00
Jake Burkholder
b34f88ee74 Add a place holder for PSTATE_SECURE, which detects if user code it
trying to set bad pstate bits.
2001-09-30 19:42:34 +00:00
Jake Burkholder
e5e8823f37 Split the low level trap code into trap, interrupt and syscall, its
easier and hopefully this code is done changing radically.

Don't use the mmu tlb register to address the kernel page table, nor
the 8k pointer register.  The hardware will do some of the page table
lookup by storing the the base address in an internal register and
calculating the address of the tte in the table.  However it is limited
to a 1 meg tsb, which only maps 512 megs.  The kernel page table only
has one level, so its easy to just do it by hand, which has the advantage
of supporting abitrary amounts of kvm and only costs a few more instructions.

Increase kvm to 1 gig now that its easy to do so and so we don't waste
most of a 4 meg page.

Fix some traces.  Fix more proc locking.

Call tsb_stte_promote if we get a soft fault on a mapping in the upper
levels of the tsb.  If there is an invalid or unreferenced mapping
in the primary tsb, it will be replaced.

Immediately fail for faults occuring in {f,s}uswintr.
2001-09-30 19:41:20 +00:00
Jake Burkholder
15b39a57a5 Implement sysarch(). 2001-09-30 19:06:45 +00:00
Jake Burkholder
c92d1bd289 Fix some traces. td->p_comm doesn't exist. 2001-09-30 19:05:30 +00:00
Jake Burkholder
956856ae06 Move the kernel to end of the first 4 gigabytes of address space, so that
one 4 meg page can map both the kernel and the openfirmware mappings.
Add the openfirmware mappings to the kernel tsb so we can call the firmware
on the kernel trap table and access kernel memory normally.
Implement pmap_swapout_proc, pmap_swapin_proc, pmap_swapout_thread,
pmap_swapin_thread, pmap_activate, pmap_page_exists, and pmap_phys_address.
2001-09-30 19:03:22 +00:00
Jake Burkholder
954f0d930e Add a macro to get the context from a tte tag, not necesarily a whole
tte.  Remove the old inline.
2001-09-30 18:55:05 +00:00