Commit Graph

1402 Commits

Author SHA1 Message Date
Marcel Moolenaar
dfeca18773 MFC rev 198341 and 198342:
o   Introduce vm_sync_icache() for making the I-cache coherent with
    the memory or D-cache, depending on the semantics of the platform.
    vm_sync_icache() is basically a wrapper around pmap_sync_icache(),
    that translates the vm_map_t argumument to pmap_t.
o   Introduce pmap_sync_icache() to all PMAP implementation. For powerpc
    it replaces the pmap_page_executable() function, added to solve
    the I-cache problem in uiomove_fromphys().
o   In proc_rwmem() call vm_sync_icache() when writing to a page that
    has execute permissions. This assures that when breakpoints are
    written, the I-cache will be coherent and the process will actually
    hit the breakpoint.
o   This also fixes the Book-E PMAP implementation that was missing
    necessary locking while trying to deal with the I-cache coherency
    in pmap_enter() (read: mmu_booke_enter_locked).
2010-03-31 02:43:58 +00:00
Bjoern A. Zeeb
1a52f90b23 MFC r201813:
In sys/<arch>/conf/Makefile set TARGET to <arch>. That allows
  sys/conf/makeLINT.mk to only do certain things for certain
  architectures.

  Note that neither arm nor mips have the Makefile there, thus
  essentially not (yet) supporting LINT.  This would enable them
  do add special treatment to sys/conf/makeLINT.mk as well chosing
  one of the many configurations as LINT.
2010-03-27 17:14:55 +00:00
Nathan Whitehorn
fca060b9f9 MFC r204297:
Move the OEA64 scratchpage to the end of KVA from the beginning, and set
its PVO to map physical address 0 instead of kernelstart. This fixes a
situation in which a user process could attempt to return this address
via KVM, have it fault while being modified, and then panic the kernel
because (a) it is supposed to map a valid address and (b) it lies in the
no-fault region between VM_MIN_KERNEL_ADDRESS and virtual_avail.

While here, move msgbuf and dpcpu back into regular KVA space for
consistency with other implementations.
2010-03-20 15:27:01 +00:00
Nathan Whitehorn
1f70273a79 MFC r204296:
Provide an implementation of pmap_dev_direct_mapped() on OEA64. This is
required in order to be able to mmap the running kernel, which is turn
required to avoid fstat returning gibberish.
2010-03-20 15:23:06 +00:00
Nathan Whitehorn
59908d2f72 MFC r204269:
Use dcbz instead of word stores for page zeroing, providing a factor of
3-4 speedup.
2010-03-20 15:21:13 +00:00
Nathan Whitehorn
aba7e013d6 MFC r204268:
Close a race involving the OEA64 scratchpage. When the scratch page's
physical address is changed, there is a brief window during which its PTE
is invalid. Since moea64_set_scratchpage_pa() does not and cannot hold
the page table lock, it was possible for another CPU to insert a new PTE
into the scratch page's PTEG slot during this interval, corrupting both
mappings.

Solve this by creating a new flag, LPTE_LOCKED, such that
moea64_pte_insert will avoid claiming locked PTEG slots even if they
are invalid. This change also incorporates some additional paranoia
added to solve things I thought might be this bug.

Reported by:	linimon
2010-03-20 15:19:57 +00:00
Nathan Whitehorn
e868629641 MFC r204128:
Reduce KVA pressure on OEA64 systems running in bridge mode by mapping
UMA segments at their physical addresses instead of into KVA. This emulates
the direct mapping behavior of OEA32 in an ad-hoc way. To make this work
properly required sharing the entire kernel PMAP with Open Firmware, so
ofw_pmap is transformed into a stub on 64-bit CPUs.

Also implement some more tweaks to get more mileage out of our limited
amount of KVA, principally by extending KVA into segment 16 until the
beginning of the first OFW mapping.

Reported by:	linimon
2010-03-20 15:15:54 +00:00
Nathan Whitehorn
6f88556c52 Fix a bug where pages being removed from memory entirely no longer have
PVOs, and so the modified state of the page can no longer be communicated
to the VM layer, causing pages not to be flushed to swap when needed, in
turn causing memory corruption. Also make several correctness adjustments
to I-Cache synchronization and TLB invalidation for 64-bit Book-S CPUs.

