Commit graph

833 commits

Author SHA1 Message Date
Jake Burkholder 50e24eb628 - Move the routine for flushing all user mappings from the tlb from pmap to
the cpu dependent files.  It will need to be done differently for USIII.
- Simplify the logic for detecting context rollovers.  Instead of dealing
  with it when the next context switch would cause the context numbers to
  rollover, deal with it when they actually do rollover.
- Move some things around in cpu_switch so that we only do 1 membar #Sync
  when switching address space, instead of 2.
- Detect kernel threads by comparing the new vm space to vmspace0, instead
  if checking if the tlb context is 0.
- Removed some debug code.
2003-04-13 21:54:58 +00:00
Hidetoshi Shimokawa 8b8d5d06d1 fix typo in the previous commit. 2003-04-12 06:43:28 +00:00
Maxime Henrion 7a648f56cf I deserve a big pointy hat for having missed all those references
to bus_dmasync_op_t in my last commit.
2003-04-10 23:50:06 +00:00
Maxime Henrion 141bacb048 Change the operation parameter of bus_dmamap_sync() from an
enum to an int and redefine the BUS_DMASYNC_* constants as
flags.  This allows us to specify several operations in one
call to bus_dmamap_sync() as in NetBSD.
2003-04-10 23:03:33 +00:00
Jake Burkholder fff890d0e8 Print real memory/avail memory on startup like other platforms. Hide
printing the model under bootverbose.
2003-04-10 17:18:52 +00:00
Maxime Henrion 06283c3ba9 The fxp(4) driver is now working on sparc64 too!
Tested by:	jake
2003-04-08 20:55:30 +00:00
Dag-Erling Smørgrav fe58453891 Introduce an M_ASSERTPKTHDR() macro which performs the very common task
of asserting that an mbuf has a packet header.  Use it instead of hand-
rolled versions wherever applicable.

Submitted by:	Hiten Pandya <hiten@unixdaemons.com>
2003-04-08 14:25:47 +00:00
Jake Burkholder 58d7ebfa7c Use vm_paddr_t for physical addresses. 2003-04-08 06:35:09 +00:00
Jake Burkholder b5250c9f8d Remove a largely useless statistic (its kept elsewhere too). 2003-04-06 18:18:17 +00:00
Jake Burkholder c81c0cf196 Make the pmap stats writeable. It can be useful to clear them. 2003-04-06 18:17:31 +00:00
Jake Burkholder 92fed30a07 Use the vis block copy/zero functions for pmap_copy_page and pmap_zero_page.
These are called through function pointers so that different implementations
can be provided for cheetah, where the block load instructions may or may
not be a win, and so they can be disabled with the machdep.use_vis tunable.
In terms of raw bandwidth the integer versions are faster, but not allocating
lines in the L2 cache for useless data gives a measurable improvement in user
time for the benchmarks I tested (mostly buildworld with -j8).

As far as I can tell the instructions used are implemented on everything
back to UltraSPARC I, so there should not be a problem with different cpu
types.
2003-04-06 17:05:26 +00:00
Jake Burkholder 3e9a6ab3a1 Ignore attempts to pmap_kremove or pmap_qremove pages which do not have
a valid mapping.  This is bug for bug compatible with other platforms.
2003-04-06 15:14:24 +00:00
Dag-Erling Smørgrav 9f45b2da8f Define ovbcopy() as a macro which expands to the equivalent bcopy() call,
to take care of the KAME IPv6 code which needs ovbcopy() because NetBSD's
bcopy() doesn't handle overlap like ours.

Remove all implementations of ovbcopy().

Previously, bzero was a function pointer on i386, to save a jmp to
bzero_vector.  Get rid of this microoptimization as it only confuses
things, adds machine-dependent code to an MD header, and doesn't really
save all that much.

