Commit Graph

39180 Commits

Author SHA1 Message Date
Robert Watson
e965edfda2 Add MAC_ALWAYS_LABEL_MBUF to options; this permits the administrator
to force the allocation of MAC labels for all mbufs regardless of
whether a configured policy requires labeling when the mbuf is
allocated.  This can be useful it you anticipate loading a fully
labeled policy after boot and don't want mbufs to exist without
label storage, for performance measurement purposes, etc.  It also
slightly lowers the overhead of m_tag labeling due to removing the
decision logic.

While here, improve commenting of other MAC options.

Obtained from:	TrustedBSD Project
Sponsored by:	DARPA, Network Associates Laboratories
2003-04-14 21:45:12 +00:00
Robert Watson
225bff6f8b Move MAC label storage for mbufs into m_tags from the m_pkthdr structure,
returning some additional room in the first mbuf in a chain, and
avoiding feature-specific contents in the mbuf header.  To do this:

- Modify mbuf_to_label() to extract the tag, returning NULL if not
  found.

- Introduce mac_init_mbuf_tag() which does most of the work
  mac_init_mbuf() used to do, except on an m_tag rather than an
  mbuf.

- Scale back mac_init_mbuf() to perform m_tag allocation and invoke
  mac_init_mbuf_tag().

- Replace mac_destroy_mbuf() with mac_destroy_mbuf_tag(), since
  m_tag's are now GC'd deep in the m_tag/mbuf code rather than
  at a higher level when mbufs are directly free()'d.

- Add mac_copy_mbuf_tag() to support m_copy_pkthdr() and related
  notions.

- Generally change all references to mbuf labels so that they use
  mbuf_to_label() rather than &mbuf->m_pkthdr.label.  This
  required no changes in the MAC policies (yay!).

- Tweak mbuf release routines to not call mac_destroy_mbuf(),
  tag destruction takes care of it for us now.

- Remove MAC magic from m_copy_pkthdr() and m_move_pkthdr() --
  the existing m_tag support does all this for us.  Note that
  we can no longer just zero the m_tag list on the target mbuf,
  rather, we have to delete the chain because m_tag's will
  already be hung off freshly allocated mbuf's.

- Tweak m_tag copying routines so that if we're copying a MAC
  m_tag, we don't do a binary copy, rather, we initialize the
  new storage and do a deep copy of the label.

- Remove use of MAC_FLAG_INITIALIZED in a few bizarre places
  having to do with mbuf header copies previously.

- When an mbuf is copied in ip_input(), we no longer need to
  explicitly copy the label because it will get handled by the
  m_tag code now.

- No longer any weird handling of MAC labels in if_loop.c during
  header copies.

- Add MPC_LOADTIME_FLAG_LABELMBUFS flag to Biba, MLS, mac_test.
  In mac_test, handle the label==NULL case, since it can be
  dynamically loaded.

In order to improve performance with this change, introduce the notion
of "lazy MAC label allocation" -- only allocate m_tag storage for MAC
labels if we're running with a policy that uses MAC labels on mbufs.
Policies declare this intent by setting the MPC_LOADTIME_FLAG_LABELMBUFS
flag in their load-time flags field during declaration.  Note: this
opens up the possibility of post-boot policy modules getting back NULL
slot entries even though they have policy invariants of non-NULL slot
entries, as the policy might have been loaded after the mbuf was
allocated, leaving the mbuf without label storage.  Policies that cannot
handle this case must be declared as NOTLATE, or must be modified.

- mac_labelmbufs holds the current cumulative status as to whether
  any policies require mbuf labeling or not.  This is updated whenever
  the active policy set changes by the function mac_policy_updateflags().
  The function iterates the list and checks whether any have the
  flag set.  Write access to this variable is protected by the policy
  list; read access is currently not protected for performance reasons.
  This might change if it causes problems.

- Add MAC_POLICY_LIST_ASSERT_EXCLUSIVE() to permit the flags update
  function to assert appropriate locks.

- This makes allocation in mac_init_mbuf() conditional on the flag.

Reviewed by:	sam
Obtained from:	TrustedBSD Project
Sponsored by:	DARPA, Network Associates Laboratories
2003-04-14 20:39:06 +00:00
Robert Watson
10eeb10c63 Abstract access to the mbuf header label behind a new function,
mbuf_to_label().  This permits the vast majority of entry point code
to be unaware that labels are stored in m->m_pkthdr.label, such that
we can experiment storage of labels elsewhere (such as in m_tags).

Reviewed by:	sam
Obtained from:	TrustedBSD Project
Sponsored by:	DARPA, Network Associates Laboratories
2003-04-14 18:11:18 +00:00
Robert Watson
aa65d9f538 Use MBTOM() to convert mbuf allocator flags to malloc() flags, rather
than using the same compare/substitute in many places.

