DragonFlyBSD/src 22b0532tools gitrev.sh

tools/gitrev.sh: Remove duplicate "cd" command

The 'cd $srcdir' was added in commit
f5a0be5909f64049304cc253123a5f9e4c5f38a3, which can cause the later
'cd $(dirname $0)' to fail, e.g.,

```
% sh ./sys/conf/../../tools/gitrev.sh
cd: ./sys/conf/../../tools: No such file or directory
$ bash ./sys/conf/../../tools/gitrev.sh
./sys/conf/../../tools/gitrev.sh: line 14: cd: ./sys/conf/../../tools: No such file or directory
```

The above invocation happens with:

```
$ env KERN_IDENT=XXX sh ./sys/conf/newvers.sh
```

So fix the issue by removing the duplicate "cd" command in gitrev.sh.
DeltaFile
+1-3tools/gitrev.sh
+1-31 files

DragonFlyBSD/src 26cefe5initrd/rescue Makefile, initrd/rescue.libcrypto Makefile

initrd: Enable WARNS=6 for building the final rescue exe

This is a follow-up change to my previous commit
b1c60d0b1c9b1260bca55b0ba511eca2ac8c522c.
DeltaFile
+0-4initrd/rescue/Makefile
+0-4initrd/rescue.libcrypto/Makefile
+0-82 files

DragonFlyBSD/src 1e0bc9finclude Makefile, sys/conf newvers.sh

include,newvers.sh: Tweak the awk command for RELDATE extraction
DeltaFile
+1-1sys/conf/newvers.sh
+1-1include/Makefile
+2-22 files

DragonFlyBSD/src a7533e1gnu/lib/gcc80/libstdc++/headers Makefile Makefile.headers, gnu/lib/gcc80/libstdcxx/headers Makefile Makefile.headers

gcc80: Revert the '++' to 'xx' renaming hack

Similar to the last commit for gcc120.
DeltaFile
+0-1,321gnu/lib/gcc80/libstdcxx/headers/config.h
+1,321-0gnu/lib/gcc80/libstdc++/headers/config.h
+0-870gnu/lib/gcc80/libstdcxx/headers/Makefile.headers
+870-0gnu/lib/gcc80/libstdc++/headers/Makefile.headers
+0-118gnu/lib/gcc80/libstdcxx/headers/Makefile
+118-0gnu/lib/gcc80/libstdc++/headers/Makefile
+2,309-2,30923 files not shown
+2,853-2,86329 files

DragonFlyBSD/src 7b15611gnu/lib/gcc120/libstdc++/components/libconv_1998 Makefile.src, gnu/lib/gcc120/libstdc++/headers Makefile.headers config.h

gcc120: Revert the '++' to 'xx' renaming hack

This hack [1] was introduced to work around the bug with bintuils AR/MRI
script that prevented using the '+' character in filenames.  That bug
has been fixed in upstream between binutils 2.38 and 2.39 and has been
backported to our in-base bintuils 2.34 and 2.27 [2][3].  So this
renaming hack is no longer needed.

However, a new problem appeared with libstdc++/product: mkdep(1) would
fail for the 'gnu11' file group with error:
```
.../gnu/lib/gcc120/libstdc++/product/../../../../../contrib/gcc-12/libstdc++-v3/src/c++11/compatibility-atomic-c++0x.cc:25:10: fatal error: gstdint.h: No such file or directory
   25 | #include "gstdint.h"
      |          ^~~~~~~~~~~
```

This problem didn't happen before because the source file
`compatibility-atomic-c++0x.cc` was copied and renamed to
`compatibility-atomic-cxx0x.cc` in ${.OBJDIR}, which was the same

    [10 lines not shown]
DeltaFile
+0-1,405gnu/lib/gcc120/libstdcxx/headers/config.h
+1,405-0gnu/lib/gcc120/libstdc++/headers/config.h
+0-1,067gnu/lib/gcc120/libstdcxx/headers/Makefile.headers
+1,067-0gnu/lib/gcc120/libstdc++/headers/Makefile.headers
+0-100gnu/lib/gcc120/libstdcxx/components/libconv_1998/Makefile.src
+100-0gnu/lib/gcc120/libstdc++/components/libconv_1998/Makefile.src
+2,572-2,57232 files not shown
+3,158-3,16838 files

DragonFlyBSD/src 8d6e451sys/dev/virtual/nvmm/x86 nvmm_x86_vmx.c nvmm_x86_svm.c