This commit does not add my pagezero() / pagecopy() code.
2003-04-04 17:29:55 +00:00
Jake Burkholder 6412c65cf0 Add optimized block copy and zero functions using vis instructions, which
can do 64 bytes at a time and don't allocate lines in the L2 cache.  These
assume that everything is 64 byte aligned, and that there's more than 128
bytes of data (best for whole pages).  The block load and store instructions
don't follow normal memory ordering rules and require either a memory barrier
or move between registers before the data can actually be used.  This
implementation correctly shuffles around 3 out of the 4 sets of registers
in order to avoid memory barriers expect for the last 2 blocks.
2003-04-03 18:43:40 +00:00
Jake Burkholder 937e05327e Add support for saving and restoring kernel floating point state. The state
will be saved if we context switch as a result of an interrupt which occured
while using the floating point registers in the kernel (which actually can't
happen right now).  This allows fp disabled traps in the kernel, which
normally shouldn't happen, so make sure the trapping code is what we expect
it is.
2003-04-03 18:34:05 +00:00
Jake Burkholder 7dafcb6914 - Add space for kernel floating point registers to the pcb. These will be
used to support block copy and zero operations in the kernel which use the
  floating point registers.
- While I'm changing the size, improve the layout of struct pcb, sort by size,
  then alphabetical etc.
- Add some assertions to validate assumptions made about how the pcb is
  allocated.
2003-04-03 18:28:03 +00:00
Jake Burkholder 8e4f1e2b8a - Generally improve register usage in cpu_switch. Use the 'in' registers
for temporaries relating to the state of the new process instead of the
  outs, so that functions can be called without fear of clobbering them.