Obtained from:	projects/ppc64
Discussed with:	grehan
2010-03-20 15:05:44 +00:00
Nathan Whitehorn
006e2f2ce5 MFC r204903:
Place interrupt handling in a critical section and remove double
counting in incrementing the interrupt nesting level. This fixes a number
of bugs in which the interrupt thread could be preempted by an IPI,
indefinitely delaying acknowledgement of the interrupt to the PIC, causing
interrupt starvation and hangs.

Reported by:	linimon
Reviewed by:	marcel, jhb
2010-03-20 14:55:22 +00:00
Nathan Whitehorn
81484b9174 MFC r204082,204179,204180,204218,204241,204247,204270,204692:
Provide thermal management and monitoring features in smu(4). This allows
fan control and thermal monitoring on SMU-based Apple G5 machines, as well
as an led(4) interface to control the sleep LED.
2010-03-20 14:49:44 +00:00
Nathan Whitehorn
7eb87cc8c7 MFC r204197:
Allow user programs to execute mfpvr instructions. Linux allows this, and
some math-related software like GMP expects to be able to use it to pick
a target appropriately.

Reported by:	Jakob van Santen <vansanten at wisc dot edu>
2010-03-01 00:38:20 +00:00
Rafal Jaworowski
0bd1aed098 MFC r203924:
Call the proper linkup routine in PowerPC Book-E machdep.

Submitted by:	attilio
2010-02-24 20:20:02 +00:00
Matt Jacob
7733cf8fff MFC a number of changes from head for ISP (203478,203463,203444,202418,201758,
201408,201325,200089,198822,197373,197372,197214,196162). Since one of those
changes was a semicolon cleanup from somebody else, this touches a lot more.
2010-02-11 18:34:06 +00:00
Nathan Whitehorn
75a2f19f20 MFC r200018:
Bump limits on PowerPC. This allows large executables like parts of LLVM
to function.

Reviewed by:	grehan
Obtained from:	NetBSD
2010-01-20 16:28:39 +00:00
Warner Losh
7578ff89fc MFC r202019:
Add INCLUDE_CONFIG_FILE in GENERIC on all non-embedded platforms.
  # This is the resolution of removing it from DEFAULTS...
2010-01-18 00:53:21 +00:00
Brooks Davis
9600c47d52 MFC r201443:
Add vlan(4) to all GENERIC kernels.
2010-01-12 06:00:56 +00:00
Warner Losh
1b1bff673f Revert 201158. DEFAULTS isn't for this kind of thing.a 2010-01-04 21:33:10 +00:00
Doug Barton
be0d315238 MFC r200594:
Add INCLUDE_CONFIG_FILE, and a note in comments about how to also
include the comments with CONFIGARGS
2009-12-29 05:35:25 +00:00
Konstantin Belousov
43ba78037b MFC r198507:
Use kern_sigprocmask() instead of direct manipulation of td_sigmask to
reschedule newly blocked signals.

MFC r198590:
Trapsignal() calls kern_sigprocmask() when delivering catched signal
with proc lock held.

MFC r198670:
For trapsignal() and postsig(), kern_sigprocmask() is called with
both process lock and curproc->p_sigacts->ps_mtx locked. Prevent lock
recursion on ps_mtx in reschedule_signals().
2009-12-19 11:31:28 +00:00
Konstantin Belousov
f0087a7a3c MFC r199135:
Extract the code that records syscall results in the frame into MD
function cpu_set_syscall_retval().
2009-12-12 20:06:25 +00:00
Alexander Motin
71e7360ed9 MFC r200171, r200182, r200275, r200295, r200359:
Introduce ATA_CAM kernel option, turning ata(4) controller drivers into
cam(4) interface modules. When enabled, this option deprecates all ata(4)
peripheral drivers (ad, acd, ...) and interfaces and allows cam(4) drivers
(ada, cd, ...) and interfaces to be natively used instead.

As side effect of this, ata(4) mode setting code was completely rewritten
to make controller API more strict and permit above change. While doing
this, SATA revision was separated from PATA mode. It allows DMA-incapable
SATA devices to operate and makes hw.ata.(ata|atapi)_dma tunable work again.

Also allow ata(4) controller drivers (except some specific or broken ones)
to handle larger data transfers. Previous constraint of 64K was artificial
and is not really required by PCI ATA BM specification or hardware.

