Due unique characteristics of stub syscalls
(e.g. fork or execve) a special care needs
to be taken to ensure no compiler
optimizations nor C calling convention will
break the stack and/or registers. In this
commit we separated normal override syscall
routines while adding helper macros to
define syscall shims properly once and for
all (hopefully). They ensure proper linkage
and calling conventions are used (even if
not enforced).
This also adds more documentation to the
override_syscall with hints how to properly
override different syscalls.
Reading of the two following articles is
mandatory:
https://lwn.net/Articles/604287/https://lwn.net/Articles/604406/
This commits adds an extensive (yet not full)
hwmon subsystem emulation. It generates a
believable values on-the-fly to match the
target hardware specification (based on the
platform-specific sensors added earlier).
In the future this layer may be fed by the
external source and serve as a simple proxy
between real values gathered by some driver
and structures the mfgBIOS (and its ioctl
callers) expect. This would be similar to the
syno-modfied drivers/hwmon/adt7475.c driver
from the GPLed kernel sources.
Normally GetHwCapability depends on some external
factors and is provided by the mfgBIOS. Instead of
discovering all the peculiarities of every platform
we simply shim the GetHwCapability to provide rest
of the system information about the physical
capabilities of the platform the OS is running on.
Technically it's possible to extend capabilities
beyond what the original platform support but it's
not recommended as the original mfgBIOS for the
given platform may have some unknown assumptions
hardcoded in its closed-source implementation.
We've observed that 918 platform likes
to optimize calls by asking for the log
directory from time to time, instead of
pulling the logs right away. This call
wasn't implemented original.
If that call is not implemented errors
are logged as this isn't technically a
requirement in the ATAPI spec but normal
drives which support SMART logging also
support the log directory. A classic
example of spec vs. real life.
Every hardware platform contains a more or
less extensive monitoring capabilities. Most
use what's called hwmon, which through
multiple layers lands data in /run/hwmon.
This commit introduces definitions of supported
sensors and configuration for each of the
platforms currently defined. This is necessary
to properly support v7 release (it was mostly
ignored in v6).
The original header for mfgBIOS contain some
degree of information which can be simply included.
However, there are bunch of things which are
missing. We're attempting to avoid duplication
here.
Due to how synobios_ops (our VTK_*) were silently
changed between v6 and v7 forced us to introduce
a change we hate - v6/v7 designation during
compile time. Unfortunately, some structures
have been rearranged without any ifdefs so we
will be shimming wrong things depending on the
OS version. However, such huge change isn't
going to happen often.
Since the introduction of "fake SATA boot shim",
emulating cut-out SATA DOM functionality on some
platforms this SATA shim became ambiguous. This
commit fixes it by clearly indicating what it is.
This method is rather hacky and may be unstable in the future.
There's no danger of using it, but it may simply not work on
boot. Despite all the safeguards in place it's recommended to
use USB boot when possible over the fake-SATA boot device.
Unlike native SATA DOM shimming this method is not officially
supported by the syno kernel and relies on clever assumptions.
SATA boot shim contains a lot of moving parts. It
housed private overrides for its own functions,
conflicted with the SCSI notifier (and duplicated
its functionality partially) and many others. This
commit removes all duplicated code and changes the
logic to use already existing components available
in this module to make the shim simple and easy
to follow.
VirtIO is natively supported by the kernel, with
modules provided in the boot disks. However, VIO
disks can be attached via SATA or SCSI. The major
advantage of using SCSI is the number of disks
possible. However, they're not considered as SATA
complaint disks (i.e. normal disks) in the syno
kernel if not running VDSM. This commits adds
that (natively supported) feature back for all
platforms.
Linux kernel contains a lot of standardized pub/sub
notification chains. SCSI layer, as a very old one,
lacks the support for any form of notifications. We
need the information about devices coming and going
so we added the SCSI notification layer ourselves,
plugging into the standard Linux notifications
library.
SMART is often needed to determine the health of a disk and
subsystems (rightfully so) expect it to always be present
in a modern system. When it's not present some of the tools
may not work properly or refuse to operate at all. That's
we added a transparent SMART autogeneration. While it does
not replace the real deal (=no real drive monitoring), it
provides a set of believable values to SMART monitoring
tools.
We've identified, as of now, three cases where this layer
is needed:
- running under ESXi (it doesn't support SMART at all)
- running VirtIO disks connected to SCSI ports
- using RAID cards which don't work in a real HBA mode