dragonfly.git
3 years agopmap: Refactor PG_*_IDX and pmap_bits_default definitions
Aaron LI [Sat, 5 Jun 2021 03:57:23 +0000 (11:57 +0800)]
pmap: Refactor PG_*_IDX and pmap_bits_default definitions

Refactor PG_*_IDX definitions by using an enumeration, and define the
pmap_bits_default[] array with named indices, making its items more
cleaer.

In addition, drop the unused 'PG_UNUSED10_IDX' item and fix some wrong
comments.

No functional changes.

3 years agox86_64/pmap.h: Move Intel EPT defines from <vmm/ept.h>
Aaron LI [Thu, 3 Jun 2021 22:35:25 +0000 (06:35 +0800)]
x86_64/pmap.h: Move Intel EPT defines from <vmm/ept.h>

Renamed 'EPT_IGNORE_PAT' to 'EPT_PG_IGNORE_PAT' for better naming
consistency.  Fixes to the vmm/ept code will follow.

While there, minor style adjustments.

3 years agonpx: Export fpusave()/fpurstor() functions for NVMM
Aaron LI [Sun, 16 May 2021 01:38:13 +0000 (09:38 +0800)]
npx: Export fpusave()/fpurstor() functions for NVMM

3 years agoMakefile: Install 'master.passwd' and 'group' if not exist
Aaron LI [Thu, 24 Jun 2021 14:27:59 +0000 (22:27 +0800)]
Makefile: Install 'passwd' and 'group' if not exist

For a new installation specified with DESTDIR, 'master.passwd' and
'group' just don't exist.  Install them in such a case in 'preinstall'
target.  Otherwise we'll be missing them since they're no longer
installed by 'installworld'.

3 years agoMakefile: Rename 'preupgrade' to 'preinstall'
Aaron LI [Thu, 24 Jun 2021 14:11:38 +0000 (22:11 +0800)]
Makefile: Rename 'preupgrade' to 'preinstall'

The 'preupgrade' target performs certain pre-installworld operations,
and is executed before 'installworld' automatically.  So rename it to
'preinstall'.

Update build(7) man page accordingly.

Suggested-by: swildner
3 years agoMakefile: Make 'installworld' depend on 'preupgrade'
Aaron LI [Thu, 27 May 2021 23:17:12 +0000 (07:17 +0800)]
Makefile: Make 'installworld' depend on 'preupgrade'

The 'preupgrade' target will creates new users/groups, which may be
required by the 'installworld' target, so make 'installworld' depend on
'preupgrade'.  This will fix the installation of nvmmctl(8) that
requires the 'nvmm' group.

As another result, no longer need to check for users/groups in the
'installcheck' target.

3 years agox86_64/cpufunc.h: Add load_cr2() function
Aaron LI [Sun, 9 May 2021 23:33:54 +0000 (07:33 +0800)]
x86_64/cpufunc.h: Add load_cr2() function

This function is a companion of rcr2() and would be used in NVMM.

3 years agox86_64/cpufunc.h: Add rxcr() and rename xsetbv() to load_xcr()
Aaron LI [Sun, 9 May 2021 23:27:17 +0000 (07:27 +0800)]
x86_64/cpufunc.h: Add rxcr() and rename xsetbv() to load_xcr()

* rxcr() is taken from FreeBSD with minor changes.
* Rename xsetbv() to load_xcr(), being consistent with rxcr() and other
  rcrX() and load_rcX() functions. (FreeBSD also uses load_xcr().)
* Clean up a bit and use standard int types.

These two functions would be used in NVMM.

3 years agoetc/Makefile: Fix typo
Antonio Huete Jimenez [Tue, 22 Jun 2021 07:50:44 +0000 (09:50 +0200)]
etc/Makefile: Fix typo

3 years agoinstallworld - don't pre-upgrade passwd files that do not exist
Matthew Dillon [Tue, 22 Jun 2021 06:02:50 +0000 (23:02 -0700)]
installworld - don't pre-upgrade passwd files that do not exist

* Fix installworld on a fresh (empty) root.  Don't try to
  pre-upgrade files that do not yet exist.

3 years agosys/vfs/hammer2: Remove unused HAMMER2_INODE_METAGOOD
Tomohiro Kusumi [Mon, 21 Jun 2021 17:19:33 +0000 (02:19 +0900)]
sys/vfs/hammer2: Remove unused HAMMER2_INODE_METAGOOD

This appeared in 7a9b14a0e3b0630905b28addf32dfdef68b39014 in 2015,
but was only used for kasserts which never failed as it was always set.

3 years agosys/vfs/hammer2: Remove unused HAMMER2_INODE_SROOT
Tomohiro Kusumi [Mon, 21 Jun 2021 17:07:17 +0000 (02:07 +0900)]
sys/vfs/hammer2: Remove unused HAMMER2_INODE_SROOT

No longer used since 504565062f34ec55037ac0cf308fe3562f091460 in 2014.

3 years agosys/vfs/hammer2: Remove if0'd HAMMER2_TRANS_PREFLUSH
Tomohiro Kusumi [Mon, 21 Jun 2021 16:31:57 +0000 (01:31 +0900)]
sys/vfs/hammer2: Remove if0'd HAMMER2_TRANS_PREFLUSH

This no longer exists since 2085215738c03d949e60de63843cb91e84836eb9 in 2016.

3 years agosys/vfs/hammer2: Remove unused FLUSH_DEBUG
Tomohiro Kusumi [Mon, 21 Jun 2021 15:20:08 +0000 (00:20 +0900)]
sys/vfs/hammer2: Remove unused FLUSH_DEBUG