Submitted by:   nwitehorn (powerpc part)
2009-12-12 10:37:31 +00:00
Nathan Whitehorn
b75ed345f8 MFC r200083:
The first argument of dcbz interprets r0 as a literal zero, not the second.
This worked before by accident.
2009-12-12 02:31:16 +00:00
Nathan Whitehorn
c15901d48b MFC r199949:
Add atp(4) to powerpc GENERIC. Most late-generation Apple PowerPC laptops
have trackpads that do not work at all without this driver.
2009-12-09 21:58:39 +00:00
Nathan Whitehorn
496ef31252 MFC r199886:
Add a CPU features framework on PowerPC and simplify CPU setup a little
more. This provides three new sysctls to user space:
hw.cpu_features - A bitmask of available CPU features
hw.floatingpoint - Whether or not there is hardware FP support
hw.altivec - Whether or not Altivec is available

PR:		powerpc/139154
2009-12-08 05:37:08 +00:00
Nathan Whitehorn
3c2ef79634 MFC r198678:
ake procstat -k work on PowerPC by avoiding mistakenly using signed
compares with a low address (0x1000) and a high address
(the KVA kernel stack).
2009-12-08 05:32:44 +00:00
Nathan Whitehorn
e9962146c6 MFC r198445:
Turn on NAP mode on G5 systems, and refactor the HID0 setup code a little.
This makes my G5 Xserve sound slightly less like it is filled with
howling banshees.

MFC r198968:

Unbreak E500 builds. The inline assembly for the 970 CPUs
is invalid when compiling for BookE.

MFC r199533:

Fix cpuid output on E500 core.
2009-12-08 05:27:06 +00:00
Nathan Whitehorn
3958967343 MFC r198444:
Allow Heathrow-based machines to boot a kernel containing option SMP
without panicing.
2009-12-08 05:23:07 +00:00
Bjoern A. Zeeb
c4de0a57f3 MFC r197729:
Make sure that the primary native brandinfo always gets added
  first and the native ia32 compat as middle (before other things).
  o(ld)brandinfo as well as third party like linux, kfreebsd, etc.
  stays on SI_ORDER_ANY coming last.

  The reason for this is only to make sure that even in case we would
  overflow the MAX_BRANDS sized array, the native FreeBSD brandinfo
  would still be there and the system would be operational.

Reviewed by:	kib
2009-12-05 20:43:15 +00:00
Nathan Whitehorn
1abf14215a MFC r199226:
Provide a real fix to the too-many-translations problem when booting
from CD on 64-bit hardware to replace existing band-aids. This occurred
when the preloaded mdroot required too many mappings for the static
buffer.

Since we only use the translations buffer once, allocate a dynamic
buffer on the stack. This early in the boot process, the call chain
is quite short and we can be assured of having sufficient stack space.
2009-11-28 20:02:45 +00:00
Nathan Whitehorn
0b5ac7b6b9 MFC r198212,198378,198427,198428,198723,198724,198725,198731:
SMP support for PowerPC G5 systems.

r198724:
	Fix a race in casuword() exposed by csup. casuword() non-atomically
read the current value of its argument before atomically replacing it,
which could occasionally return the wrong value on an SMP system. This
resulted in user mutex operations hanging when using threaded applications.

r198723,198725,198731:
	Loop on blocked threads when using ULE scheduler, removing an
XXX MP comment.

r198427:
	Add some more paranoia to setting HID registers, and update the AIM
clock routines to work better with SMP.

r198378:
	Add SMP support on U3-based G5 systems. While here, correct the
64-bit tlbie function to set the CPU to 64-bit mode correctly.

r198212:
	Don't assume that physical addresses are identity mapped. This
allows the second processor on G5 systems to start.
2009-11-28 19:37:58 +00:00
Nathan Whitehorn
b17e03bd8a MFC r198400:
Do not map the trap vectors into the kernel's address space. They are
only used in real mode and keeping them mapped only serves to make NULL
a valid address, which results in silent NULL pointer deferences.

Suggested by:   Patrick Kerharo
Obtained from:  projects/ppc64
2009-11-28 18:36:58 +00:00
Nathan Whitehorn
b478ed7a6b MFC r197961,197962:
Fix two typos that caused DSISR and CR not to be preserved across context
switches.
2009-11-28 18:34:35 +00:00
Ken Smith
50aa951061 Comment out the sbp(4) entry for GENERIC config files that contain it.
There are known issues with this driver that are beyond what can be
fixed for 8.0-RELEASE and the bugs can cause boot failure on some systems.
It's not clear if it impacts all systems and there is interest in getting
the problem fixed so for now just comment it out instead of remove it.

Commit straight to stable/8, this is an 8.0-RELEASE issue.  Head was left
alone so work on it can continue there.