Obtained from:	TrustedBSD Project
Sponsored by:	DARPA, Network Associates Laboratories
2003-04-14 16:04:10 +00:00
Maxim Sobolev
cf0d8a1e48 Use pci_enable_{busmaster|io}() instead of directly writing into
PCI configuration register.

Submitted by:	mdodd
2003-04-14 15:50:04 +00:00
Olivier Houchard
695d74f337 Use while (*controlp != NULL) instead of do ... while (*control != NULL)
There are valid cases where *controlp will be NULL at this point.

Discussed with:	dwmalone
2003-04-14 14:44:36 +00:00
Bernd Walter
65193b3e5d Use a sim for each device on it's own instead of one for all umass
devices.
This reduces complexity and fixes a number of small problems.

Approved by:	gallatin (mentor)
Reviewed by:	njl
2003-04-14 14:28:17 +00:00
Hidetoshi Shimokawa
050871cc4f Panic if bus_dmamap_load() doesn't respect maxsegsz. 2003-04-14 14:17:49 +00:00
Bernd Walter
ca3acad1d7 add EHCI (USB 2.0) controller support.
Approved by:	joe
		gallatin (mentor)
Obtained from:  NetBSD
2003-04-14 14:04:08 +00:00
Hidetoshi Shimokawa
c8990f0d8e Restore delayed load support for the resource shortage case.
It was missed in the previous change.
Now, _bus_dmamap_load_buffer() accepts BUS_DMA_WAITOK/BUS_DMA_NOWAIT flags.

Original idea from: jake
2003-04-14 13:21:40 +00:00
Maxim Sobolev
bb342a3713 Before attaching device set PCIM_CMD_PORTEN in addition to
PCIM_CMD_MEMEN and PCIM_CMD_BUSMASTEREN, becaise some braindead
BIOSes (such as one found in my vprmatrix notebook) forget
to initialize it properly resulting in attachment failure.
2003-04-14 09:45:25 +00:00
Poul-Henning Kamp
7715475960 More correct patch: Only call biofinish if we have not already sent
any children down the mesh.
2003-04-14 08:49:54 +00:00
Poul-Henning Kamp
2f912fc976 Call biofinish() also when we get a malloc() failure. 2003-04-14 08:08:17 +00:00
Hidetoshi Shimokawa
f5270431be * Use _bus_dmamap_load_buffer() and respect maxsegsz in bus_dmamap_load().
Ignoring maxsegsz may lead to fatal data corruption for some devices.
ex. SBP-2/FireWire
We should apply this change to other platforms except for sparc64.

MFC after: 1 week
2003-04-14 04:19:42 +00:00
Alan Cox
de5ef10142 Update locking on the kernel_object to use the new macros. 2003-04-14 00:36:53 +00:00
Alan Cox
d1dc776d9d Lock some manipulations of the vm object's flags. 2003-04-13 23:43:34 +00:00
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
Poul-Henning Kamp
073834e69b Add definitions for location of the magic sequence and the length
of a partition entry.
2003-04-13 21:52:22 +00:00
Jake Burkholder
2373499592 Made vmspace0 non-static. Its useful to be able to identify a vmspace as
the kernel vmspace.
2003-04-13 21:29:11 +00:00
Alan Cox
e2479b4fc3 Lock some manipulations of the vm object's flags. 2003-04-13 20:22:02 +00:00
Alan Cox
b077a36297 Lock some manipulations of the vm object's flags. 2003-04-13 19:36:18 +00:00
Alan Cox
fdff41609d Add new macros for locking and unlocking a vm object. 2003-04-13 18:39:47 +00:00
Poul-Henning Kamp
7c1d57b6e8 Since dynamic allocation of device major numbers so far have not
resulted in any earthquakes, civil wars or early onset hair-loss,
I think we can do without the printf announcing the assigned number.
2003-04-13 15:27:49 +00:00
Poul-Henning Kamp
3924ad705e Time has run from the "run GEOM in userland" harness, and the new regression
test is built to test GEOM as running in the kernel.

