dragonfly.git
3 years agopmap: Implement pmap_npt_transform() for NVMM
Aaron LI [Sun, 6 Jun 2021 12:06:59 +0000 (20:06 +0800)]
pmap: Implement pmap_npt_transform() for NVMM

This function will transform an initialized pmap structure for use by
NVMM's AMD SVM backend.

AMD's NPT (nested page table), aka RVI (rapid virtualization indexing)
implementation is more complete than Intel's EPT; it supports A/D bits
and uses the same bits positions as native x86 page tables.  So this
function is a simplified version of pmap_ept_transform().

3 years agopc64/vmm: Use pmap_ept_transform() to simplify EPT code
Aaron LI [Sun, 6 Jun 2021 04:51:50 +0000 (12:51 +0800)]
pc64/vmm: Use pmap_ept_transform() to simplify EPT code

3 years agopmap: Implement pmap_ept_transform() for NVMM
Aaron LI [Sun, 6 Jun 2021 03:30:13 +0000 (11:30 +0800)]
pmap: Implement pmap_ept_transform() for NVMM

The pmap_ept_transform() transforms an initialized pmap structure to be
EPT type for Intel VMX hypervisor (e.g., NVMM) use.  This implementation
is derived from vmx_ept_init() and vmx_ept_pmap_pinit() in
'pc64/vmm/ept.c'.

Note that this function has a different prototype as NetBSD's one,
because we don't make 'pmap_ept_has_ad' a global variable so we need to
pass extra flags to the pmap.

When zeroing out the page directories, note that the valid area is two
pages if there is a pm_pmlpv_iso PTE installed (i.e., the system has
meltdown mitigation enabled), otherwise, it's only one page.  (credit to
Matt Dillon)

3 years agonvmmctl(8): Rewrite makefile and hook to build
Aaron LI [Tue, 25 May 2021 23:43:54 +0000 (07:43 +0800)]
nvmmctl(8): Rewrite makefile and hook to build

3 years agonvmmctl(8): Port to DragonFly
Aaron LI [Tue, 25 May 2021 23:43:29 +0000 (07:43 +0800)]
nvmmctl(8): Port to DragonFly

* Adjust header inclusions
* Add 'XCR0_FLAGS1' macro define
* Add several '__unused' attributes
* Rename '__dead' to '__dead2'

3 years agolibnvmm: Adapt to also build on NetBSD
Aaron LI [Sat, 12 Jun 2021 10:11:10 +0000 (18:11 +0800)]
libnvmm: Adapt to also build on NetBSD

Adapt the libnvmm code to build and work on both DragonFly and NetBSD.
So it can help debug the porting issues.

3 years agolibnvmm: Fix mmap() failure with 'permission denied'
Aaron LI [Sun, 30 May 2021 23:25:14 +0000 (07:25 +0800)]
libnvmm: Fix mmap() failure with 'permission denied'

The mmap() in nvmm_vcpu_create() was always failing with the EACCES
(permission denied) error code.  It was because mmap() was requesting
prot = PROT_READ|PROT_WRITE and flags = MAP_SHARED, but the fd was
opened with O_RDONLY (or O_WRONLY in nvmm_root_init()) and thus
disallowed such a mmap request.

Fix this issue by opening the nvmm fd with O_RDWR flag.  This also
requires to change the mode of '/dev/nvmm' from 0640 to 0660.
However, this makes root owner distinguishing in nvmm kernel module
useless.  So change to identify root owner by checking whether the
caller has root privilege.

In addition, refactor nvmm_root_init() to also check for root privilege
first and then call nvmm_init().

3 years agolibnvmm: Update makefiles and hook to build
Aaron LI [Sun, 9 May 2021 23:05:43 +0000 (07:05 +0800)]
libnvmm: Update makefiles and hook to build

3 years agolibnvmm: Port to DragonFly
Aaron LI [Sun, 9 May 2021 23:05:16 +0000 (07:05 +0800)]
libnvmm: Port to DragonFly

* Add 'nvmm_compat.h' to adapt some macros/constants for DragonFly.
* Add some '__unused' attributes to fix compilation warnings/errors.
* Adjust header inclusions.
* Update nvmm(4) kernel source path in the man page, also update
  'struct nvmm_x64_state' to match DragonFly's version.

3 years agonvmm: Improve makefile to allow standalone build
Aaron LI [Sat, 29 May 2021 15:14:06 +0000 (23:14 +0800)]
nvmm: Improve makefile to allow standalone build

This change makes the nvmm kernel module is buildable in its own
directory.  This helps debug the module.

3 years agonvmm: Rewrite makefiles and hook to build
Aaron LI [Sun, 9 May 2021 23:35:35 +0000 (07:35 +0800)]
nvmm: Rewrite makefiles and hook to build

Note that kernel header files are install by the top-level
'include/Makefile'.  However, it will install all found header
files in the specified directories, including 'nvmm_compat.h'
and 'nvmm_internal.h'.  Therefore, add a guard to prevent them
from including by userland utilities (e.g., libnvmm, nvmmctl).

3 years agonvmm: Add to sys/conf/files and LINT64
Aaron LI [Sun, 9 May 2021 23:17:27 +0000 (07:17 +0800)]
nvmm: Add to sys/conf/files and LINT64