Reviewed by:	Primary misc. architecture maintainers (marcel, marius)
2009-11-09 21:39:42 +00:00
Nathan Whitehorn
006a483528 Insta-MFC of r199084,199108:
Increase the size of the OFW translations buffer to handle G5 systems
   that use many translation regions in firmware, and add bounds checking
   to prevent buffer overflows in case even the new value is exceeded.

Short MFC requested by re since the problem this fixes breaks CD boot on
most G5 systems, making them uninstallable.

Reported by:	Jacob Lambert
Approved by:	re (kensmith,kib)
Requested by:	re
2009-11-09 21:30:45 +00:00
Alan Cox
ebc91405bd MFC r197316
Add a new sysctl for reporting all of the supported page sizes.
2009-10-31 18:54:26 +00:00
Konstantin Belousov
55f128de91 MFC r197933:
Define architectural load bases for PIE binaries.

MFC r198203 (by marius):
Change load base for sparc to match default gcc memory layout model.

Approved by:	re (kensmith)
2009-10-20 13:32:28 +00:00
Nathan Whitehorn
3f12b2cdd4 MFC r197080
Add a few SCSI controllers to GENERIC that can be found in Powermacs.
This allows installation onto SCSI disks as shipped, for example,
as an option with the Powermac G3.

PR:		powerpc/138543
Reviewed by:	grehan
Approved by:	re (kib)
Obtained from:	sparc64
2009-09-19 01:49:36 +00:00
Nathan Whitehorn
ec46867105 MFC r196993
Remove some debugging (KTR_VERBOSE) that crept into ppc GENERIC long ago
and is present on no other architectures by default.

Reviewed by:	grehan
Approved by:	re (kib)
2009-09-19 01:48:12 +00:00
Ken Smith
ac7d4c93c6 Remove extra debugging support that is turned on for head but turned off
for stable branches:

	- shift to MALLOC_PRODUCTION
	- turn off automatic crash dumps
	- Remove kernel debuggers, INVARIANTS*[1], WITNESS* from
	  GENERIC kernel config files[2]

[1] INVARIANTS* left on for ia64 by request marcel
[2] sun4v was left as-is

Reviewed by:	marcel, kib
Approved by:	re (implicit)
2009-09-10 14:04:00 +00:00
Attilio Rao
be1057174e MFC r196196:
* Completely remove the option STOP_NMI from the kernel.  This option
  has proven to have a good effect when entering KDB by using a NMI,
  but it completely violates all the good rules about interrupts
  disabled while holding a spinlock in other occasions.  This can be the
  cause of deadlocks on events where a normal IPI_STOP is expected.
* Add an new IPI called IPI_STOP_HARD on all the supported architectures.
  This IPI is responsible for sending a stop message among CPUs using a
  privileged channel when disponible. In other cases it just does match a
  normal IPI_STOP.
  Right now the IPI_STOP_HARD functionality uses a NMI on ia32 and amd64
  architectures, while on the other has a normal IPI_STOP effect. It is
  responsibility of maintainers to eventually implement an hard stop
  when necessary and possible.
* Use the new IPI facility in order to implement a new userend SMP kernel
  function called stop_cpus_hard(). That is specular to stop_cpu() but
  it does use the privileged channel for the stopping facility.
* Let KDB use the newly introduced function stop_cpus_hard() and leave
  stop_cpus() for all the other cases
* Disable interrupts on CPU0 when starting the process of APs suspension.
* Style cleanup and comments adding

This patch should fix the reboot/shutdown deadlocks many users are
constantly reporting on mailing lists.

Please don't forget to update your config file with the STOP_NMI
option removal

Reviewed by:  jhb
Tested by:    pho, bz, rink
Approved by:  re (kib)
2009-08-13 17:54:11 +00:00
John Baldwin
013818111a Add a new type of VM object: OBJT_SG. An OBJT_SG object is very similar to
a device pager (OBJT_DEVICE) object in that it uses fictitious pages to
provide aliases to other memory addresses.  The primary difference is that
it uses an sglist(9) to determine the physical addresses for a given offset
into the object instead of invoking the d_mmap() method in a device driver.

Reviewed by:	alc
Approved by:	re (kensmith)
MFC after:	2 weeks
2009-07-24 13:50:29 +00:00
Rafal Jaworowski
570255d8a5 Do not use OCP85XX_LBC_OFF twice when accessing LBC registers on MPC85XX.
It turns LBC control registers were not programmed correctly on MPC85XX. We
were accessing bogus addresses as the base offset (OCP85XX_LBC_OFF) was
erroneously added during offset calculations.  Effectively the state of LBC
control registers was not altered by the kernel initialization code, but
everything worked as long as we coincided to use the same settings (LBC decode
windows) as firmware has initialized.