No longer used since 8138a154be31c3db1d8bd046ca7b003a6c79c01c in 2014.

3 years agoipfw3nat: ICMP packets NAT using icmp id
Bill Yuan [Mon, 21 Jun 2021 15:04:33 +0000 (23:04 +0800)]
ipfw3nat: ICMP packets NAT using icmp id

TCP/UDP are using tuple(srcip,srcport,dstip, dstport),
while ICMP is using tuple(srcip, icmp_id, dstip, icmp_id)

icmp_id after NAT is generated using srcip & dstip

3 years agosys/vfs/hammer2: Remove redundant local dedup mask variable initialization
Tomohiro Kusumi [Sat, 19 Jun 2021 15:34:07 +0000 (00:34 +0900)]
sys/vfs/hammer2: Remove redundant local dedup mask variable initialization

3 years agohammer2 - hammer2 growfs, also update hmp->volumes[0].size
Matthew Dillon [Sun, 20 Jun 2021 16:24:51 +0000 (09:24 -0700)]
hammer2 - hammer2 growfs, also update hmp->volumes[0].size

* hammer2 growfs also needs to update hmp->volumes[0].size,
  otherwise a panic on file write past the previous boundary
  will ensue.

* Note that a reboot after issuing the growfs also takes care
  of this.

Reported-by: goneri (irc)
3 years agopmap: Move pmap_pte_index() and remove pmap_{pde,pdpe,pml4e}_index()
Aaron LI [Sat, 5 Jun 2021 05:03:03 +0000 (13:03 +0800)]
pmap: Move pmap_pte_index() and remove pmap_{pde,pdpe,pml4e}_index()

* Move pmap_pte_index() from 'pmap.h' to pc64/pmap.c since it's only
  used there.  (vkernel64 has the same function in its pmap.c)
* Remove unused pmap_pde_index(), pmap_pdpe_index() and
  pmap_pml4e_index() functions from 'pmap.h'.  Well, the same
  functionalities are implemented in pmap.c as pmap_pt_index(),
  pmap_pd_index() and pmap_pdp_index(), respectively.
* Improve the description of these functions a bit.

3 years agopmap: Eliminate a simple macro 'pte_load_clear()'
Aaron LI [Thu, 3 Jun 2021 01:05:22 +0000 (09:05 +0800)]
pmap: Eliminate a simple macro 'pte_load_clear()'

First, this macro is not used in vkernel64's pmap code.  Secondly, this
macro is sudden and looks unrelated to other things in the pmap.h
header.  So just substitute it in the pmap code and get rid of it.

3 years agovm/pmap.h: Move vtophys() and vtophys_pte() macros here
Aaron LI [Thu, 3 Jun 2021 01:01:40 +0000 (09:01 +0800)]
vm/pmap.h: Move vtophys() and vtophys_pte() macros here

The two macros are defined against with pmap_kextract(), which is also
declared in this header file, so it's a better place to hold the two
macros.

In addition, this adjustment avoids the duplicates in both pc64 and
vkernel64.

3 years agox86_64/param.h: Remove 'NPML4' (duplicate of 'NBPML4')
Aaron LI [Thu, 3 Jun 2021 00:49:21 +0000 (08:49 +0800)]
x86_64/param.h: Remove 'NPML4' (duplicate of 'NBPML4')

The 'NPML4' and 'NBPML4' definitions are the same, so only keep the
latter, which is consistent with definitions of 'NBPDP' and 'NBPDR'.

Adjust whitespace a bit.

3 years agoBump __DragonFly_version for type change of VM globals
Aaron LI [Tue, 25 May 2021 01:13:23 +0000 (09:13 +0800)]
Bump __DragonFly_version for type change of VM globals

3 years agovm: Change 'kernel_pmap' global to pointer type
Aaron LI [Mon, 24 May 2021 12:28:12 +0000 (20:28 +0800)]
vm: Change 'kernel_pmap' global to pointer type

Following the previous commits, this commit changes the 'kernel_pmap'
to pointer type of 'struct pmap *'.  This makes it align better with
'kernel_map' and simplifies the code a bit.

No functional changes.

3 years agovm: Change 'kernel_object' global to pointer type
Aaron LI [Fri, 21 May 2021 13:39:12 +0000 (21:39 +0800)]
vm: Change 'kernel_object' global to pointer type

Following the previous commits, this commit changes the 'kernel_object'
to pointer type of 'struct vm_object *'.  This makes it align better
with 'kernel_map' and simplifies the code a bit.

No functional changes.

3 years agovm: Change {buffer,clean,pager}_map globals to pointer type
Aaron LI [Thu, 20 May 2021 14:52:15 +0000 (22:52 +0800)]
vm: Change {buffer,clean,pager}_map globals to pointer type

Similar to the previous commit that changes global 'kernel_map' to type
of 'struct vm_map *', change related globals 'buffer_map', 'clean_map'
and 'pager_map' to pointer type, i.e., 'struct vm_map *'.

No functional changes.

3 years agovm: Change 'kernel_map' global to type of 'struct vm_map *'
Aaron LI [Thu, 20 May 2021 14:40:00 +0000 (22:40 +0800)]
vm: Change 'kernel_map' global to type of 'struct vm_map *'

Change the global variable 'kernel_map' from type 'struct vm_map' to a
pointer to this struct.  This simplify the code a bit since all
invocations take its address.  This change also aligns with NetBSD's
'kernal_map' that it's also a pointer, which also helps the porting of
NVMM.

No functional changes.