Meanwhile, remove the unused 'files.nvmm'.

3 years agonvmm: Port to DragonFly #23: header inclusion adjustments
Aaron LI [Sun, 23 May 2021 10:52:45 +0000 (18:52 +0800)]
nvmm: Port to DragonFly #23: header inclusion adjustments

3 years agonvmm: Port to DragonFly #22: pmap EPT/NPT base address
Aaron LI [Sun, 23 May 2021 10:21:31 +0000 (18:21 +0800)]
nvmm: Port to DragonFly #22: pmap EPT/NPT base address

Replace NetBSD's pmap->pm_pdirpa[0] with our vtophys(pmap->pm_pml4).

In addition, use vmspace_pmap() to grab the pmap, which is more
consistent with other code in our code base.

3 years agonvmm: Port to DragonFly #21: virtual address space management
Aaron LI [Sun, 23 May 2021 10:13:54 +0000 (18:13 +0800)]
nvmm: Port to DragonFly #21: virtual address space management

Adapt the following NetBSD UVM functions to DragonFly:

* uvmspace_alloc() -> vmspace_alloc()
* uvmspace_free() -> vmspace_rel()
* uvm_fault() -> vm_fault()
* uvm_map() -> vm_map_insert() + vm_map_inherit() + vm_map_madvise() ...
* uvm_map_pageable() -> vm_map_wire()
* uvm_unmap(), uvm_deallocate() -> vm_map_remove()

To support the UVM_FLAG_FIXED & UVM_FLAG_UNMAP flags in uvm_map(),
vm_map_delete() is called unconditionally to make room fot the coming
new mapping.  Note that vm_map_findspace() cannot be called in this case,
because it's not guaranteed to return the input hint address if the
hint range is available.

Use vm_map_wire() to wire/unwire the mapping; vm_map_unwire() is for
userland mlock operations.

In uvm_deallocate(), need to unwire kernel page before remove, because
vm_map_remove() only handles user wirings.

Reviewed-by: Matt Dillon
3 years agonvmm: Port to DragonFly #20: preemption & critical section
Aaron LI [Sat, 22 May 2021 13:58:44 +0000 (21:58 +0800)]
nvmm: Port to DragonFly #20: preemption & critical section

In DragonFly, a normal kernel thread will not migrate to another CPU or be
preempted (except by an interrupt thread), so kpreempt_{disable,enable}()
are not needed.  However, we can't use critical section as an instead,
because that would also prevent interrupt/reschedule flags from being
set, which would be a problem for nvmm_return_needed() that's called from
vcpu_run() loop.  (credit to Matt Dillon)

Port nvmm_return_needed() to DragonFly.  But note that the
*_resched_wanted() functions cannot be used in critical sections, which
would prevent the relevant flags from being set.  (credit to Matt Dillon)

Port splhigh()/splx() as critical sections in DragonFly for the moment.
Don't worry about it unless we have issues with it later.

3 years agonvmm: Port to DragonFly #19: IPI cross-cpu calls
Aaron LI [Sat, 22 May 2021 08:28:48 +0000 (16:28 +0800)]
nvmm: Port to DragonFly #19: IPI cross-cpu calls

Replace NetBSD xcall(9) API by our lwkt_send_ipiq() and
lwkt_send_ipiq_mask() to unicast/broadcast a function call to one/all
CPUs.

In DragonFly, a normal kernel thread won't migrate to another CPU,
so no need to implement NetBSD's curlwp_bind() and curlwp_bindx().

3 years agonvmm: Port to DragonFly #18: kernel memory allocation
Aaron LI [Sat, 22 May 2021 04:03:06 +0000 (12:03 +0800)]
nvmm: Port to DragonFly #18: kernel memory allocation

Use kmem_alloc() and kmem_free() to implement uvm_km_alloc() and
uvm_km_free() as they're used in svm_vcpu_create() and vmx_vcpu_create().
However, our kmem_alloc() may return 0 (i.e., allocation failure), so
need an extra check in the caller functions.

Since we've defined 'kmem_alloc' and 'kmem_free' macros to adapt
NetBSD's functions to use our kmalloc() and kfree().  Therefore, extra
parentheses are added around 'kmem_alloc' and 'kmem_free' to avoid macro
expansion, so the original functions would be called.

In addition, change the 'kmem_free()' to 'uvm_km_free()' in
vmx_vcpu_create(), aligning with the invocation pattern as well as
the use case in svm_vcpu_create().

3 years agonvmm: Port to DragonFly #17: physical page allocation
Aaron LI [Fri, 21 May 2021 15:19:46 +0000 (23:19 +0800)]
nvmm: Port to DragonFly #17: physical page allocation

Implement uvm_pagealloc() and uvm_pagefree() with vm_page_alloczwq() and
vm_page_freezwq(), respectively, which are added for this purpose by
Matt Dillon in 14067db606f14f728f62891ebcdc30366e95aa3d.

These two functions are used in 'nvmm_x86_svm.c' to allocate the HSAVE
memory.

3 years agonvmm: Port to DragonFly #16: contiguous memory allocation
Aaron LI [Fri, 21 May 2021 14:39:59 +0000 (22:39 +0800)]
nvmm: Port to DragonFly #16: contiguous memory allocation