Submitted by:	Lukasz Wojcik
Reviewed by:	marcel
Approved by:	re (kensmith)
Obtained from:	Semihalf
2009-07-21 08:38:45 +00:00
Alan Cox
3153e878dd Add support to the virtual memory system for configuring machine-
dependent memory attributes:

Rename vm_cache_mode_t to vm_memattr_t.  The new name reflects the
fact that there are machine-dependent memory attributes that have
nothing to do with controlling the cache's behavior.

Introduce vm_object_set_memattr() for setting the default memory
attributes that will be given to an object's pages.

Introduce and use pmap_page_{get,set}_memattr() for getting and
setting a page's machine-dependent memory attributes.  Add full
support for these functions on amd64 and i386 and stubs for them on
the other architectures.  The function pmap_page_set_memattr() is also
responsible for any other machine-dependent aspects of changing a
page's memory attributes, such as flushing the cache or updating the
direct map.  The uses include kmem_alloc_contig(), vm_page_alloc(),
and the device pager:

  kmem_alloc_contig() can now be used to allocate kernel memory with
  non-default memory attributes on amd64 and i386.

  vm_page_alloc() and the device pager will set the memory attributes
  for the real or fictitious page according to the object's default
  memory attributes.

Update the various pmap functions on amd64 and i386 that map pages to
incorporate each page's memory attributes in the mapping.

Notes: (1) Inherent to this design are safety features that prevent
the specification of inconsistent memory attributes by different
mappings on amd64 and i386.  In addition, the device pager provides a
warning when a device driver creates a fictitious page with memory
attributes that are inconsistent with the real page that the
fictitious page is an alias for. (2) Storing the machine-dependent
memory attributes for amd64 and i386 as a dedicated "int" in "struct
md_page" represents a compromise between space efficiency and the ease
of MFCing these changes to RELENG_7.

In collaboration with: jhb

Approved by:	re (kib)
2009-07-12 23:31:20 +00:00
Nathan Whitehorn
f136543e41 Increase the size of the page table on 64-bit PowerPC machines as a
bandaid to prevent exhaustion of the primary and secondary hash groups
in the event of extreme stress on the PMAP layer (e.g. a forkbomb). This
wastes memory, and should be revised to properly handle PTEG spills instead.

Suggested by:	grehan
Approved by:	re (kensmith)
2009-07-12 04:07:52 +00:00
Sam Leffler
8c393fd1f0 Cleanup ALIGNED_POINTER:
o add to platforms where it was missing (arm, i386, powerpc, sparc64, sun4v)
o define as "1" on amd64 and i386 where there is no restriction
o make the type returned consistent with ALIGN
o remove _ALIGNED_POINTER
o make associated comments consistent

Reviewed by:	bde, imp, marcel
Approved by:	re (kensmith)
2009-07-05 17:45:48 +00:00
Ed Schouten
89fe4c0a2b Enable POSIX semaphores on all non-embedded architectures by default.
More applications (including Firefox) seem to depend on this nowadays,
so not having this enabled by default is a bad idea.

Proposed by:	miwi
Patch by:	Florian Smeets <flo kasimir com>
Approved by:	re (kib)
2009-07-02 18:24:37 +00:00
Alan Cox
5797795f5a Correct the #endif comment.
Noticed by:	jmallett
Approved by:	re (kib)
2009-06-26 16:22:24 +00:00
Alan Cox
e999111ae7 This change is the next step in implementing the cache control functionality
required by video card drivers.  Specifically, this change introduces
vm_cache_mode_t with an appropriate VM_CACHE_DEFAULT definition on all
architectures.  In addition, this changes adds a vm_cache_mode_t parameter
to kmem_alloc_contig() and vm_phys_alloc_contig().  These will be the
interfaces for allocating mapped kernel memory and physical memory,
respectively, with non-default cache modes.

In collaboration with:	jhb
2009-06-26 04:47:43 +00:00
Rafal Jaworowski
51500a4872 Include SMP support in the MPC85XX kernel by default. 2009-06-25 10:07:21 +00:00
Jeff Roberson
b7c3d41368 - Add the right includes to use kmem_alloc(). This was broken by my
DPCPU commit.
Reported by:	bz
2009-06-25 00:14:27 +00:00