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.
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]
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)
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)
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)
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)
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)
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
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.
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.
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)
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.
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.
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)
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)