svm_memalloc() and vmx_memalloc() need to allocate memory block that's
both virtually contiguous and physically contiguous.  NetBSD achieves
this requirement by first allocating a list of physically contiguous
pages and a virtually contiguous memory address, and then mapping them
page by page.

We can just use contigmalloc(9) to achieve the same goal.

3 years agonvmm: Port to DragonFly #15: anonymous object management
Aaron LI [Wed, 19 May 2021 10:52:22 +0000 (18:52 +0800)]
nvmm: Port to DragonFly #15: anonymous object management

Implement compat code for NetBSD anonymous object management:
uao_create(), uao_reference() and uao_detach().

The created object should be pageable by default, for example, the
object of guest physical memory.  So choose the default pager to create
the anonymous object.

If the object needs to be wired (e.g., the object for communicating
between kernel and userland), the uvm_map_pageable() can be called to
wire the object.

3 years agonvmm: Port to DragonFly #14: device & module operations
Aaron LI [Tue, 18 May 2021 06:05:40 +0000 (14:05 +0800)]
nvmm: Port to DragonFly #14: device & module operations

Replace NetBSD 'cdevsw' and 'fileops' structs with our 'dev_ops' struct,
and port NVMM to support both device open/close and module load/unload
operations.

NetBSD doesn't support cloning device, so it clones the file descriptor
(fd_clone() function) of the opened device (/dev/nvmm) and reassociates
it to the current process.  So that each process sees a separate
instance of the device.  See also NetBSD 'sys/net/if_tap.c' for an
example with detailed explanation on this mechansim.

DragonFly supports per-file-descriptor data with the devfs cdevpriv API,
which is much simpler than the method with autoclone device.

Also credit to Jaromír Doleček for his porting work of NVMM to DragonFly.
See: https://github.com/Moritz-Systems/DragonFlyBSD/commit/b96e5836fd25b448bb54775ac0107917adc2937d

3 years agonvmm: Port to DragonFly #13: debug register save & restore
Aaron LI [Sun, 16 May 2021 09:18:00 +0000 (17:18 +0800)]
nvmm: Port to DragonFly #13: debug register save & restore

Derived from NetBSD's x86_dbregs_save()/x86_dbregs_restore() in
'sys/arch/x86/x86/dbregs.c'.

3 years agonvmm: Port to DragonFly #12: FPU save & restore
Aaron LI [Tue, 25 May 2021 06:40:41 +0000 (14:40 +0800)]
nvmm: Port to DragonFly #12: FPU save & restore

Note that the host FPU state is indeterminant and depends on whether
the user program used the FPU or not, so there might not be any state to
save.  npxpush() and npxpop() can handle this.  Accordingly, need to use
'mcontext_t' to store host FPU state.

At first I used fpu_area_save() and fpu_area_restore() to deal with the
host FPU state, but it caused a hard fault loop when trying to boot an
OS in QEMU, because it failed to handle an uninitialized FPU.  Thanks
to Matt Dillon for tracking it down and fixing it.

Credit to FreeBSD vmm code: save_guest_fpustate(), restore_guest_fpustate()

3 years agonvmm: Port to DragonFly #11: CPU features
Aaron LI [Sat, 15 May 2021 14:37:08 +0000 (22:37 +0800)]
nvmm: Port to DragonFly #11: CPU features

3 years agonvmm: Port to DragonFly #10: cpu_info etc.
Aaron LI [Fri, 14 May 2021 12:10:32 +0000 (20:10 +0800)]
nvmm: Port to DragonFly #10: cpu_info etc.

* Replace 'struct cpu_info' with 'struct globaldata'.
* Port cpu_info's ci_tss_sel/ci_tss/ci_gdt.
* Port curcpu(), cpu_number(), cpu_index() functions.
* Port CPU iteration code.

3 years agonvmm: Port to DragonFly #9: atomic operations
Aaron LI [Fri, 14 May 2021 00:09:58 +0000 (08:09 +0800)]
nvmm: Port to DragonFly #9: atomic operations

Add compat defines for NetBSD's atomic_inc_64(), atomic_{inc,dec}_uint().
However, we don't have an alternative for the type-generic
atomic_load_relaxed() function.  So just modify the code accordingly.

3 years agonvmm: Port to DragonFly #8: kcpuset(9) -> cpumask(9)
Aaron LI [Wed, 12 May 2021 23:25:59 +0000 (07:25 +0800)]
nvmm: Port to DragonFly #8: kcpuset(9) -> cpumask(9)

Translate NetBSD's kcpuset(9) API to our cpumask(9) API.  Use the atomic
version to avoid possible races between multiple vCPUs.

3 years agonvmm: Port to DragonFly #7: memory allocation
Aaron LI [Wed, 12 May 2021 23:23:04 +0000 (07:23 +0800)]
nvmm: Port to DragonFly #7: memory allocation

Add compat code to adapt NetBSD's kmem_alloc()/kmem_zalloc()/kmem_free().

3 years agonvmm: Port to DragonFly #6: mutex/rwlock
Aaron LI [Tue, 11 May 2021 23:16:23 +0000 (07:16 +0800)]
nvmm: Port to DragonFly #6: mutex/rwlock

Add compat code to adapt NetBSD's mutex and rwlock to use DragonFly's
lockmgr(9).