nvmm(4): Save debug registers to curthread's PCB

The PCB already has space for debug registers, so just use that area
instead of abusing the vCPU's host area.  This also reduces difference
with NetBSD.

Suggested-by: Maxime Villard (m00nbsd)
DeltaFile
+16-24sys/dev/virtual/nvmm/x86/nvmm_x86_internal.h
+2-5sys/dev/virtual/nvmm/x86/nvmm_x86_vmx.c
+2-5sys/dev/virtual/nvmm/x86/nvmm_x86_svm.c
+20-343 files

DragonFlyBSD/src 9bace06lib/libnvmm libnvmm_x86.c

libnvmm(3): Sync misc changes from m00nbsd

* Fix inverted comments.
* Read guest PTEs atomically.
DeltaFile
+16-14lib/libnvmm/libnvmm_x86.c
+16-141 files

DragonFlyBSD/src ad801e3lib/libnvmm libnvmm_x86.c, test/testcases/libnvmm h_mem_assist.c h_mem_assist_asm.S

libnvmm(3): Add support for "BT r/m, imm8"

Used by Windows Vista 64bit.

Credit: Maxime Villard (m00nbsd)
DeltaFile
+101-0lib/libnvmm/libnvmm_x86.c
+89-0test/testcases/libnvmm/h_mem_assist_asm.S
+5-0test/testcases/libnvmm/h_mem_assist.c
+195-03 files

DragonFlyBSD/src b604ef8lib/libnvmm libnvmm_x86.c, test/testcases/libnvmm h_mem_assist.c h_mem_assist_asm.S

libnvmm(3): Fix sign-extension on immediates

It's the immediate size that should be used for sign-extension, not the
operand size. Fix this, and add a unit-test for it.

Credit: Maxime Villard (m00nbsd)
DeltaFile
+21-0test/testcases/libnvmm/h_mem_assist_asm.S
+2-7lib/libnvmm/libnvmm_x86.c
+2-0test/testcases/libnvmm/h_mem_assist.c
+25-73 files

DragonFlyBSD/src 1391cc4lib/libnvmm libnvmm_x86.c, test/testcases/libnvmm h_mem_assist.c h_mem_assist_asm.S

libnvmm(3): Fix the emulation of REP/REPN prefixes

- REP applies only to string instructions, so restrict the emulation
  accordingly, and add a unit-test to ensure correctness.
- REPN applies only to SCAS and CMPS, neither of which we support;
  nevertheless, allow REPN to be used with MOVS/LODS/STOS.

Credit: Maxime Villard (m00nbsd)
DeltaFile
+18-6lib/libnvmm/libnvmm_x86.c
+16-1test/testcases/libnvmm/h_mem_assist_asm.S
+2-0test/testcases/libnvmm/h_mem_assist.c
+36-73 files

DragonFlyBSD/src 453793elib/libnvmm libnvmm_x86.c

libnvmm(3): Do not confuse long-mode and 64bit-mode

32bit compatibility mode has EFER.LMA=1 and CS.L=0. Use CS.L rather than
EFER.LMA to determine whether to apply segmentation.

Credit: Maxime Villard (m00nbsd)
DeltaFile
+4-10lib/libnvmm/libnvmm_x86.c
+4-101 files

DragonFlyBSD/src ed75211lib/libnvmm libnvmm_x86.c

libnvmm(3): Remove erroneous PS check on L1 PTEs

On L1 PTEs, the PS bit is actually PAT, and it is legal for it to be set.

Credit: Maxime Villard (m00nbsd)
DeltaFile
+0-6lib/libnvmm/libnvmm_x86.c
+0-61 files

DragonFlyBSD/src d4608dclib/libnvmm libnvmm_x86.c

Revert "libnvmm(3): Simplify x86_emul.func prototype"

This reverts commit b4ca47aaefeba38c6205a34b0e24495f29d61463.

Directly passing 'uint64_t *gprs' saves a few fetch instructions.

In addition, we're not going to implement the instruction emulation that
requires further extend the 'func' prototype, so this reverted
simplification is of little use.

Discussed-with: Maxime Villard
DeltaFile
+22-32lib/libnvmm/libnvmm_x86.c
+22-321 files

DragonFlyBSD/src 18e8b20test/testcases/libnvmm h_mem_assist.c h_io_assist.c

testcases/libnvmm: Improve error handling of IO/memory callbacks

Don't simply abort the program in case of nvmm_assist_{io,mem}() errors.
Instead, propagate the error to the test runner so that the total
failures are counted and reported in the end.