This commit is basically "unifdef -D_KERNEL" to remove the mainly #include
related code to support the userland-harness.
2003-04-13 09:02:06 +00:00
Max Khon
7d0de413cb Driver for Granch SBNI16 SHDSL modem
Submitted by:	Denis I. Timofeev <timofeev@granch.ru>
MFC after:	1 week
2003-04-13 06:27:13 +00:00
Jeffrey Hsu
983985c11e No need to unlock if error detected before locking.
Submitted by:	harti
2003-04-13 06:21:02 +00:00
Alan Cox
e96c181d16 Use vm_object_pip_wait() rather than reimplementing it. 2003-04-13 05:10:44 +00:00
Yoshihiro Takahashi
ba32bfe24e The dpt, ex and idt modules are for i386 only. 2003-04-13 01:32:03 +00:00
Alan Cox
f279b88deb Permit vm_object_pip_add() and vm_object_pip_wakeup() on the kmem_object
without Giant held.
2003-04-13 00:43:48 +00:00
Alan Cox
f31c239da1 Eliminate unnecessary gotos from kmem_malloc(). 2003-04-13 00:23:42 +00:00
Jeff Roberson
a5f099d0c4 - Unbreak priority prop. for timeshare threads. Always place something on
the current queue if its priority is really elevated.  This needs more work
   as there are cases where a next queue kse could be holding up what would
   be a curr queue kse, and thus hurting interactivity.  Also, when a thread
   with an elevated priority has its priority lowered it should be placed
   back on the next queue.
2003-04-12 22:33:24 +00:00
Poul-Henning Kamp
537d9274dc If we hit access ahead of a spoil event, we should have negative
delta access-counts and proceed.
2003-04-12 17:04:34 +00:00
Poul-Henning Kamp
2b454c0ae5 Fix a bug which resulted in orphanization getting confused every now
and then.
2003-04-12 16:36:19 +00:00
Poul-Henning Kamp
ad3648813c protoypes for the dos_partition encoding functions. 2003-04-12 10:07:12 +00:00
Dag-Erling Smørgrav
ed9adee74c Options that go into homonymous headers shouldn't specify the header name.
Submitted by:	Hiten Pandya <hiten@unixdaemons.com>
2003-04-12 09:40:37 +00:00
Poul-Henning Kamp
5f5a9022b2 Retire the experimental bio_taskqueue(), it was not quite as usable as
hoped.  It can be revived from here, should other drivers be able to
use it.
2003-04-12 09:13:01 +00:00
Poul-Henning Kamp
2b69c2d76a Remove the unused ioctl routine. 2003-04-12 08:44:54 +00:00
Poul-Henning Kamp
0d3e96e39c Retire the "frontstuff" record keeping, it was no match for the
in-band meta-data of BSD labels and a more complex solution will be needed.
2003-04-12 08:41:26 +00:00
Poul-Henning Kamp
6e03422af0 Move the functions for encoding decoding struct dos_partition into
a separate .c file so they can be used from userland as well.
2003-04-12 08:34:40 +00:00
Jeff Roberson
9bca28a703 - Clean up some debug code left over from my earlier megacommit. 2003-04-12 07:28:36 +00:00
Jeff Roberson
b5c4c4a7e5 - We only care about the base priority. Ignore the SCHED_FIFO_BIT so that
we dont get confused.

Reported and debugged by:	Steve Kargl <sgk@troutmask.apl.washington.edu>
2003-04-12 07:00:16 +00:00
Hidetoshi Shimokawa
8b8d5d06d1 fix typo in the previous commit. 2003-04-12 06:43:28 +00:00
Mike Silbersack
53dcc544a8 Rename MBUF_FRAG_TEST to MBUF_STRESS_TEST as it will be extended
to include more than just frag tests.
2003-04-12 06:11:46 +00:00
David Xu
f9b89f7e3e Style fix. 2003-04-12 02:54:46 +00:00
Kelly Yancey
f563420e8d Fix race between a process registering a NOTE_EXIT EVFILT_PROC event and
the target process exiting which causes attempts to register the kevent
to randomly fail depending on whether the target runs to completion before
the parent can call kevent(2).  The bug actually effects EVFILT_PROC
events on any zombie process, but the most common manifestation is with
parents trying to monitor child processes.

MFC after:	2 weeks
Sponsored by:	NTT Multimedia Communications Labs
2003-04-12 01:57:04 +00:00
Jeff Roberson
86711bae9b - Use the sched_nice() api instead of setting the nice value directly.
Tested by:	Steve Kargl <sgk@troutmask.apl.washington.edu>
2003-04-12 01:05:19 +00:00
David Xu
5312b1c7fa Check SIG_HOLD action ealier to avoid missing test it in later code. 2003-04-12 00:38:47 +00:00
Jeff Roberson
a22ec9d8f2 - Call sched_exit_{kse,thread} and sched_fork{kse,thread} so that thr works
with ULE.  This was not strictly required by sched_4bsd.
2003-04-11 19:24:37 +00:00
Jeff Roberson
141ad61c78 - Add sched_exit_*
- Call sched_exit_kse() from sched_exit() instead of implementing it here.
2003-04-11 19:24:00 +00:00
Jeff Roberson
58177de2de - Only select kseqs with more than one kse to steal. The running kse
is reflected in the load now and you can't very well migrate that.
2003-04-11 18:40:34 +00:00