3 years agonvmm: Port to DragonFly #5: constants/functions/macros
Aaron LI [Sun, 30 May 2021 08:02:49 +0000 (16:02 +0800)]
nvmm: Port to DragonFly #5: constants/functions/macros

Update nvmm_compat.h to include various compat constant/functions
defines.

3 years agonvmm: Port to DragonFly #4: PAT modes
Aaron LI [Sun, 30 May 2021 08:01:24 +0000 (16:01 +0800)]
nvmm: Port to DragonFly #4: PAT modes

Adapt NetBSD's PATENTRY() and PAT_* modes to ours PAT_VALUE() and PAT_*
defines.

3 years agonvmm: Port to DragonFly #3: CR/MSR defines
Aaron LI [Tue, 11 May 2021 23:10:55 +0000 (07:10 +0800)]
nvmm: Port to DragonFly #3: CR/MSR defines

Add XCR0 and various MSRs compat defines.

3 years agonvmm: Port to DragonFly #2: CPUID Fn0000_000B for SVM
Aaron LI [Tue, 11 May 2021 23:03:56 +0000 (07:03 +0800)]
nvmm: Port to DragonFly #2: CPUID Fn0000_000B for SVM

Add CPUID Fn0000_000B (Extended Topology Enumeration) defines for SVM.

Obtained from NetBSD.

3 years agonvmm: Port to DragonFly #1: nvmm_x86_{svmfunc,vmxfunc}.S
Aaron LI [Tue, 11 May 2021 06:25:17 +0000 (14:25 +0800)]
nvmm: Port to DragonFly #1: nvmm_x86_{svmfunc,vmxfunc}.S

3 years agonvmm: Port to DragonFly #0: initial nvmm_compat.h
Aaron LI [Tue, 25 May 2021 06:39:10 +0000 (14:39 +0800)]
nvmm: Port to DragonFly #0: initial nvmm_compat.h

Add nvmm_compat.h to hold the major compatibility code for the porting.
Currently there are mostly CPUID2_* and CPUID_SEF_* defines.

Credit to Jaromír Doleček for his initial porting of NVMM to DragonFly.
See: https://github.com/Moritz-Systems/DragonFlyBSD/commit/b96e5836fd25b448bb54775ac0107917adc2937d

3 years agoAdd group 'nvmm' and GID_NVMM for nvmm(4) & nvmmctl(8)
Aaron LI [Sun, 9 May 2021 23:06:54 +0000 (07:06 +0800)]
Add group 'nvmm' and GID_NVMM for nvmm(4) & nvmmctl(8)

3 years agonvmm.4: Add HISTORY and hook to build
Aaron LI [Sun, 9 May 2021 23:03:31 +0000 (07:03 +0800)]
nvmm.4: Add HISTORY and hook to build

3 years agonvmm: Bring some minor changes from NetBSD-current
Aaron LI [Sun, 9 May 2021 22:52:17 +0000 (06:52 +0800)]
nvmm: Bring some minor changes from NetBSD-current

These changes help port NVMM to DragonFly by reducing the required
difference.

3 years agoImport nvmm.4 manpage from NetBSD 9-stable
Aaron LI [Wed, 5 May 2021 08:16:06 +0000 (16:16 +0800)]
Import nvmm.4 manpage from NetBSD 9-stable

Branch: NetBSD 9-stable
Date: Fri Apr 30 14:08:16 2021 +0000
Path: share/man/man4/nvmm.4

3 years agoImport nvmmctl(8) from NetBSD 9-stable
Aaron LI [Wed, 5 May 2021 08:06:40 +0000 (16:06 +0800)]
Import nvmmctl(8) from NetBSD 9-stable

This is a program to control NVMM(4) virtual machines.  It currently
implements the following two commands:
- identify: display the capabilities of the system.
- list: display information on each virtual machine registered in the
  system.

Branch: NetBSD 9-stable
Date: Fri Apr 30 14:08:16 2021 +0000
Path: usr.sbin/nvmmctl

3 years agoImport libnvmm(3) from NetBSD 9-stable
Aaron LI [Wed, 5 May 2021 07:58:32 +0000 (15:58 +0800)]
Import libnvmm(3) from NetBSD 9-stable

This is the virtualization API that provides a way for VMM software to
effortlessly create and manage virtual machines via NVMM(4).

Branch: NetBSD 9-stable
Date: Fri Apr 30 14:08:16 2021 +0000
Path: lib/libnvmm

3 years agoImport nvmm(4) from NetBSD 9-stable
Aaron LI [Wed, 5 May 2021 07:35:16 +0000 (15:35 +0800)]
Import nvmm(4) from NetBSD 9-stable

This is the kernel driver that provides support for hardware-accelerated
virtualization.  It is made of an MI frontend with the following two MD
backends:
- x86 Intel VMX
- x86 AMD SVM

Branch: NetBSD 9-stable
Date: Fri Apr 30 14:08:16 2021 +0000
Path: sys/dev/nvmm

3 years ago<sys/signal.h>: Put sig_t and sigmask() under __BSD_VISIBLE.
Sascha Wildner [Tue, 20 Jul 2021 16:01:52 +0000 (18:01 +0200)]
<sys/signal.h>: Put sig_t and sigmask() under __BSD_VISIBLE.