This is a follow-up fix to my previous commit
dad22e44dc57d9ba999b6826494043a616e16b43.
DeltaFile
+18-13test/testcases/libnvmm/h_mem_assist.c
+18-13test/testcases/libnvmm/h_io_assist.c
+36-262 files

DragonFlyBSD/src cea9f57test/testcases/libnvmm h_mem_assist.c h_mem_assist_asm.S

testcases/libnvmm: Rename our extra tests to avoid conflicts
DeltaFile
+8-8test/testcases/libnvmm/h_mem_assist_asm.S
+7-8test/testcases/libnvmm/h_mem_assist.c
+15-162 files

DragonFlyBSD/src c620eectest/testcases/libnvmm h_mem_assist.c h_io_assist.c

testcases/libnvmm: Extract OS-specific bits into h_os.h
DeltaFile
+91-0test/testcases/libnvmm/h_os.h
+3-46test/testcases/libnvmm/h_io_assist.c
+3-45test/testcases/libnvmm/h_mem_assist.c
+97-913 files

DragonFlyBSD/src dad22e4test/testcases/libnvmm h_io_assist.c h_mem_assist.c

testcases/libnvmm: Print more info and report total failures

* Print a few more details in the output logs.
* Run all tests to completeion and report the total number of failures
  at the end.
DeltaFile
+36-13test/testcases/libnvmm/h_mem_assist.c
+20-8test/testcases/libnvmm/h_io_assist.c
+56-212 files

DragonFlyBSD/src da9c391test/testcases/libnvmm h_mem_assist.c h_io_assist.c

testcases/libnvmm: Add CFLAGS+=-g and enable WARNS=6
DeltaFile
+1-1test/testcases/libnvmm/h_mem_assist.c
+1-1test/testcases/libnvmm/h_io_assist.c
+2-0test/testcases/libnvmm/Makefile.inc
+4-23 files

DragonFlyBSD/src 691a36eusr.sbin/nvmmctl nvmmctl.8

nvmmctl.8: Improve command enumeration style
DeltaFile
+3-3usr.sbin/nvmmctl/nvmmctl.8
+3-31 files

DragonFlyBSD/src 0d5a90bsys/dev/virtual/nvmm nvmm_ioctl.h nvmm_os.h

nvmm(4): Add a few comments and clean up a bit
DeltaFile
+2-4sys/dev/virtual/nvmm/nvmm_internal.h
+4-1sys/dev/virtual/nvmm/nvmm_os.h
+0-2sys/dev/virtual/nvmm/nvmm_ioctl.h
+6-73 files

DragonFlyBSD/src ea254afsys/dev/virtual/nvmm/x86 nvmm_x86_vmxfunc.S nvmm_x86_svmfunc.S

nvmm(4): Undefine all specialreg macros to avoid potential conflicts

The 'nvmm_x86.h' is a public header that's included via 'nvmm.h', so
it's possible for the custom defined CR0/CR4/XCR0/MSR bits to conflict
with OS's version; for example, including one header that pulls in
<machine/specialreg.h>.  This is actually the case happened in NetBSD
11.0.

In order to resolve the conflict in NetBSD 11.0 and be future-proof,
move the specialreg macros to the internal header 'nvmm_x86_internal.h',
and generate the `#undef` block to undefine all the macros to avoid any
redefinition warnings.

Discussed-with: Maxime Villard (m00nbsd)
DeltaFile
+256-1sys/dev/virtual/nvmm/x86/nvmm_x86_internal.h
+0-70sys/dev/virtual/nvmm/x86/nvmm_x86.h
+2-2sys/dev/virtual/nvmm/x86/nvmm_x86_vmxfunc.S
+2-2sys/dev/virtual/nvmm/x86/nvmm_x86_svmfunc.S
+260-754 files

DragonFlyBSD/src 7c512aasys/dev/virtual/nvmm nvmm_dragonfly.c nvmm.c, sys/dev/virtual/nvmm/x86 nvmm_x86_vmx.c nvmm_x86_svm.c

nvmm(4): Dedup inclusion of system headers
DeltaFile
+1-13sys/dev/virtual/nvmm/x86/nvmm_x86_internal.h
+6-4sys/dev/virtual/nvmm/nvmm_os.h
+0-6sys/dev/virtual/nvmm/x86/nvmm_x86_vmx.c
+0-6sys/dev/virtual/nvmm/x86/nvmm_x86_svm.c
+0-6sys/dev/virtual/nvmm/nvmm.c
+0-5sys/dev/virtual/nvmm/nvmm_dragonfly.c
+7-402 files not shown
+7-468 files