3 years agox86_64/specialreg.h: Deprecate old defines of Spectre mitigation
Aaron LI [Wed, 26 May 2021 11:40:58 +0000 (19:40 +0800)]
x86_64/specialreg.h: Deprecate old defines of Spectre mitigation

Migrate the old defines of Spectre mitigation to the new ones obtained
from NetBSD and FreeBSD.  Specifically, apply the following changes:

* CPUID_7_0_I3_* -> CPUID_STDEXT3_*
* CPUID_SEF_* -> CPUID_STDEXT3_*
* CPUID_*_80000008_I1_* -> CPUID_CAPEX_*

In addition, merge the comments to the relevant code.

No functional changes.

3 years agox86_64/specialreg.h: Reorganize SPEC_CTRL_* macros
Aaron LI [Wed, 26 May 2021 11:38:00 +0000 (19:38 +0800)]
x86_64/specialreg.h: Reorganize SPEC_CTRL_* macros

Move the SPEC_CTRL_* bit defines near to the corresponding MSR_SPEC_CTRL
MSR definition.

3 years agox86_64/specialreg.h: Add several MSR defines for NVMM
Aaron LI [Tue, 11 May 2021 06:19:55 +0000 (14:19 +0800)]
x86_64/specialreg.h: Add several MSR defines for NVMM

* Add MSR_IA32_FLUSH_CMD define, together with one bit define.
* Add various bit defines for MSR_IA32_MISC_ENABLE.
* Add MSR_AMD_NB_CFG, MSR_AMD_PATCH_LEVEL, MSR_AMD_LS_CFG,
  and MSR_AMD_IC_CFG defines.
* Rename MSR_K8_UCODE_UPDATE -> MSR_AMD_PATCH_LOADER, for naming
  consistency.

Taken from NetBSD and referred to FreeBSD.

3 years agox86_64/specialreg.h: Rename MSR_SYSENTER_* defines for consistency
Aaron LI [Tue, 11 May 2021 06:18:42 +0000 (14:18 +0800)]
x86_64/specialreg.h: Rename MSR_SYSENTER_* defines for consistency

Remove the _MSR suffix from these 3 MSR defines.

3 years agox86_64/specialreg.h: Rename two IA32_ARCH_* defines for consistency
Aaron LI [Tue, 11 May 2021 05:18:43 +0000 (13:18 +0800)]
x86_64/specialreg.h: Rename two IA32_ARCH_* defines for consistency

Rename IA32_ARCH_SSB_NO -> IA32_ARCH_CAP_SSB_NO, and
IA32_ARCH_MDS_NO -> IA32_ARCH_CAP_MDS_NO, for better consistency with
other IA32_ARCH_CAP_* defines.

Submitted in bug #3265 by chicken.
https://bugs.dragonflybsd.org/issues/3265

3 years agox86_64/specialreg.h: Reorganize and sort various MSR defines
Aaron LI [Tue, 11 May 2021 05:13:30 +0000 (13:13 +0800)]
x86_64/specialreg.h: Reorganize and sort various MSR defines

Sort some MSR defines by their addresses.  Reorganize some MSR bit
defines to group with their corresponding MSRs.

Some whitespace cleanups to align better.

3 years agox86_64/specialreg.h: Rename several CR4 defines
Aaron LI [Tue, 11 May 2021 04:39:54 +0000 (12:39 +0800)]
x86_64/specialreg.h: Rename several CR4 defines

Rename CR4_FXSR -> CR4_OSFXSR, CR4_XMM -> CR4_OSXMMEXCPT, and
CR4_XSAVE -> CR4_OSXSAVE, so that they match the naming conventions in
the Intel specification and look more clear.

Submitted in bug #3265 by chicken:
https://bugs.dragonflybsd.org/issues/3265

3 years agox86_64/specialreg.h: Rename MSR_TSCAUX to MSR_TSC_AUX
Aaron LI [Mon, 10 May 2021 17:07:45 +0000 (01:07 +0800)]
x86_64/specialreg.h: Rename MSR_TSCAUX to MSR_TSC_AUX

Align better with the specification, and FreeBSD also use it.

3 years agox86_64/specialreg.h: Rename MSR_PERFCTRx to avoid #undef's
Aaron LI [Mon, 10 May 2021 17:06:00 +0000 (01:06 +0800)]
x86_64/specialreg.h: Rename MSR_PERFCTRx to avoid #undef's

Rename MSR_PERFCTRx to MSR_K7_PERFCTRx, following the same names as in
FreeBSD and NetBSD.  This also avoids #undef's.

3 years agox86_64/specialreg.h: Improve MSR_AMD_VM_CR bits defines
Aaron LI [Mon, 10 May 2021 16:44:13 +0000 (00:44 +0800)]
x86_64/specialreg.h: Improve MSR_AMD_VM_CR bits defines

Rename bit define MSR_AMD_VM_CR_SVMDIS to VM_CR_SVMDIS for better
consistency.  Add more VM_CR bit defines.

Referred to NetBSD and AMD programmer's manual.

3 years agox86_64/specialreg.h: Add CPUID Fn8000_000A (AMD SVM) defines
Aaron LI [Mon, 10 May 2021 16:20:18 +0000 (00:20 +0800)]
x86_64/specialreg.h: Add CPUID Fn8000_000A (AMD SVM) defines

These defines are taken from NetBSD, with comments from the AMD manual.
Some of the defines will be used in NVMM.

3 years agox86_64/specialreg.h: Add more CPUID Fn8000_0008 defines
Aaron LI [Mon, 10 May 2021 16:14:21 +0000 (00:14 +0800)]
x86_64/specialreg.h: Add more CPUID Fn8000_0008 defines