3 years agopam_passwdqc: Local modifications.
Sascha Wildner [Tue, 20 Jul 2021 14:53:51 +0000 (16:53 +0200)]
pam_passwdqc: Local modifications.

3 years agoMerge branch 'vendor/PAM_PASSWDQC'
Sascha Wildner [Tue, 20 Jul 2021 14:52:42 +0000 (16:52 +0200)]
Merge branch 'vendor/PAM_PASSWDQC'

3 years agoImport passwdqc 2.0.2 vendor/PAM_PASSWDQC
Sascha Wildner [Tue, 20 Jul 2021 14:50:57 +0000 (16:50 +0200)]
Import passwdqc 2.0.2

3 years agoopenpam: Push README.DELETED to master.
Sascha Wildner [Tue, 20 Jul 2021 14:46:18 +0000 (16:46 +0200)]
openpam: Push README.DELETED to master.

3 years agoImport OpenPAM Tabebuia.
Sascha Wildner [Tue, 20 Jul 2021 14:45:26 +0000 (16:45 +0200)]
Import OpenPAM Tabebuia.

Fixes an off-by-one in pam_getenv(3).

See HISTORY for the details.

3 years agosbin/hammer2: Print freemap leaf's linear offset when "show"
Tomohiro Kusumi [Sat, 17 Jul 2021 16:23:28 +0000 (01:23 +0900)]
sbin/hammer2: Print freemap leaf's linear offset when "show"

3 years agosys/vfs/hammer2: Fix compilation when HAMMER2_IO_DEBUG enabled
Tomohiro Kusumi [Thu, 15 Jul 2021 16:45:08 +0000 (01:45 +0900)]
sys/vfs/hammer2: Fix compilation when HAMMER2_IO_DEBUG enabled

No such field debug_data in struct hammer2_io.

3 years agosys/vfs/hammer2: #if0 incomplete HAMMER2_FREEMAP_{DOMAYFREE,DOREALFREE} related
Tomohiro Kusumi [Wed, 14 Jul 2021 16:12:28 +0000 (01:12 +0900)]
sys/vfs/hammer2: #if0 incomplete HAMMER2_FREEMAP_{DOMAYFREE,DOREALFREE} related

Disable related code in addition to already #if0'd parts.

Neither "how == HAMMER2_FREEMAP_DOMAYFREE" nor "how == HAMMER2_FREEMAP_DOREALFREE"
happen. Looks like these weren't completely implemented since first
appeared in 10136ab6cde1969ab6ca22168b2a10ed5d9cc557 in 2013.

3 years agosys/vfs/hammer2: Remove unused HAMMER2_XOP_IROOT
Tomohiro Kusumi [Mon, 12 Jul 2021 17:02:23 +0000 (02:02 +0900)]
sys/vfs/hammer2: Remove unused HAMMER2_XOP_IROOT

Never used since first appeared in 6f445d15835c6677a0a79c8d168ef44d0b9b22c3 in 2018.
Also remove a comment for nonexistent HAMMER2_XOP_RECURSE.

3 years agokernel/acpi: Adjust MADT revision check.
Sascha Wildner [Sat, 17 Jul 2021 09:02:22 +0000 (11:02 +0200)]
kernel/acpi: Adjust MADT revision check.

3 years agoUpdate the pciconf(8) database.
Sascha Wildner [Thu, 15 Jul 2021 03:53:32 +0000 (05:53 +0200)]
Update the pciconf(8) database.

July 5, 2021 snapshot from https://pci-ids.ucw.cz

3 years agolibstand: Unbreak buildworld.
Sascha Wildner [Tue, 13 Jul 2021 04:31:03 +0000 (06:31 +0200)]
libstand: Unbreak buildworld.

Oops, this was a stupid last minute mistake.

3 years agoMake stand/lib an internal one, i.e. don't install libstand anymore.
Sascha Wildner [Mon, 12 Jul 2021 14:36:07 +0000 (16:36 +0200)]
Make stand/lib an internal one, i.e. don't install libstand anymore.

Nothing in dports needs it either.

Also, leave the manual page.

3 years agoboot: Move boot source code /usr/src/stand.
Sascha Wildner [Mon, 12 Jul 2021 14:20:16 +0000 (16:20 +0200)]
boot: Move boot source code /usr/src/stand.

sys/boot becomes stand/boot and lib/libstand becomes stand/lib.

My main reason is to have boot out of the way when for example grepping
in sys/. It also makes more sense since it's not really userland or
kernel code.

Other BSDs have moved their boot/standalone code around too, but maybe
with different directory layouts.

Approved-by: dillon, zrj
3 years agosys/vfs/hammer2: Remove unused HAMMER2_OFFSET_{MIN,MAX}
Tomohiro Kusumi [Wed, 7 Jul 2021 17:18:06 +0000 (02:18 +0900)]
sys/vfs/hammer2: Remove unused HAMMER2_OFFSET_{MIN,MAX}

Never used since first appeared in 504565062f34ec55037ac0cf308fe3562f091460 in 2014.

3 years agoperiodic/whatis: Remove whatis(1) db rebuilding for localized manpages.
Sascha Wildner [Sun, 11 Jul 2021 10:01:53 +0000 (12:01 +0200)]
periodic/whatis: Remove whatis(1) db rebuilding for localized manpages.