- Use savefpctx instead of rolling our own.
2003-04-03 16:36:01 +00:00
Jake Burkholder 02798ad7e0 Don't assume the fp state is at offset 0 in the pcb. 2003-04-03 16:04:18 +00:00
Jake Burkholder 1db34e9d43 Fix typos (don't use * when taking the size of an array). 2003-04-03 15:50:17 +00:00
Peter Wemm cc66ebe2a9 Commit a partial lazy thread switch mechanism for i386. it isn't as lazy
as it could be and can do with some more cleanup.  Currently its under
options LAZY_SWITCH.  What this does is avoid %cr3 reloads for short
context switches that do not involve another user process.  ie: we can
take an interrupt, switch to a kthread and return to the user without
explicitly flushing the tlb.  However, this isn't as exciting as it could
be, the interrupt overhead is still high and too much blocks on Giant
still.  There are some debug sysctls, for stats and for an on/off switch.

The main problem with doing this has been "what if the process that you're
running on exits while we're borrowing its address space?" - in this case
we use an IPI to give it a kick when we're about to reclaim the pmap.

Its not compiled in unless you add the LAZY_SWITCH option.  I want to fix a
few more things and get some more feedback before turning it on by default.

This is NOT a replacement for Bosko's lazy interrupt stuff.  This was more
meant for the kthread case, while his was for interrupts.  Mine helps a
little for interrupts, but his helps a lot more.

The stats are enabled with options SWTCH_OPTIM_STATS - this has been a
pseudo-option for years, I just added a bunch of stuff to it.

One non-trivial change was to select a new thread before calling
cpu_switch() in the first place.  This allows us to catch the silly
case of doing a cpu_switch() to the current process.  This happens
uncomfortably often.  This simplifies a bit of the asm code in cpu_switch
(no longer have to call choosethread() in the middle).  This has been
implemented on i386 and (thanks to jake) sparc64.  The others will come
soon.  This is actually seperate to the lazy switch stuff.

Glanced at by:  jake, jhb
2003-04-02 23:53:30 +00:00
Jake Burkholder c2b117e7db Implement cpu_thread_setup. Fix cpu_set_upcall. 2003-04-02 08:03:42 +00:00
Jake Burkholder 6e1e13b5e0 - Set the version number in the mcontext in get_mcontext and check it in
set_mcontext.
- Don't make assumptions about the alignment of the mcontext inside of the
  ucontext; we have to save the floating point registers to the pcb and then
  copy to the mcontext.
2003-04-01 23:18:13 +00:00
Jake Burkholder 73adf5691f - Add a flags field to struct pcb. Use this to keep track of wether or
not the pcb has floating point registers saved in it.
- Implement get_mcontext and set_mcontext.
2003-04-01 04:58:50 +00:00
Jake Burkholder 404221fe55 - Don't allow tf_wstate to be set in set_regs.
- Clear FPRS_FEF in set_fpregs so the new registers will be reloaded.
2003-04-01 04:29:03 +00:00
Jake Burkholder 8fe20fdafa Implement cpu_set_upcall. 2003-04-01 04:19:29 +00:00
Jake Burkholder f217a77ce4 - Rename pcb_fpstate to pcb_ufp (user floating point), and change it to
a simple array of 64 ints.
- Use a critical section when saving floating point state in cpu_fork
  instead of sched_lock.
2003-04-01 04:02:45 +00:00
Jake Burkholder e50173aeaa Rename pcb_fp to pcb_sp, so as to not be confused with floating point
state.
2003-04-01 03:05:46 +00:00
Jake Burkholder a31794d553 Implement casuptr. 2003-04-01 02:37:04 +00:00
Jeff Roberson b8db34d280 - Define a new md function 'casuptr'. This atomically compares and sets
a pointer that is in user space.  It will be used as the basic primitive
   for a kernel supported user space lock implementation.
 - Implement this function in x86's support.s
 - Provide stubs that return -1 in all other architectures.  Implementations
   will follow along shortly.

Reviewed by:	jake
2003-04-01 00:18:55 +00:00
Jeff Roberson 4093529dee - Move p->p_sigmask to td->td_sigmask. Signal masks will be per thread with
a follow on commit to kern_sig.c
 - signotify() now operates on a thread since unmasked pending signals are
   stored in the thread.
 - PS_NEEDSIGCHK moves to TDF_NEEDSIGCHK.
2003-03-31 22:49:17 +00:00
Jeff Roberson 1bf4700bff - Change trapsignal() to accept a thread and not a proc.
- Change all consumers to pass in a thread.

Right now this does not cause any functional changes but it will be important
later when signals can be delivered to specific threads.
2003-03-31 22:02:38 +00:00
Jake Burkholder c82feacd9b - Allow the physical memory size that will be actually used by the kernel to
be overridden by setting hw.physmem.
- Fix a vm_map_find arg, we don't want to find space.
- Add tracing and statistics for off colored pages.
- Detect "stupid" pmap_kenters (same virtual and physical as existing
  mapping), and do nothing in that case.
2003-03-31 19:56:55 +00:00
Jake Burkholder 0f0dfee4d5 Handle the fictitious pages created by the device pager. For fictitious
pages which represent actual physical memory we must strip off the fake
page in order to allow illegal aliases to be detected.  Otherwise we map
uncacheable in the virtual and physical caches and set the side effect bit,
as is required for mapping device memory.

This fixes gstat on sparc64, which wants to mmap kernel memory through a
character device.
2003-03-27 02:16:31 +00:00
Jake Burkholder 868aaa93bc Set the cache line size for subordinate pci bridges as well as for their
child devices.  This fixes dma timeouts for devices behind the bridge.

Reported by:	simokawa
Tested by:	simokawa
2003-03-27 02:01:59 +00:00
Jake Burkholder 227f9a1c58 - Add vm_paddr_t, a physical address type. This is required for systems
where physical addresses larger than virtual addresses, such as i386s
  with PAE.
- Use this to represent physical addresses in the MI vm system and in the
  i386 pmap code.  This also changes the paddr parameter to d_mmap_t.
- Fix printf formats to handle physical addresses >4G in the i386 memory
  detection code, and due to kvtop returning vm_paddr_t instead of u_long.

Note that this is a name change only; vm_paddr_t is still the same as
vm_offset_t on all currently supported platforms.

Sponsored by:	DARPA, Network Associates Laboratories
Discussed with:	re, phk (cdevsw change)
2003-03-25 00:07:06 +00:00
Ruslan Ermilov ab0f83bd03 Remove bitrot associated with `maxusers'.
Submitted by:	bde
2003-03-22 14:18:23 +00:00
John Baldwin 31566c96f4 Use td->td_ucred instead of td->td_proc->p_ucred. 2003-03-20 21:17:40 +00:00
Maxime Henrion fd1b2ab0c9 Use atomic operations to increment and decrement the refcount
in busdma tags.  There are currently no tags shared accross
different drivers so this isn't needed at the moment, but it
will be required when we'll have a proper newbus method to get
the parent busdma tag.
2003-03-20 19:45:26 +00:00
Jake Burkholder 00aabd830d - Remove unused cache flushing routines. These will not necessary work
on future UltraSPARC cpus for which the data cache is not direct mapped.
- Move UltraSPARC I and II (spitfire, blackbird, sapphire, sabre) specific
  functions to spitfire.c, and add cheetah.c for UltraSPARC III specific
  functions.  Initially just cache flushing, but there are a few other
  functions that will need to move here.
- Add an ipi handler for data cache flushing on UltraSPARC III.
- Use function pointers to select the right cache flushing functions based
  on cpu_impl.

With this it is possible to boot single user from an mfs root on UltraSPARC
III systems, including spinning up secondary processors.  There is currently
no support for the host to pci bridge, and no documentation for it is
publically available.

Thanks to Oleg Derevenetz for providing access to a system with UltraSPARC
III+ cpus.
2003-03-19 06:55:37 +00:00
Jake Burkholder 2b8cd5a6a2 - Set cpu_impl early in sparc64_init so that we can use it to detect
UltraSPARC III and higher cpus and do needed setup.
- Disable the "system tick" interrupt for UltraSPARC III.  This avoids
  an interrupt storm on startup since we're not prepared for these at
  all.  This feature has questionable use anyway.
- Clear tick on startup and then leave it alone.
2003-03-19 05:51:21 +00:00
Jake Burkholder 9ff3487981 Remove a workaround for mysterious junk appearing in the tlb of secondary
cpus.  It turned out to be a bug in the loader.
2003-03-19 05:05:08 +00:00
Jake Burkholder 8c4ea08fc7 Implement db_print_backtrace. This may need to flush out the windows
as well.
2003-03-19 02:58:53 +00:00
Jake Burkholder eb51ffcb6d Remove unused fields. 2003-03-18 08:15:24 +00:00
Jake Burkholder 56a6b03a6d Clean up /dev/mem now that pmap handles illegal aliases properly. Don't
allow access to device memory through /dev/mem, or try to make modifying
kernel text through /dev/mem safe (it is not).
2003-03-17 18:53:02 +00:00
Jake Burkholder b17d5f7dda Ensure that kstack0 has physical colour equal to virtual colour, so that
illegal aliases will not be created in the data cache if its accessed
through another such mapping.
2003-03-17 03:18:56 +00:00
Jake Burkholder 5501d40bb9 Made the prototypes for pmap_kenter and pmap_kremove MD. These functions
are machine dependent because they are not required to update the tlb when
mappings are added or removed, and doing so is machine dependent.
In addition, an implementation may require that pages mapped with pmap_kenter
have a backing vm_page_t, which is not necessarily true of all physical
pages, and so may choose to pass the vm_page_t to pmap_kenter instead of the
physical address in order to make this requirement clear.
2003-03-16 04:16:03 +00:00
Jake Burkholder d647b74e54 Implement is_physical_memory. Accessing memory which doesn't exist causes
traps that are difficult to recover from, so we check against the memory
map returned by the prom.
2003-03-15 23:59:00 +00:00
Jake Burkholder 7b66da6e32 lock.h must be included before mutex.h. 2003-03-14 07:19:29 +00:00
Maxime Henrion 7541142438 Oops, add missing includes. Pass me the pointy hat.
Reported by:	jake
2003-03-14 00:04:37 +00:00
Maxime Henrion c0796d1cb4 Grab Giant around calls to contigmalloc() and contigfree() so
that drivers converted to be MP safe don't have to deal with it.
2003-03-13 17:18:48 +00:00