CPUID Fn8000_0008 - AMD Processor Capacity Parameters and Extended Features

These CPUID defines are taken from NetBSD, and some of them will be used
by NVMM.

Note that FreeBSD also has such CPUID, but in different names.

3 years agox86_64/specialreg.h: Improve CPUID Fn8000_0007 defines
Aaron LI [Mon, 10 May 2021 16:08:37 +0000 (00:08 +0800)]
x86_64/specialreg.h: Improve CPUID Fn8000_0007 defines

CPUID Fn8000_0007 - Advanced Power Management

Add CPUID_APM_* defines with some comments, taken from NetBSD.
And define original AMDPM_* macros based on the new ones.

3 years agox86_64/specialreg.h: Improve CPUID Fn8000_0001 defines
Aaron LI [Mon, 10 May 2021 16:03:39 +0000 (00:03 +0800)]
x86_64/specialreg.h: Improve CPUID Fn8000_0001 defines

CPUID Fn8000_0001 - Extended Features

Add many more defines for this CPUID function, taken from NetBSD.
Meanwhile, define original AMDID_* and AMDID2_* macros based on the
new defines.

Some of these defines will be used in NVMM.

3 years agox86_64/specialreg.h: Add CPUID Fn0000_000D defines
Aaron LI [Mon, 10 May 2021 15:59:39 +0000 (23:59 +0800)]
x86_64/specialreg.h: Add CPUID Fn0000_000D defines

Add CPUID Fn0000_000D (Processor Extended State Enumeration) defines,
taken from NetBSD, and will be used by NVMM.

3 years agox86_64/specialreg.h: Reorganize CPUID Fn0000_000B defines
Aaron LI [Mon, 10 May 2021 15:56:19 +0000 (23:56 +0800)]
x86_64/specialreg.h: Reorganize CPUID Fn0000_000B defines

3 years agox86_64/specialreg.h: Add various CPUID Fn0000_0007 defines
Aaron LI [Mon, 10 May 2021 15:46:06 +0000 (23:46 +0800)]
x86_64/specialreg.h: Add various CPUID Fn0000_0007 defines

These Structured Extended Features (SEF) defines are taken from FreeBSD,
but with comments taken from NetBSD.

Some of these SEF defines will be used by NVMM. (Although NetBSD define
them with different names than FreeBSD.)

3 years agox86_64/specialreg.h: Improve CPUID Fn0000_000[456] feature defines
Aaron LI [Mon, 10 May 2021 15:39:27 +0000 (23:39 +0800)]
x86_64/specialreg.h: Improve CPUID Fn0000_000[456] feature defines

* Reorganize these define groups in CPUID function ordering.
* Add basic comments to various items (mostly taken from NetBSD).

3 years agox86_64/specialreg.h: Improve XCR0 defines a bit
Aaron LI [Mon, 10 May 2021 15:17:04 +0000 (23:17 +0800)]
x86_64/specialreg.h: Improve XCR0 defines a bit

* Move XCR0 defines CPU_XFEATURE_* before the CPUID feature defines,
  so the CPUID/AMDID defines groups better.
* Add a bit comments to the defines (obtained from NetBSD).
* Add a alias define CPU_XFEATURE_AVX, although won't be used yet.

3 years agox86_64/specialreg.h: Remove CPUID_XMM alias to favor CPUID_SSE
Aaron LI [Sat, 19 Jun 2021 04:16:45 +0000 (12:16 +0800)]
x86_64/specialreg.h: Remove CPUID_XMM alias to favor CPUID_SSE

The CPUID_XMM is defined as an alias to CPUID_SSE.  So just remove
CPUID_XMM and always use CPUID_SSE instead.  This makes the code a bit
clearer.

3 years agox86_64/specialreg.h: Improve CPUID Fn0000_0001 feature defines
Aaron LI [Mon, 10 May 2021 14:36:39 +0000 (22:36 +0800)]
x86_64/specialreg.h: Improve CPUID Fn0000_0001 feature defines

* Add/improve comments to various feature defines.
* Add some missing feature defines.
* Remove unused and reserved CPUID_B10 and CPUID_B20.

Mostly taken from NetBSD, also referred to FreeBSD.

3 years agox86_64/specialreg.h: Add more defines for EFER bits
Aaron LI [Mon, 10 May 2021 14:20:06 +0000 (22:20 +0800)]
x86_64/specialreg.h: Add more defines for EFER bits

Add several more EFER bits define, and move them close to the MSR_EFER
define to organize better.

Taken from NetBSD and the submit in bug #3265 by chicken:
https://bugs.dragonflybsd.org/issues/3265

3 years agox86_64/specialreg.h: Add more defines for CR4 bits
Aaron LI [Mon, 10 May 2021 14:16:21 +0000 (22:16 +0800)]
x86_64/specialreg.h: Add more defines for CR4 bits

Taken from NetBSD and the submit in bug #3265 by chicken:
https://bugs.dragonflybsd.org/issues/3265

3 years agox86_64/specialreg.h: Add more defines for CR0 bits
Aaron LI [Mon, 10 May 2021 14:03:20 +0000 (22:03 +0800)]
x86_64/specialreg.h: Add more defines for CR0 bits

Taken from NetBSD, also referred to FreeBSD.

Specifically, CR0_ET is used by NVMM.

Meanwhile, improve the comments a bit.

3 years agox86_64/segments.h: Fix typo of an unused struct member
Aaron LI [Tue, 18 May 2021 06:25:12 +0000 (14:25 +0800)]
x86_64/segments.h: Fix typo of an unused struct member