makewhatis doesn't have an -L option since the switch to mandoc's version.

Besides, we don't have localized manual pages in base and also in dports
I couldn't find a trace of any.

3 years agoperiodic: Enable {daily,weekly,monthly,security}_show_badconfig by default.
Sascha Wildner [Sat, 10 Jul 2021 17:44:42 +0000 (19:44 +0200)]
periodic: Enable {daily,weekly,monthly,security}_show_badconfig by default.

It can be helpful and found an issue in a dports periodic script, so we
want this on, I guess. Our base scripts have been cleaned up to not error
on optional things like a missing accounting file when accounting is not
enabled, etc.

Reported-by: James Cook (falsifian)
3 years agoperiodic: Do not error with rc==2 for some optional stuff.
Sascha Wildner [Sat, 10 Jul 2021 17:40:39 +0000 (19:40 +0200)]
periodic: Do not error with rc==2 for some optional stuff.

* UFS accounting has to be enabled in rc.conf, and if it is not, the
  script should just do nothing.

* /etc/news.expire is just some backwards compatibility stuff, so
  don't worry if it doesn't exist.

3 years agoperiodic: Do not error with rc=2 when /etc/daily.local etc. don't exist.
Sascha Wildner [Sat, 10 Jul 2021 16:59:54 +0000 (18:59 +0200)]
periodic: Do not error with rc=2 when /etc/daily.local etc. don't exist.

These scripts are only for backwards compatibility and we could even
remove 999.* but for now, just stay silent and do nothing if they
don't exist.

3 years agouname.1: Add missing options to the usage.
Sascha Wildner [Thu, 8 Jul 2021 11:00:07 +0000 (13:00 +0200)]
uname.1: Add missing options to the usage.

Submitted-by: yellowrabbit2010
Dragonfly-bug: https://bugs.dragonflybsd.org/issues/3285

3 years agosys/vfs/hammer2: Use HAMMER2_IND_COUNT_XXX
Tomohiro Kusumi [Sun, 4 Jul 2021 17:32:28 +0000 (02:32 +0900)]
sys/vfs/hammer2: Use HAMMER2_IND_COUNT_XXX

3 years agosys/vfs/hammer2: HAMMER2_CHAIN_BMAP* should be HAMMER2_CHAIN_BLKMAP*
Tomohiro Kusumi [Sun, 4 Jul 2021 16:30:10 +0000 (01:30 +0900)]
sys/vfs/hammer2: HAMMER2_CHAIN_BMAP* should be HAMMER2_CHAIN_BLKMAP*

The freemap code uses "bmap" and "BMAP" for bitmap,
so these two macros should be "BLKMAP" as the comment implies.

3 years agonpx: Remove an unused typedef and clean up a bit
Aaron LI [Wed, 7 Jul 2021 01:12:43 +0000 (09:12 +0800)]
npx: Remove an unused typedef and clean up a bit

* Remove unused typedef bool_t
* Fix a minor typo: FXRSTR -> FXRSTOR
* Fix indentation
* Reorganize a bit

3 years agonpx: Fix inline ASM error in fpu_clean_state()
Aaron LI [Wed, 7 Jul 2021 14:54:03 +0000 (22:54 +0800)]
npx: Fix inline ASM error in fpu_clean_state()

I made a mistake in commit 6becaabbb80a1d1b37c868ce7f22fca2ef6a743f when
I changed it use 'fldz' in the inline ASM.  Fix it.

3 years agomknod(2): Allow for the creation of fifos with mknod() to satisfy POSIX.
Sascha Wildner [Wed, 7 Jul 2021 14:49:16 +0000 (16:49 +0200)]
mknod(2): Allow for the creation of fifos with mknod() to satisfy POSIX.

Calling mknod() and mknodat() with S_IFIFO shall be equivalent to
calling mkfifo() and mkfifoat().

Note that we ignore 'dev' if S_IFIFO is passed, like Linux does, but
different from what {Free,Net,Open}BSD do, which require it to be 0.
It's true that the standard leaves anything but 0 undefined for this
case but also note the standard's example which does indeed pass a
'dev' arg and doesn't take any precautions of initializing it:

https://pubs.opengroup.org/onlinepubs/9699919799/functions/mknod.html#tag_16_328_06

I don't think it makes any difference in practice, though.

Reported-by: DanDan
While here, fix the manual page's HISTORY a bit (taken from FreeBSD).

3 years agoperiodic/snapshot-hammer2: Change scarce free space handling slightly.
Sascha Wildner [Wed, 7 Jul 2021 14:07:37 +0000 (16:07 +0200)]
periodic/snapshot-hammer2: Change scarce free space handling slightly.

The idea is that whenever the user falls into free space shortage
situation, the "sliding window" of snapshots potentially continues
rolling forward, instead of becoming stuck into the past.

Submitted-by: Francis GUDIN
Dragonfly-bug: <https://bugs.dragonflybsd.org/issues/3287>

3 years agonpx: Use 64-bit version FXSAVE64/FXRSTOR64 and XSAVE64/XRSTOR64
Aaron LI [Mon, 5 Jul 2021 11:50:51 +0000 (19:50 +0800)]
npx: Use 64-bit version FXSAVE64/FXRSTOR64 and XSAVE64/XRSTOR64