DragonFlyBSD/src dc2d842sys/dev/virtual/nvmm nvmm.c nvmm_internal.h, sys/dev/virtual/nvmm/x86 nvmm_x86_vmx.c nvmm_x86_svm.c

nvmm(4): Sync misc changes from m00nbsd

* Fix extern global 'nmachines' to 'nvmm_nmachines'.
* Minor cleanup to NetBSD's pmap_ept_has_ad handling and EPT/NPT pmap
  setup.
* Some code style tweaks.

No functional changes.
DeltaFile
+15-17sys/dev/virtual/nvmm/x86/nvmm_x86_svm.c
+15-13sys/dev/virtual/nvmm/x86/nvmm_x86_vmx.c
+3-8sys/dev/virtual/nvmm/nvmm_os.h
+5-5sys/dev/virtual/nvmm/nvmm_internal.h
+6-4sys/dev/virtual/nvmm/nvmm.h
+4-5sys/dev/virtual/nvmm/nvmm.c
+48-523 files not shown
+52-619 files

DragonFlyBSD/src 719a5b4lib/libnvmm libnvmm_x86.c

libnvmm(3): Fix build after nvmm_x86.h adjustment
DeltaFile
+8-0lib/libnvmm/libnvmm_x86.c
+8-01 files

DragonFlyBSD/src 9987ec0test/testcases/libnvmm h_mem_assist.c h_io_assist.c

testcases/libnvmm: Fix build after nvmm_x86.h adjustment
DeltaFile
+13-0test/testcases/libnvmm/h_mem_assist.c
+13-0test/testcases/libnvmm/h_io_assist.c
+26-02 files

DragonFlyBSD/src 1a32130lib/libutil pty.3, share/man/man4 mtw.4 corecstat.4

Sort SEE ALSO in a few manual pages.
DeltaFile
+3-3share/man/man4/pty.4
+2-2usr.bin/setcaps/setcaps.1
+1-1share/man/man4/mtw.4
+1-1share/man/man4/corecstat.4
+1-1lib/libutil/pty.3
+8-85 files

DragonFlyBSD/src ac8b1c8share/man/man9 unr.9

unr.9: Fix typo.
DeltaFile
+1-1share/man/man9/unr.9
+1-11 files

DragonFlyBSD/src 003c13finclude stdint.h ndbm.h, include/xlocale _monetary.h

Add <sys/cdefs.h> inclusion to a number of headers.

These are the last non-contrib headers that were using macros from
<sys/cdefs.h> but were not including it.
DeltaFile
+2-0sys/sys/_clock_id.h
+2-0include/xlocale/_monetary.h
+2-0include/ndbm.h
+1-0sys/sys/_ucontext.h
+1-0sys/netinet/in.h
+1-0include/stdint.h
+9-02 files not shown
+11-08 files

DragonFlyBSD/src 9e1703dsys/dev/virtual/nvmm/x86 nvmm_x86_vmx.c nvmm_x86_svm.c

nvmm(4): Improve guest TSC handling

Don't skip updating TSC if the emulator set a zero value, which can
happen if the emulator resets the VM.  In this case, we really want this
to be applied.

Meanwhile, rename 'gtsc_match' to 'gtsc_last'.

Credit: Maxime Villard (m00nbsd)
DeltaFile
+8-10sys/dev/virtual/nvmm/x86/nvmm_x86_vmx.c
+8-10sys/dev/virtual/nvmm/x86/nvmm_x86_svm.c
+16-202 files

DragonFlyBSD/src 51e47edsys/dev/virtual/nvmm/x86 nvmm_x86_internal.h nvmm_x86_vmx.c

nvmm(4): Make use of kernel_fpu_begin() and kernel_fpu_end()

The kernel_fpu_*() API was added to help drm/amdgpu in commit
1be00ff1850ebb705db236c08160ee8fea99b32a, shortly after I ported NVMM.
Use this API to reduce difference with the NVMM upstream.

Credit: Maxime Villard (m00nbsd)
DeltaFile
+1-14sys/dev/virtual/nvmm/x86/nvmm_x86_vmx.c
+1-14sys/dev/virtual/nvmm/x86/nvmm_x86_svm.c
+2-2sys/dev/virtual/nvmm/x86/nvmm_x86_internal.h
+4-303 files