Change memeber name 'sd_xx1' to 'gd_xx1' in 'struct gate_descriptor', so
it aligns with other struct members.

3 years agox86_64/segments.h: Add more system segment defines
Aaron LI [Sun, 9 May 2021 23:23:03 +0000 (07:23 +0800)]
x86_64/segments.h: Add more system segment defines

Taken from FreeBSD (also referred to NetBSD).

Specifically, SDT_SYS286BSY is used by NVMM.

Also improve the comments a bit.

3 years agoinclude: Some minor cleanups to Makefile
Aaron LI [Thu, 27 May 2021 10:39:44 +0000 (18:39 +0800)]
include: Some minor cleanups to Makefile

* Remove a duplicate item (bus/cam) from LSUBDIRS.
* Adjust and improve comments for LSUBDIRS and LSYMSUBDIRS.
* Amend LSYMSUBDIRS a bit to be more clear.

3 years agolibutil: Allow suffix to be NULL in humanize_{number,unsigned}()
Aaron LI [Thu, 27 May 2021 11:13:05 +0000 (19:13 +0800)]
libutil: Allow suffix to be NULL in humanize_{number,unsigned}()

Allow to pass NULL to the suffix argument to these two functions.  If
suffix is NULL, then take it as "" (i.e., empty suffix).  This case
happens in nvmmctl(8).

3 years agolibutil: Fix a minor NULL deref issue in humanize_number()
Aaron LI [Thu, 27 May 2021 11:10:10 +0000 (19:10 +0800)]
libutil: Fix a minor NULL deref issue in humanize_number()

Modify buf after checking it's not NULL.  Although it's certainly a
misuse to pass a NULL as buf but with len > 0, fix it FWIW.

3 years agolibutil: Sort files in Makefile
Aaron LI [Tue, 25 May 2021 23:32:22 +0000 (07:32 +0800)]
libutil: Sort files in Makefile

3 years agolibutil: Bring in snprintb() and snprintb_m() from NetBSD
Aaron LI [Tue, 25 May 2021 23:20:56 +0000 (07:20 +0800)]
libutil: Bring in snprintb() and snprintb_m() from NetBSD

At least, nvmmctl(8) requires snprintb().

3 years agotools: Sync 'install.sh' options with install(1)
Aaron LI [Mon, 14 Jun 2021 07:43:46 +0000 (15:43 +0800)]
tools: Sync 'install.sh' options with install(1)

The 'install.sh' script should recognize all install(1) options so as to
ignore them.  Sync it with install(1) which has gained several new
options since.

To help future update, add a note in install(1)'s getopt() code to also
update the 'tools/install.sh' script. (credit to swildner)

3 years agodevfs: Add man page for devfs_{set,get,clear}_cdevpriv()
Aaron LI [Tue, 25 May 2021 04:28:29 +0000 (12:28 +0800)]
devfs: Add man page for devfs_{set,get,clear}_cdevpriv()

Derived from FreeBSD's devfs_set_cdevpriv.9 man page.

3 years agodevfs: Change typedef 'cdevpriv_dtr_t' to 'd_priv_dtor_t'
Aaron LI [Tue, 25 May 2021 04:15:34 +0000 (12:15 +0800)]
devfs: Change typedef 'cdevpriv_dtr_t' to 'd_priv_dtor_t'

The original 'cdevpriv_dtr_t' typedef was not able to be used in a
function prototype like the other d_xxx_t typedef's, because it declared
a function *pointer* rather than a function.  This makes it useless
outside the cdevpriv implementation.

Change the typedef to declare a function and rename it to
'd_priv_dtor_t', which is more consistent with other dev_ops methods,
although it's not a direct member in the dev_ops struct.

Obtained-from: FreeBSD (revision 291653)
URL: https://reviews.freebsd.org/D4340

3 years agokernel - Add vm_page_alloczwq()/vm_page_freezwq(), refactor comments
Matthew Dillon [Fri, 18 Jun 2021 07:02:11 +0000 (00:02 -0700)]
kernel - Add vm_page_alloczwq()/vm_page_freezwq(), refactor comments

* Add two functions to help support nvmm.

* Refactor comments for vm_page_alloc(), vm_page_grab().

* Rename a few variables for consistency.

3 years agokernel - Document vm_map_wire() and vm_map_unwire()
Matthew Dillon [Fri, 18 Jun 2021 02:48:19 +0000 (19:48 -0700)]
kernel - Document vm_map_wire() and vm_map_unwire()

* The names chosen are just horrid.  Document the problem.  Don't rename
  the functions quite yet.

3 years agomfiutil(8): Fix building with -DDEBUG.
Sascha Wildner [Thu, 17 Jun 2021 20:03:52 +0000 (22:03 +0200)]
mfiutil(8): Fix building with -DDEBUG.

3 years agosys/vfs/hammer2: Remove unused hammer2_flush_info::debug
Tomohiro Kusumi [Sun, 13 Jun 2021 16:12:07 +0000 (01:12 +0900)]
sys/vfs/hammer2: Remove unused hammer2_flush_info::debug

No longer used since 850d3f60f0a03e7a3f08357489acac749d6224ca in 2017.
Remove the entire "hammer2_debug & 0x200" code around this as well.

3 years agosysconf.3: Point out that -1 may be returned even if the call succeeded.
Sascha Wildner [Tue, 15 Jun 2021 15:28:42 +0000 (17:28 +0200)]
sysconf.3: Point out that -1 may be returned even if the call succeeded.