Since DragonFly is 64-bit only, use the 64-bit version
FXSAVE64/FXRSTOR64 and XSAVE64/XRSTOR64.

The new FXSAVE64/FXRSTOR64 version represents FIP/FDP as 64-bit fields
(union fp_addr.fa_64), while the legacy FXSAVE/FXRSTOR version uses
split fields: 32-bit offset, 16-bit segment and 16-bit reserved field
(union fp_addr.fa_32).  The latter implies that the actual addresses are
truncated to 32 bits which is insufficient in modern programs.

Improve the inline ASM code a bit to use 'xsave64'/'xrstor64' names.
The extra 'area' variable is introduced to help avoid dereferencing
'void *' pointer.

Referred-to: NetBSD

3 years agonpx: Extend fpusave/fpurstor() to accept an XSAVE mask argument
Aaron LI [Tue, 6 Jul 2021 23:32:56 +0000 (07:32 +0800)]
npx: Extend fpusave/fpurstor() to accept an XSAVE mask argument

XSAVE/XRSTOR requires a mask argument that determines the
components/states to save/restore.  Thus this argument controls the
save area size.

Extend fpusave/fpurstor() functions to accept an XSAVE mask argument,
so the caller can choose the wanted components/states to save/restore
and knows the exact area size.

NVMM will use this feature.

3 years agonpx: Use 'fldz' in fpu_clean_state() to load dummy zero
Aaron LI [Tue, 6 Jul 2021 23:17:46 +0000 (07:17 +0800)]
npx: Use 'fldz' in fpu_clean_state() to load dummy zero

The 'fldz' instruction pushs +0.0 onto the FPU register stack.  Use it
to replace the 'dummy_variable' variable.

Referred-to: NetBSD

3 years agoffs.5 : ffs is the default filesystem for /boot only
Pierre-Alain TORET [Tue, 6 Jul 2021 20:24:05 +0000 (22:24 +0200)]
ffs.5 : ffs is the default filesystem for /boot only

3 years agoinetd: Adjust error message too (a la the removed fcntl one).
Sascha Wildner [Tue, 6 Jul 2021 19:16:53 +0000 (21:16 +0200)]
inetd: Adjust error message too (a la the removed fcntl one).

3 years agoinetd: Use pipe2() instead of pipe()/fcntl()/fcntl() combo.
Sascha Wildner [Tue, 6 Jul 2021 19:12:20 +0000 (21:12 +0200)]
inetd: Use pipe2() instead of pipe()/fcntl()/fcntl() combo.

3 years agofile: Update README.DRAGONFLY and config.h.
Sascha Wildner [Tue, 6 Jul 2021 19:07:55 +0000 (21:07 +0200)]
file: Update README.DRAGONFLY and config.h.

3 years agoMerge branch 'vendor/FILE'
Sascha Wildner [Tue, 6 Jul 2021 18:47:45 +0000 (20:47 +0200)]
Merge branch 'vendor/FILE'

3 years agovendor/file: upgrade from 5.39 to 5.40
Sascha Wildner [Tue, 6 Jul 2021 18:44:23 +0000 (20:44 +0200)]
vendor/file: upgrade from 5.39 to 5.40

For details, see ChangeLog.

3 years agolibmagic/mkmagic: Add generated header(s) to CLEANFILES.
Sascha Wildner [Tue, 6 Jul 2021 18:23:34 +0000 (20:23 +0200)]
libmagic/mkmagic: Add generated header(s) to CLEANFILES.

3 years agokernel/modules: Simplify a number of .PATHs in module Makefiles.
Sascha Wildner [Mon, 5 Jul 2021 10:09:58 +0000 (12:09 +0200)]
kernel/modules: Simplify a number of .PATHs in module Makefiles.

3 years ago<sys/sensors.h>: Include <sys/types.h> for timeval and int64_t.
Sascha Wildner [Mon, 5 Jul 2021 07:30:40 +0000 (09:30 +0200)]
<sys/sensors.h>: Include <sys/types.h> for timeval and int64_t.

While here, remove an unused define.

3 years agoworld - Add covid(1) utility and port manual page from netbsd (2)
Matthew Dillon [Sun, 4 Jul 2021 19:03:11 +0000 (12:03 -0700)]
world - Add covid(1) utility and port manual page from netbsd (2)

* Though perhaps one could say that the 512-byte page-table pages
  the VAX had were a kind of disease, no... we won't go there.

  Fix manual page, move to section 1, and it isn't vax-specific.

3 years agoworld - Add covid(1) utility and port manual page from netbsd
Matthew Dillon [Sun, 4 Jul 2021 18:58:21 +0000 (11:58 -0700)]
world - Add covid(1) utility and port manual page from netbsd

* Move from section (4) to section (1) and include a utility which
  dumps one of the genome sequences.  Just to put an exclamation
  mark on the amount of damage such an absurdly short genetic sequence
  can wreak on the world

3 years agoMakefile.inc1: Remove unneeded exists() checks.
Sascha Wildner [Sun, 4 Jul 2021 18:39:12 +0000 (20:39 +0200)]
Makefile.inc1: Remove unneeded exists() checks.

Just doing 'make' in /usr/src isn't used for building anymore for a long
time, and our targets don't really make sense with an incomplete sounrce
tree.

