1993-06-12 14:58:17 +00:00
|
|
|
/*-
|
2017-11-20 19:43:44 +00:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
*
|
1993-06-12 14:58:17 +00:00
|
|
|
* Copyright (c) 1990 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* William Jolitz.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2017-02-28 23:42:47 +00:00
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
1993-06-12 14:58:17 +00:00
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1993-10-08 12:49:55 +00:00
|
|
|
* from: @(#)param.h 5.8 (Berkeley) 6/28/91
|
1999-08-28 01:08:13 +00:00
|
|
|
* $FreeBSD$
|
1993-06-12 14:58:17 +00:00
|
|
|
*/
|
|
|
|
|
2009-09-08 20:45:40 +00:00
|
|
|
|
|
|
|
#ifndef _I386_INCLUDE_PARAM_H_
|
|
|
|
#define _I386_INCLUDE_PARAM_H_
|
|
|
|
|
2013-04-21 11:12:44 +00:00
|
|
|
#include <machine/_align.h>
|
2000-11-08 16:59:25 +00:00
|
|
|
|
|
|
|
/*
|
2013-04-21 11:12:44 +00:00
|
|
|
* Machine dependent constants for Intel 386.
|
2000-11-08 16:59:25 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2006-01-09 06:05:57 +00:00
|
|
|
#define __HAVE_ACPI
|
2011-06-22 21:04:13 +00:00
|
|
|
#define __HAVE_PIR
|
2006-01-09 06:05:57 +00:00
|
|
|
#define __PCI_REROUTE_INTERRUPT
|
|
|
|
|
2000-11-08 16:59:25 +00:00
|
|
|
#ifndef MACHINE
|
|
|
|
#define MACHINE "i386"
|
|
|
|
#endif
|
1999-03-01 06:10:16 +00:00
|
|
|
#ifndef MACHINE_ARCH
|
1998-08-31 08:41:58 +00:00
|
|
|
#define MACHINE_ARCH "i386"
|
1999-03-01 06:10:16 +00:00
|
|
|
#endif
|
1998-06-14 15:21:27 +00:00
|
|
|
#define MID_MACHINE MID_I386
|
|
|
|
|
2008-03-27 05:03:26 +00:00
|
|
|
#if defined(SMP) || defined(KLD_MODULE)
|
2011-07-19 00:37:24 +00:00
|
|
|
#ifndef MAXCPU
|
2008-10-01 21:59:04 +00:00
|
|
|
#define MAXCPU 32
|
2011-07-19 00:37:24 +00:00
|
|
|
#endif
|
1997-08-18 05:34:01 +00:00
|
|
|
#else
|
2000-09-23 12:18:06 +00:00
|
|
|
#define MAXCPU 1
|
2008-03-27 05:03:26 +00:00
|
|
|
#endif /* SMP || KLD_MODULE */
|
1997-08-21 05:08:25 +00:00
|
|
|
|
2013-05-07 22:46:24 +00:00
|
|
|
#ifndef MAXMEMDOM
|
|
|
|
#define MAXMEMDOM 1
|
|
|
|
#endif
|
|
|
|
|
2000-11-08 16:59:25 +00:00
|
|
|
#define ALIGNBYTES _ALIGNBYTES
|
|
|
|
#define ALIGN(p) _ALIGN(p)
|
2009-07-05 17:45:48 +00:00
|
|
|
/*
|
|
|
|
* ALIGNED_POINTER is a boolean macro that checks whether an address
|
|
|
|
* is valid to fetch data elements of type t from on this architecture.
|
|
|
|
* This does not reflect the optimal alignment, just the possibility
|
|
|
|
* (within reasonable limits).
|
|
|
|
*/
|
|
|
|
#define ALIGNED_POINTER(p, t) 1
|
1993-07-28 01:42:17 +00:00
|
|
|
|
2009-04-19 21:26:36 +00:00
|
|
|
/*
|
|
|
|
* CACHE_LINE_SIZE is the compile-time maximum cache line size for an
|
|
|
|
* architecture. It should be used with appropriate caution.
|
|
|
|
*/
|
2017-08-28 22:28:41 +00:00
|
|
|
#define CACHE_LINE_SHIFT 6
|
2009-04-19 20:19:13 +00:00
|
|
|
#define CACHE_LINE_SIZE (1 << CACHE_LINE_SHIFT)
|
|
|
|
|
1996-05-02 14:21:14 +00:00
|
|
|
#define PAGE_SHIFT 12 /* LOG2(PAGE_SIZE) */
|
i386: Merge PAE and non-PAE pmaps into same kernel.
Effectively all i386 kernels now have two pmaps compiled in: one
managing PAE pagetables, and another non-PAE. The implementation is
selected at cold time depending on the CPU features. The vm_paddr_t is
always 64bit now. As result, nx bit can be used on all capable CPUs.
Option PAE only affects the bus_addr_t: it is still 32bit for non-PAE
configs, for drivers compatibility. Kernel layout, esp. max kernel
address, low memory PDEs and max user address (same as trampoline
start) are now same for PAE and for non-PAE regardless of the type of
page tables used.
Non-PAE kernel (when using PAE pagetables) can handle physical memory
up to 24G now, larger memory requires re-tuning the KVA consumers and
instead the code caps the maximum at 24G. Unfortunately, a lot of
drivers do not use busdma(9) properly so by default even 4G barrier is
not easy. There are two tunables added: hw.above4g_allow and
hw.above24g_allow, the first one is kept enabled for now to evaluate
the status on HEAD, second is only for dev use.
i386 now creates three freelists if there is any memory above 4G, to
allow proper bounce pages allocation. Also, VM_KMEM_SIZE_SCALE changed
from 3 to 1.
The PAE_TABLES kernel config option is retired.
In collaboarion with: pho
Discussed with: emaste
Reviewed by: markj
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D18894
2019-01-30 02:07:13 +00:00
|
|
|
#define PAGE_SIZE (1 << PAGE_SHIFT) /* bytes/page */
|
|
|
|
#define PAGE_MASK (PAGE_SIZE - 1)
|
|
|
|
#define NPTEPG (PAGE_SIZE / sizeof(pt_entry_t))
|
|
|
|
|
|
|
|
/* Size in bytes of the page directory */
|
|
|
|
#define NBPTD (NPGPTD << PAGE_SHIFT)
|
|
|
|
/* Number of PDEs in page directory, 2048 for PAE, 1024 for non-PAE */
|
|
|
|
#define NPDEPTD (NBPTD / sizeof(pd_entry_t))
|
|
|
|
/* Number of PDEs in one page of the page directory, 512 vs. 1024 */
|
|
|
|
#define NPDEPG (PAGE_SIZE / sizeof(pd_entry_t))
|
|
|
|
#define PDRMASK (NBPDR - 1)
|
|
|
|
#ifndef PDRSHIFT
|
|
|
|
#define PDRSHIFT i386_pmap_PDRSHIFT
|
|
|
|
#endif
|
|
|
|
#ifndef NBPDR
|
|
|
|
#define NBPDR (1 << PDRSHIFT) /* bytes/page dir */
|
2003-03-30 05:24:52 +00:00
|
|
|
#endif
|
1993-06-12 14:58:17 +00:00
|
|
|
|
2009-09-18 17:04:57 +00:00
|
|
|
#define MAXPAGESIZES 2 /* maximum number of supported page sizes */
|
|
|
|
|
1997-08-09 00:04:06 +00:00
|
|
|
#define IOPAGES 2 /* pages of i/o permission bitmap */
|
2001-08-25 02:20:02 +00:00
|
|
|
|
2001-09-12 08:38:13 +00:00
|
|
|
#ifndef KSTACK_PAGES
|
i386: Bump KSTACK_PAGES default to match amd64
Logically, extend r286288 to cover all threads, by default.
The world has largely moved on from i386. Most FreeBSD users and developers
test on amd64 hardware. For better or worse, we have written a non-trivial
amount of kernel code that relies on stacks larger than 8 kB, and it "just
works" on amd64, so there has been little incentive to shrink it.
amd64 had its KSTACK_PAGES bumped to 4 back in Peter's initial AMD64 commit,
r114349, in 2003. Since that time, i386 has limped along on a stack half
the size. We've even observed the stack overflows years ago, but neglected
to fix the issue; see the 20121223 and 20150728 entries in UPDATING.
If anyone is concerned with this change, I suggest they configure their
AMD64 kernels with KSTACK_PAGES 2 and fix the fallout there first. Eugene
has identified a list of high stack usage functions in the first PR below.
PR: 219476, 224218
Reported by: eugen@, Shreesh Holla <hshreesh AT yahoo.com>
Relnotes: maybe
Sponsored by: Dell EMC Isilon
2017-12-11 04:32:37 +00:00
|
|
|
#define KSTACK_PAGES 4 /* Includes pcb! */
|
2001-08-25 02:20:02 +00:00
|
|
|
#endif
|
2003-06-14 23:23:55 +00:00
|
|
|
#define KSTACK_GUARD_PAGES 1 /* pages of kstack guard; 0 disables */
|
2015-08-04 13:50:52 +00:00
|
|
|
#if KSTACK_PAGES < 4
|
|
|
|
#define TD0_KSTACK_PAGES 4
|
|
|
|
#else
|
|
|
|
#define TD0_KSTACK_PAGES KSTACK_PAGES
|
|
|
|
#endif
|
2001-09-12 08:38:13 +00:00
|
|
|
|
2012-08-27 13:22:27 +00:00
|
|
|
/*
|
|
|
|
* Ceiling on amount of swblock kva space, can be changed via
|
|
|
|
* the kern.maxswzone /boot/loader.conf variable.
|
|
|
|
*
|
|
|
|
* 276 is sizeof(struct swblock), but we do not always have a definition
|
|
|
|
* in scope for struct swblock, so we have to hardcode it. Each struct
|
|
|
|
* swblock holds metadata for 32 pages, so in theory, this is enough for
|
|
|
|
* 16 GB of swap. In practice, however, the usable amount is considerably
|
|
|
|
* lower due to fragmentation.
|
|
|
|
*/
|
|
|
|
#ifndef VM_SWZONE_SIZE_MAX
|
|
|
|
#define VM_SWZONE_SIZE_MAX (276 * 128 * 1024)
|
|
|
|
#endif
|
|
|
|
|
2001-08-20 00:41:12 +00:00
|
|
|
/*
|
|
|
|
* Ceiling on size of buffer cache (really only effects write queueing,
|
2002-08-31 21:15:29 +00:00
|
|
|
* the VM page cache is not effected), can be changed via
|
|
|
|
* the kern.maxbcache /boot/loader.conf variable.
|
2013-03-27 10:52:18 +00:00
|
|
|
*
|
|
|
|
* The value is equal to the size of the auto-tuned buffer map for
|
|
|
|
* the machine with 4GB of RAM, see vfs_bio.c:kern_vfs_bio_buffer_alloc().
|
2001-08-20 00:41:12 +00:00
|
|
|
*/
|
|
|
|
#ifndef VM_BCACHE_SIZE_MAX
|
2013-03-27 10:52:18 +00:00
|
|
|
#define VM_BCACHE_SIZE_MAX (7224 * 16 * 1024)
|
2001-08-20 00:41:12 +00:00
|
|
|
#endif
|
|
|
|
|
1993-06-12 14:58:17 +00:00
|
|
|
/*
|
|
|
|
* Mach derived conversion macros
|
|
|
|
*/
|
1998-10-13 08:24:45 +00:00
|
|
|
#define trunc_page(x) ((x) & ~PAGE_MASK)
|
|
|
|
#define round_page(x) (((x) + PAGE_MASK) & ~PAGE_MASK)
|
2003-03-25 00:07:06 +00:00
|
|
|
#define trunc_4mpage(x) ((x) & ~PDRMASK)
|
|
|
|
#define round_4mpage(x) ((((x)) + PDRMASK) & ~PDRMASK)
|
1994-05-25 09:21:21 +00:00
|
|
|
|
2003-03-25 00:07:06 +00:00
|
|
|
#define atop(x) ((x) >> PAGE_SHIFT)
|
|
|
|
#define ptoa(x) ((x) << PAGE_SHIFT)
|
VM system performance improvements from John Dyson and myself. The
following is a summary:
1) increased object cache back up to a more reasonable value.
2) removed old & bogus cruft from machdep.c (clearseg, copyseg,
physcopyseg, etc).
3) inlined many functions in pmap.c
4) changed "load_cr3(rcr3())" into tlbflush() and made tlbflush inline
assembly.
5) changed the way that modified pages are tracked - now vm_page struct
is kept updated directly - no more scanning page tables.
6) removed lots of unnecessary spl's
7) removed old unused functions from pmap.c
8) removed all use of page_size, page_shift, page_mask variables - replaced
with PAGE_ constants.
9) moved trunc/round_page, atop, ptoa, out of vm_param.h and into i386/
include/param.h, and optimized them.
10) numerous changes to sys/vm/ swap_pager, vnode_pager, pageout, fault
code to improve performance. LRU algorithm modified to be more
effective, read ahead/behind values tuned for better performance,
etc, etc...
1994-01-31 04:19:00 +00:00
|
|
|
|
2003-03-25 00:07:06 +00:00
|
|
|
#define i386_btop(x) ((x) >> PAGE_SHIFT)
|
|
|
|
#define i386_ptob(x) ((x) << PAGE_SHIFT)
|
1993-10-12 07:13:12 +00:00
|
|
|
|
1999-02-19 19:34:49 +00:00
|
|
|
#define pgtok(x) ((x) * (PAGE_SIZE / 1024))
|
|
|
|
|
i386 4/4G split.
The change makes the user and kernel address spaces on i386
independent, giving each almost the full 4G of usable virtual addresses
except for one PDE at top used for trampoline and per-CPU trampoline
stacks, and system structures that must be always mapped, namely IDT,
GDT, common TSS and LDT, and process-private TSS and LDT if allocated.
By using 1:1 mapping for the kernel text and data, it appeared
possible to eliminate assembler part of the locore.S which bootstraps
initial page table and KPTmap. The code is rewritten in C and moved
into the pmap_cold(). The comment in vmparam.h explains the KVA
layout.
There is no PCID mechanism available in protected mode, so each
kernel/user switch forth and back completely flushes the TLB, except
for the trampoline PTD region. The TLB invalidations for userspace
becomes trivial, because IPI handlers switch page tables. On the other
hand, context switches no longer need to reload %cr3.
copyout(9) was rewritten to use vm_fault_quick_hold(). An issue for
new copyout(9) is compatibility with wiring user buffers around sysctl
handlers. This explains two kind of locks for copyout ptes and
accounting of the vslock() calls. The vm_fault_quick_hold() AKA slow
path, is only tried after the 'fast path' failed, which temporary
changes mapping to the userspace and copies the data to/from small
per-cpu buffer in the trampoline. If a page fault occurs during the
copy, it is short-circuit by exception.s to not even reach C code.
The change was motivated by the need to implement the Meltdown
mitigation, but instead of KPTI the full split is done. The i386
architecture already shows the sizing problems, in particular, it is
impossible to link clang and lld with debugging. I expect that the
issues due to the virtual address space limits would only exaggerate
and the split gives more liveness to the platform.
Tested by: pho
Discussed with: bde
Sponsored by: The FreeBSD Foundation
MFC after: 1 month
Differential revision: https://reviews.freebsd.org/D14633
2018-04-13 20:30:49 +00:00
|
|
|
#define INKERNEL(va) (TRUE)
|
2015-07-02 14:37:21 +00:00
|
|
|
|
2009-09-08 20:45:40 +00:00
|
|
|
#endif /* !_I386_INCLUDE_PARAM_H_ */
|