3 years agosysconf.3: Remove wrong info about "minimum maximum" values.
Sascha Wildner [Tue, 15 Jun 2021 14:52:45 +0000 (16:52 +0200)]
sysconf.3: Remove wrong info about "minimum maximum" values.

_SC_STREAM_MAX and _SC_TZNAME_MAX do not return the lower bounds of
the respective maximum limits as the manual page claims, but instead
the actual maximum values.

See the table here:
https://pubs.opengroup.org/onlinepubs/9699919799/functions/sysconf.html

What the manual page is really thinking of are _POSIX_STREAM_MAX and
_POSIX_TZNAME_MAX. But those are not retrievable with sysconf(), as
there are no corresponding _SC_* constants for them.

While here, fix a typo (types -> bytes).

3 years agohammer2 - Fix growfs issue with multi-volume support + one other bug
Matthew Dillon [Mon, 14 Jun 2021 20:16:59 +0000 (13:16 -0700)]
hammer2 - Fix growfs issue with multi-volume support + one other bug

* A hammer2 filesystem versioned for multi-volume support checks
  voldata.total_size, but growfs was never modified to adjust
  the total_size field.

  Fix this by having growfs properly adjust the total_size field.

* An older bug... growfs was not zeroing any new volume headers
  when extending the filesystem in such a way as additional volume
  headers are needed.

  Fix by properly zeroing these headers (mount will complain until
  hammer2 cycles through all four but that's ok).

* Also fix an older bug, modifications to only the volume header could
  be flushed without bumping mirror_tid, causing confusion later
  on if the filesystem is unmounted and remounted.

  Fix this by having hammer2_voldata_modify() set mirror_tid in the
  vchain in the same manner that hammer2_chain_modify() does for
  a chain.  e.g.:

  hmp->vchain.bref.mirror_tid = hmp->voldata.mirror_tid + 1;

3 years agohammer2 - Do not exit on a bad volume header if others are good
Matthew Dillon [Mon, 14 Jun 2021 19:58:22 +0000 (12:58 -0700)]
hammer2 - Do not exit on a bad volume header if others are good

* Do not exit if a bad volume header is encountered if others
  are good.  We only punt if none of the four volume headers is
  good.

  The point of having four is to be able to mount / access the filesystem
  even if one has become corrupted.

3 years agogetconf(1): Add _POSIX_V7_* names, as aliases for POSIX_V7_*.
Sascha Wildner [Sun, 13 Jun 2021 11:03:04 +0000 (13:03 +0200)]
getconf(1): Add _POSIX_V7_* names, as aliases for POSIX_V7_*.

The standard is indeed ambiguous about whether the confstr(3) related
POSIX_Vx_* names shall have a leading underscore or not. I think the
intention is to follow the specified rule:

"The names of the symbolic constants used as the name argument of the
 confstr() function in the System Interfaces volume of POSIX.1-2017,
 without the _CS_ prefix."

But in its description of the -v option it uses leading underscores.

3 years agoconfstr(3): Add minimal support for V[67]_ENV.
Sascha Wildner [Sun, 13 Jun 2021 10:55:59 +0000 (12:55 +0200)]
confstr(3): Add minimal support for V[67]_ENV.

_CS_V6_ENV and _CS_V7_ENV were both added in Issue 7 of the standard.
Issue 6 did not have _CS_V6_ENV.

Right now they are empty. We'll see if more is needed in the future,
but I doubt it.

3 years agosysconf.3: Document more constants.
Sascha Wildner [Sun, 13 Jun 2021 01:27:35 +0000 (03:27 +0200)]
sysconf.3: Document more constants.

Taken-from: {Free,Net,Open}BSD

3 years agosysconf.3: Separate standard and non-standard constants.
Sascha Wildner [Sat, 12 Jun 2021 23:09:50 +0000 (01:09 +0200)]
sysconf.3: Separate standard and non-standard constants.

3 years agoahci - Document more loader.conf variables
Matthew Dillon [Sat, 12 Jun 2021 19:39:11 +0000 (12:39 -0700)]
ahci - Document more loader.conf variables

* Document additional loader.conf variables available for
  forcing 3 GBits and 6 GBits.  In particular, it is sometimes
  convenient to force 3 GBits on mini-PC's using unshielded ribbon
  cables to avoid comm errors.

    hint.ahci.force150=1
    hint.ahci.force300=1 <--- very useful sometimes
    hint.ahci.force600=1

3 years agosys/vfs/hammer2: Remove unused hammer2_thread::depth
Tomohiro Kusumi [Sat, 12 Jun 2021 19:06:59 +0000 (04:06 +0900)]
sys/vfs/hammer2: Remove unused hammer2_thread::depth

No longer used since 01d71aa5538cba09383737ddbea2fb05e1e75e78 in 2015.

3 years agosys/vfs/hammer2: Remove unused hammer2_pfs::lock_nlink
Tomohiro Kusumi [Sat, 12 Jun 2021 18:22:00 +0000 (03:22 +0900)]
sys/vfs/hammer2: Remove unused hammer2_pfs::lock_nlink

No longer used since cf1b3fafd1f08bd3a18fc9af3c431c48f600eb32 in 2016.

3 years agosys/vfs/hammer2: Remove unused rdok/wrok helper inline functions
Tomohiro Kusumi [Sat, 12 Jun 2021 15:03:06 +0000 (00:03 +0900)]
sys/vfs/hammer2: Remove unused rdok/wrok helper inline functions

Appeared in 23c7c7dd4e59da5bdb6ffa7fe2074c5b7ffe5e4f in 2015,
but never used for anything.

3 years agosys/vfs/hammer2: Remove nonexistent struct name
Tomohiro Kusumi [Fri, 11 Jun 2021 18:32:28 +0000 (03:32 +0900)]
sys/vfs/hammer2: Remove nonexistent struct name

struct hammer2_span never existed.
struct hammer2_msg was removed in 3a5aa68f9b693d86f3b5d5ac9191035f09d18b3e in 2012.
struct hammer2_cluster and hammer2_thread don't need to be declared here.

3 years agosys/vfs/hammer2: Remove unused hammer2_worker_rmask
Tomohiro Kusumi [Fri, 11 Jun 2021 17:30:11 +0000 (02:30 +0900)]
sys/vfs/hammer2: Remove unused hammer2_worker_rmask

No longer used since d38955556cc42394a330f93ed9dfd1906a476776 in 2021.

3 years agosys/vfs/hammer2: Remove unused (add used) header includes
Tomohiro Kusumi [Fri, 11 Jun 2021 17:16:25 +0000 (02:16 +0900)]
sys/vfs/hammer2: Remove unused (add used) header includes

3 years agodebug - Adjust ncptrace
Matthew Dillon [Fri, 11 Jun 2021 05:27:06 +0000 (22:27 -0700)]
debug - Adjust ncptrace

* Adjust ncptrace w/recent work so it compiles again.

3 years agohammer2 - Fix deadlock and improve performance
Matthew Dillon [Fri, 11 Jun 2021 03:18:16 +0000 (20:18 -0700)]
hammer2 - Fix deadlock and improve performance

* hammer2_xop_start*() is supposed to split the worker threads
  into two groups, one for strategy XOPs and the other for non-strategy
  XOPs.

  However, due to a bug in the code it was *NOT* doing this, possibly
  leading to VOP/STRATEGY deadlocks under heavy loads.  That is,
  XOP worker threads could received a strategy XOP while blocked on a VOP
  XOP and deadlock.

* Possibly related to bug reports of systems locking up during
  the overnight periodic (which find /'s a lot).  This may fix these
  issues.

* Also refactor the thread-selection algorithm.  Filesystems with
  nclusters == 1 (which is all of them at the moment) do not have
  to serialize XOPs based on the inode (sending the XOP to another
  thread, most likely), and instead they can just push the XOP to a
  worker thread on the current cpu.

  This significantly reduces IPI signaling and reduces I/O latency,
  but at the cost of reduced streaming decompression performance
  since the decompression from a single user thread is not distributed
  across multiple CPUs.

  I might be able to improve this later by explicitly sending read-ahead
  strategy XOPs to other CPUs, but for now I just want to create a sane
  world.

* In addition, change the number of worker threads per cpu per H2 mount
  to at least 4, half of which are dedicated to strategy XOPs and the
  other half to VOP XOPs.

  This allows strategy XOPs to read-ahead and stream the actual block
  I/O a whole lot better, and also allows multiple VOP XOPs issued on the
  same CPU (e.g. from several user threads that happened to be scheduled
  to the same cpu) to issue I/O and block without serializing.

  Finally, note that even though the XOP messaging is doing thread switches,
  it is happening between threads on the same CPU which is actually pretty
  quick, typically no more than 2uS or so for the round-trip.

3 years agotmpfs - Fix lost vnode reference due to race
Matthew Dillon [Fri, 11 Jun 2021 03:16:15 +0000 (20:16 -0700)]
tmpfs - Fix lost vnode reference due to race

* Under certain race conditions when a vget() fails and must
  retry, the vnode is not completely unwound and an extra ref
  is left on it.

* Can cause files in tmpfs to build-up and eat space even if deleted.

* Relatively rare.

3 years agolibc - Fix intermediate path elements if used in shm_open() (2)
Matthew Dillon [Fri, 11 Jun 2021 00:07:45 +0000 (17:07 -0700)]
libc - Fix intermediate path elements if used in shm_open() (2)

* Fix mistake made in /etc/rc.d/mounttmpfs last commit, the
  dev/shm sub-tree goes under /var/run/shm, not /var/run/shm/tmp.

3 years agosysconf.3: Add _SC_HOST_NAME_MAX
Antonio Huete Jimenez [Wed, 9 Jun 2021 22:24:46 +0000 (00:24 +0200)]
sysconf.3: Add _SC_HOST_NAME_MAX

Taken-from: FreeBSD

3 years agopw_scan: remove checks for (u|g)ids > USHRT_MAX.
Dan Cross [Fri, 21 May 2021 15:09:40 +0000 (15:09 +0000)]
pw_scan: remove checks for (u|g)ids > USHRT_MAX.

Remove the check and simplify the logic for checking
UID/GID validity in `pw_scan()` by calling `strtonum`
instead of `strtoul`.

I ran into this because I use a non-default UID/GID
numbering scheme where both are typically greater
than 2^16 for normal users.  The width of UIDs has
been 32 bits since before 4.4BSD in 1994, almost 27
years ago; if larger UIDs were going to show up as
a problem it would have already happened.

Signed-off-by: Dan Cross <cross@gajendra.net>
3 years agomtree: Use spaces to indent.
Sascha Wildner [Wed, 9 Jun 2021 14:37:16 +0000 (16:37 +0200)]
mtree: Use spaces to indent.

3 years agokernel - Make sure nl_dvp is non-NULL in a few situations
Matthew Dillon [Tue, 8 Jun 2021 21:34:40 +0000 (14:34 -0700)]
kernel - Make sure nl_dvp is non-NULL in a few situations

* When NLC_REFDVP is set, nl_dvp should be returned non-NULL
  when the nlookup succeeds.

  However, there is one case where nlookup() can succeed but nl_dvp
  can be NULL, and this is when the nlookup() represents a
  mount-point.

* Fix three instances where this case was not being checked and
  could lead to a NULL pointer dereference / kernel panic.

* Do the full resolve treatment for cache_resolve_dvp().  In
  null-mount situations where we have A/B and we null-mount B onto C,
  path resolutions of C via the null mount will resolve B but
  not resolve A.

  This breaks an assumption that nlookup() and cache_dvpref()
  make about the parent ncp having a valid vnode.  In fact, the
  parent ncp of B (which is A) might not, because the resolve
  path for B may have bypassed it due to the presence of the null
  mount.

* Should fix occassional 'mkdir /var/cache' calls that fail with
  EINVAL instead of EEXIST.

Reported-by: zach
3 years agolibc - Fix intermediate path elements if used in shm_open()
Matthew Dillon [Tue, 8 Jun 2021 21:25:01 +0000 (14:25 -0700)]
libc - Fix intermediate path elements if used in shm_open()

* Our shm_open() places the path relative to /var/run/shm, but if
  the directory structure for miscellaneous prefixes (such as
  "/tmp/blahblah", "/dev/shm/blahblah", etc) do not exist under
  /var/run/shm then shm_open() fails when it should not.

* Change shm_open() to automatically create any intermediate directory
  elements under /var/run/shm/ that are missing.  The elements will
  be created mode 1777.

* Fixes chromium-90 and any other packages that still use directory
  prefixes in shm_open() calls.

3 years agolibc - Add mkdirat() to the namespace
Matthew Dillon [Tue, 8 Jun 2021 21:24:09 +0000 (14:24 -0700)]
libc - Add mkdirat() to the namespace

* Add mkdirat() / _mkdirat() to the namespace (will be used by
  gen/posixshm.c).

3 years agomtree - Pre-create a few more dirs under /var/run/shm
Matthew Dillon [Tue, 8 Jun 2021 21:22:36 +0000 (14:22 -0700)]
mtree - Pre-create a few more dirs under /var/run/shm

* We already pre-create /var/run/shm/tmp, also pre-create
  /var/run/shm/dev/shm.  As with tmp, modes 1777.  This is just
  so prefixes commonly used in shm_open() (particularly in older
  code) have intermediate directories owned by root.

3 years agokernel/kern_sig.c: Tabify, remove end of line whitespace, etc.
Sascha Wildner [Sun, 6 Jun 2021 22:08:29 +0000 (00:08 +0200)]
kernel/kern_sig.c: Tabify, remove end of line whitespace, etc.

3 years agokernel: In proc_{,un}stop(), use a better name for the process state argument.
Sascha Wildner [Sun, 6 Jun 2021 21:42:20 +0000 (23:42 +0200)]
kernel: In proc_{,un}stop(), use a better name for the process state argument.

It has nothing to do with signals.

3 years agosys/vfs/hammer2: Remove duplicate M_OBJCACHE definition
Tomohiro Kusumi [Sat, 5 Jun 2021 17:25:01 +0000 (02:25 +0900)]
sys/vfs/hammer2: Remove duplicate M_OBJCACHE definition

3 years agosys/vfs/hammer2: Remove unused struct hammer2_sync_info
Tomohiro Kusumi [Sat, 5 Jun 2021 17:12:10 +0000 (02:12 +0900)]
sys/vfs/hammer2: Remove unused struct hammer2_sync_info

Unused since ecfe89b8868b30c9ddfa9c86cb4b0a20365a248d in 2018.

3 years agoedk2: Sync our TianoCore EDK II headers with the edk2-stable202105 tag.
Sascha Wildner [Sat, 5 Jun 2021 03:05:54 +0000 (05:05 +0200)]
edk2: Sync our TianoCore EDK II headers with the edk2-stable202105 tag.

Nothing of importance to us.

3 years agoSync ACPICA with Intel's version 20210604.
Sascha Wildner [Sat, 5 Jun 2021 02:58:39 +0000 (04:58 +0200)]
Sync ACPICA with Intel's version 20210604.

* Fixes and cleanups.

* Add PlatformRtMechanism OperationRegion handler support.

* Add support for various tables.

For a detailed list, please see sys/contrib/dev/acpica/changes.txt.

3 years agodsynth.1: Oops, fix sorting.
Sascha Wildner [Thu, 3 Jun 2021 10:08:12 +0000 (12:08 +0200)]
dsynth.1: Oops, fix sorting.

3 years agodsynth.1: Add -P to the SYNOPSIS.
Sascha Wildner [Thu, 3 Jun 2021 10:04:12 +0000 (12:04 +0200)]
dsynth.1: Add -P to the SYNOPSIS.

3 years agokernel - Remove KVA_PAGES (no longer used)
Matthew Dillon [Tue, 1 Jun 2021 02:52:25 +0000 (19:52 -0700)]
kernel - Remove KVA_PAGES (no longer used)

* KVA_PAGES is a throw-back to 32-bit systems which we no longer support.
  Remove it entirely.

  The current platform for 64-bit systems uses NKPML4E to specify the
  number of PML4E entries to use for KVM.  Set to 16 (8TB), a value
  high enough that we just don't have to worry about it any more.

Reported-by: Aaron Li
3 years agoamdtemp - Fix family 0x17 support, add family 0x19 support (3)
Matthew Dillon [Tue, 1 Jun 2021 02:52:07 +0000 (19:52 -0700)]
amdtemp - Fix family 0x17 support, add family 0x19 support (3)

* Remove 0x18 from amdsmn as well.