3 years agoMakefile.inc1: Put all backup related stuff under the NO_BACKUP check.
Sascha Wildner [Sun, 4 Jul 2021 18:33:36 +0000 (20:33 +0200)]
Makefile.inc1: Put all backup related stuff under the NO_BACKUP check.

Main effect is that /usr/obj/world_backup is no longer created when
NO_BACKUP is set.

3 years agosys/vfs/hammer2: #if0 unused HAMMER2_DIRHASH_{HIMASK,FORCED}
Tomohiro Kusumi [Sat, 3 Jul 2021 17:50:42 +0000 (02:50 +0900)]
sys/vfs/hammer2: #if0 unused HAMMER2_DIRHASH_{HIMASK,FORCED}

HIMASK was no longer used since e028fa747e9825425f74da7e9c57a50a82b48e82 in 2012.
FORCED bit was never used since first appeared in above commit.

Only LOMASK bits are relevant for dirent lookup.

3 years agosys/vfs/hammer2: Fix function name in xop kprintf's
Tomohiro Kusumi [Sat, 3 Jul 2021 16:54:09 +0000 (01:54 +0900)]
sys/vfs/hammer2: Fix function name in xop kprintf's

3 years agolibc: Sync namespace.h and un-namespace.h a bit more pedantically.
Sascha Wildner [Sun, 4 Jul 2021 11:37:30 +0000 (13:37 +0200)]
libc: Sync namespace.h and un-namespace.h a bit more pedantically.

3 years agokernel: Staticize some variables.
Sascha Wildner [Sun, 4 Jul 2021 11:13:09 +0000 (13:13 +0200)]
kernel: Staticize some variables.

3 years agokernel/vm: Remove an unused variable.
Sascha Wildner [Sun, 4 Jul 2021 11:12:39 +0000 (13:12 +0200)]
kernel/vm: Remove an unused variable.

It is no longer needed since f2c2051ee473577d22178d55f782ceebbd88d58f.

3 years agokernel: Remove ndis(4) and associated tools and stuff.
Sascha Wildner [Sat, 3 Jul 2021 18:51:28 +0000 (20:51 +0200)]
kernel: Remove ndis(4) and associated tools and stuff.

ndis(4) was a wrapper to allow running binary Windows network
drivers that conformed to the Network Driver Interface Specification,
i.e. NDIS.

It only ever supported drivers from the days of Windows XP and
Windows Server 2003 (i.e. NDIS 5.1). And even if one was actually
able to extract the .sys and .inf files from the driver package and
successfully convert them to a building module, which both were
adventures in itself, it could be any result when trying to run it,
depending on the card and driver, from resonably working to not
working, even crashing. But it did work for some cards, so it had
some limited merit in its time.

NetBSD removed it in 2018, FreeBSD in January 2021, so let's follow
suit now.

3 years agowpa_cli.8: command is actually optional.
Sascha Wildner [Sat, 3 Jul 2021 13:04:02 +0000 (15:04 +0200)]
wpa_cli.8: command is actually optional.

3 years agowpa_supplicant: Adjust READMEs.
Sascha Wildner [Sat, 3 Jul 2021 11:28:31 +0000 (13:28 +0200)]
wpa_supplicant: Adjust READMEs.

3 years agoMerge branch 'vendor/WPA_SUPPLICANT'
Sascha Wildner [Sat, 3 Jul 2021 11:27:25 +0000 (13:27 +0200)]
Merge branch 'vendor/WPA_SUPPLICANT'

3 years agowpa_supplicant: Remove NDIS specific code on the vendor branch. vendor/WPA_SUPPLICANT
Sascha Wildner [Sat, 3 Jul 2021 11:26:40 +0000 (13:26 +0200)]
wpa_supplicant: Remove NDIS specific code on the vendor branch.

3 years agoipfw3nat: Fix indentation
Aaron LI [Sat, 3 Jul 2021 04:26:30 +0000 (12:26 +0800)]
ipfw3nat: Fix indentation

A follow-up to eb4c9e6d01df1803b884c6499ab99062a4453975.

3 years agonetinet6 - Add bridge test to ND6_RTENTRY_IS_NEIGHBOR()
Matthew Dillon [Fri, 2 Jul 2021 18:33:46 +0000 (11:33 -0700)]
netinet6 - Add bridge test to ND6_RTENTRY_IS_NEIGHBOR()

* Refactor ND6_RTENTRY_IS_NEIGHBOR() to get rid of
  the confusing double-negative.

* Change the IFP test to also allow the case where
  the route belongs to a bridge that the ifp is
  associated with.

* Fixes bogus "nd6_lookup: failed to lookup..." console messages.

3 years agonetinet6 - Fix 'not IPV6' console warning
Matthew Dillon [Fri, 2 Jul 2021 17:25:09 +0000 (10:25 -0700)]
netinet6 - Fix 'not IPV6' console warning

* Remove the ethernet header before issuing the icmp6_error()
  after an ARP (well, IPV6 equivalent) failure.

  Fixes a console warning.

3 years agohammer2 - Remove fhtovp debugging
Matthew Dillon [Fri, 2 Jul 2021 17:19:34 +0000 (10:19 -0700)]
hammer2 - Remove fhtovp debugging

* Remove kprintf() in fhtovp().